Skip to content

Commit

Permalink
Merge pull request #451 from iainrb/fluidigm_qc_publish
Browse files Browse the repository at this point in the history
Add option to publish Fluidigm QC results to iRODS
  • Loading branch information
Keith James authored Apr 3, 2017
2 parents 4935651 + 427e5fc commit 54c6518
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
6 changes: 6 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Change log for WTSI genotyping pipeline

Latest version is hosted at: https://github.com/wtsi-npg/genotyping

Release 1.14.2: 2017-03-31
--------------------------

Added:
- Fluidigm QC script has option to publish results to iRODS

Release 1.14.1: 2017-03-28
--------------------------

Expand Down
20 changes: 20 additions & 0 deletions src/perl/bin/qc_fluidigm.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main;
use strict;
use warnings;
use Cwd qw(abs_path);
use DateTime;
use File::Copy qw(cp);
use File::Temp qw(tempfile);
use File::Spec::Functions qw(tmpdir);
Expand All @@ -16,6 +17,7 @@ package main;
use WTSI::NPG::Genotyping::Fluidigm::AssayDataObject;
use WTSI::NPG::Genotyping::Fluidigm::QC;
use WTSI::NPG::iRODS;
use WTSI::NPG::SimplePublisher;
use WTSI::NPG::Utilities qw(user_session_log);

my $uid = `whoami`;
Expand All @@ -32,6 +34,7 @@ sub run {
my $log4perl_config;
my $new_csv;
my $old_csv;
my $publish_dest;
my $query_path;
my $verbose;
my @filter_key;
Expand All @@ -47,6 +50,7 @@ sub run {
'logconf=s' => \$log4perl_config,
'new-csv=s' => \$new_csv,
'old-csv=s' => \$old_csv,
'publish-dest=s' => \$publish_dest,
'query-path=s' => \$query_path,
'verbose' => \$verbose,
'' => \$stdio); # Permits trailing '-' for STDIN
Expand Down Expand Up @@ -87,6 +91,11 @@ sub run {
$new_csv = $old_csv;
}
}
if ($publish_dest && ! $new_csv) {
pod2usage(-msg => "Must specify --new-csv or --in-place for ".
"publication of output to iRODS",
-exitval => 2);
}
# set up logging
my @log_levels;
if ($debug) { push @log_levels, $DEBUG; }
Expand Down Expand Up @@ -143,6 +152,14 @@ sub run {
$qc->write_csv($fh);
if (defined $new_csv) {
close $fh || $log->logcroak("Cannot close CSV output");
if (defined $publish_dest) {
my $publisher = WTSI::NPG::SimplePublisher->new(irods => $irods);
my $published = $publisher->publish_file($new_csv,
[],
$publish_dest,
DateTime->now);
$log->info('Published Fluidigm QC output to iRODS: ', $published);
}
}
if (defined $temp) {
my $cp_ok = cp($temp, $new_csv);
Expand Down Expand Up @@ -177,6 +194,9 @@ =head1 SYNOPSIS
to STDOUT.
--old-csv Path of a CSV file from which to read existing QC records.
Optional.
--publish-dest An iRODS collection for publication of the CSV output file.
Optional; if not given, output is not published to iRODS.
Not valid if output is being written to STDOUT.
--query-path An iRODS path to query for Fluidigm DataObjects. Required,
unless iRODS paths are supplied on STDIN using the '-'
option.
Expand Down
14 changes: 13 additions & 1 deletion src/perl/t/WTSI/NPG/Genotyping/Fluidigm/QCTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use File::Copy qw/copy/;
use File::Slurp qw/read_file/;
use File::Temp qw/tempdir/;
use Set::Scalar;
use Test::More tests => 17;
use Test::More tests => 19;
use Test::Exception;
use Text::CSV;

Expand Down Expand Up @@ -131,6 +131,18 @@ sub script_metaquery : Test(2) {
_validate_csv_output("$tmp/$csv_name", $msg);
}

sub script_publish : Test(2) {
my $irods = WTSI::NPG::iRODS->new;
my $publish_dest = $irods_tmp_coll.'/qc_output';
my $cmd = "$script --query-path $irods_tmp_coll ".
"--publish-dest $publish_dest ".
"--old-csv $tmp/$csv_name --in-place --logconf $logconf --debug";
$log->info("Running command '$cmd'");
ok(system($cmd)==0, "Script with --publish-dest exits OK");
my $obj_path = $publish_dest.'/'.$csv_name;
ok($irods->is_object($obj_path), 'QC output published to '.$obj_path);
}

sub script_update : Test(2) {
# ensure an entry with outdated md5 checksum is replaced
my $cmd = "$script --query-path $irods_tmp_coll ".
Expand Down

0 comments on commit 54c6518

Please sign in to comment.