-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #681 from wtsi-npg/devel
merge from devel to master to create release 68.2.0
- Loading branch information
Showing
11 changed files
with
286 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
use FindBin qw($Bin); | ||
use lib ( -d "$Bin/../lib/perl5" ? "$Bin/../lib/perl5" : "$Bin/../lib" ); | ||
use Log::Log4perl qw(:levels); | ||
use Try::Tiny; | ||
use Carp; | ||
|
||
use npg_tracking::glossary::rpt; | ||
use npg_tracking::glossary::composition::factory::rpt_list; | ||
use npg_tracking::glossary::moniker; | ||
use npg_qc::autoqc::checks::review; | ||
|
||
our $VERSION = '0'; | ||
|
||
Log::Log4perl->easy_init({layout => '%d %-5p %c - %m%n', | ||
level => $INFO}); | ||
my $logger = Log::Log4perl->get_logger(); | ||
|
||
my $dir_out = $ARGV[0]; | ||
if (defined $dir_out) { | ||
if (($dir_out ne q[]) and (-d $dir_out) and (-w $dir_out)) { | ||
$logger->info("Using output directory $dir_out"); | ||
} else { | ||
$logger->error( | ||
"Output directory $dir_out does not exists or is not writable"); | ||
exit 2; | ||
} | ||
} else { | ||
$logger->info('Using current directory as an output directory'); | ||
} | ||
|
||
my $line_number = 0; | ||
##no critic (InputOutput::ProhibitExplicitStdin) | ||
while (my $line = <STDIN>) { | ||
##use critic | ||
$line_number++; | ||
|
||
if ($line =~ /\Asample_name,/smx) { # header, skip | ||
next; | ||
} | ||
my $l = "Line $line_number:"; | ||
my $outcome; | ||
my $file_name_root; | ||
my $r; | ||
my $sname; | ||
my $lib_type; | ||
|
||
try { | ||
my @columns = split /,/xms, $line; | ||
(@columns >= 2) or croak 'at least two columns are expected'; | ||
$file_name_root = shift @columns; | ||
$file_name_root or croak 'no file name in the first column'; | ||
$outcome = pop @columns; | ||
defined $outcome or croak 'no outcome in the last column'; | ||
$outcome =~ s/\s+\Z//xms; | ||
$outcome =~ /\A(TRUE|FALSE)\Z/xms or croak | ||
"unexpected outcome value '$outcome'"; | ||
|
||
my $h = npg_tracking::glossary::moniker->parse_file_name($file_name_root); | ||
my $rpt = npg_tracking::glossary::rpt->deflate_rpt($h); | ||
$r = npg_qc::autoqc::checks::review->new(rpt_list => $rpt); | ||
$sname = $r->lims->sample_supplier_name(); | ||
$lib_type = $r->lims->library_type(); | ||
} catch { | ||
$logger->error("$l $_"); | ||
exit 1; | ||
}; | ||
|
||
if (!$sname) { | ||
$logger->warn( | ||
"$l skipping $file_name_root, sample supplier name is not set"); | ||
next; | ||
} | ||
|
||
my ($name_prefix) = $sname =~ /\A([[:upper:]]{4})-/xms; | ||
if (!$name_prefix || ($name_prefix =~ /\ACGAP\Z/ixms)) { | ||
$logger->warn( | ||
"$l skipping $file_name_root, sample '${sname}' does not belong to Heron"); | ||
next; | ||
} | ||
|
||
if (!$lib_type) { | ||
$logger->warn( | ||
"$l skipping $file_name_root, library type is not set"); | ||
next; | ||
} | ||
|
||
$r->result->pass(int($outcome eq 'TRUE' ? 1 : 0)); | ||
$r->result->qc_outcome($r->generate_qc_outcome('uqc', 'artic-qc')); | ||
$r->result->library_type($lib_type); | ||
my $condition = 'Passed ncov2019-artic-nf QC'; | ||
$r->result->evaluation_results({$condition => $r->result->pass}); | ||
$r->result->criteria({'and' => [$condition]}); | ||
try { | ||
$r->result->store($dir_out); | ||
} catch { | ||
$logger->error("$l $_"); | ||
exit 2; | ||
}; | ||
} | ||
|
||
exit 0; | ||
|
||
__END__ | ||
=head1 NAME | ||
npg_simple_robo4artic | ||
=head1 USAGE | ||
=head1 CONFIGURATION | ||
=head1 SYNOPSIS | ||
echo '34014_1#104,TRUE' | npg_simple_robo4artic | ||
echo '34014_1#104,FALSE' | npg_simple_robo4artic 'my_dir' | ||
=head1 DESCRIPTION | ||
This script creates autoqc review result JSON files for | ||
entities and outcomes piped from STDIN. One line of input | ||
produces one file, unless this input is considered irrelevant. | ||
The JSON files are created in the working directory unless an | ||
alternative directory is specified as teh only argument. The | ||
qc outcomes are recorded as user QC. | ||
Example of input: | ||
34014_1#104,1.21,98.61,19221,34014_1#104.primertrimmed.consensus.fa,34014_1#104.mapped.primertrimmed.sorted.bam,TRUE | ||
34014_1#105,87.85,9.91,376,34014_1#105.primertrimmed.consensus.fa,34014_1#105.mapped.primertrimmed.sorted.bam,FALSE | ||
Only the first and the last column of the input is considered. | ||
=head1 REQUIRED ARGUMENTS | ||
None | ||
=head1 OPTIONS | ||
=head1 SUBROUTINES/METHODS | ||
=head1 DIAGNOSTICS | ||
=head1 CONFIGURATION AND ENVIRONMENT | ||
=head1 DEPENDENCIES | ||
=over | ||
=item strict | ||
=item warnings | ||
=item FindBin | ||
=item lib | ||
=item Carp | ||
=item Try::Tiny | ||
=item Log::Log4perl | ||
=item npg_tracking::glossary::rpt | ||
=item npg_tracking::glossary::composition::factory::rpt_list | ||
=item npg_tracking::glossary::moniker | ||
=item npg_qc::autoqc::checks::review | ||
=back | ||
=head1 INCOMPATIBILITIES | ||
=head1 EXIT STATUS | ||
=head1 BUGS AND LIMITATIONS | ||
=head1 AUTHOR | ||
Marina Gourtovaia | ||
=head1 LICENSE AND COPYRIGHT | ||
Copyright (C) 2020 Genome Research Ltd. | ||
This file is part of NPG. | ||
NPG is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.