-
Notifications
You must be signed in to change notification settings - Fork 19
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 #796 from mgcam/daemon4novaseqx_samplesheet
Daemon4novaseqx samplesheet
- Loading branch information
Showing
9 changed files
with
230 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/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(:easy); | ||
|
||
use npg::samplesheet::auto; | ||
|
||
our $VERSION = '0'; | ||
|
||
Log::Log4perl->easy_init($INFO); | ||
|
||
my $log = Log::Log4perl->get_logger('main'); | ||
$log->info('Starting npg samplesheet daemon for NovaSeqX instruments'); | ||
|
||
npg::samplesheet::auto->new(instrument_format => 'NovaSeqX')->loop(); | ||
|
||
0; | ||
|
||
__END__ | ||
|
||
=head1 NAME | ||
|
||
npg_samplesheet4NovaSeqX | ||
|
||
=head1 USAGE | ||
|
||
npg_samplesheet4NovaSeqX | ||
|
||
=head1 DESCRIPTION | ||
|
||
The script, once started, runs in perpetuity, generating Illumina-style | ||
samplesheets for any NovaSeqX run with status 'run pending'. | ||
|
||
=head1 REQUIRED ARGUMENTS | ||
|
||
None | ||
|
||
=head1 OPTIONS | ||
|
||
=head1 DIAGNOSTICS | ||
|
||
=head1 CONFIGURATION | ||
|
||
Access to both npg_tracking and ml warehouse database is required. | ||
|
||
=head1 DEPENDENCIES | ||
|
||
=over | ||
|
||
=item strict | ||
|
||
=item warnings | ||
|
||
=item FindBin | ||
|
||
=item lib | ||
|
||
=item Log::Log4perl | ||
|
||
=item npg::samplesheet::auto | ||
|
||
=back | ||
|
||
=head1 EXIT STATUS | ||
|
||
Does not exit unless is sent a signal to terminate. | ||
|
||
=head1 INCOMPATIBILITIES | ||
|
||
=head1 BUGS AND LIMITATIONS | ||
|
||
=head1 AUTHOR | ||
|
||
Marina Gourtovaia E<lt>[email protected]<gt> | ||
|
||
=head1 LICENSE AND COPYRIGHT | ||
|
||
Copyright (C) 2023 GRL. | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,24 +60,6 @@ Readonly::Scalar my $MIN_COLUMN_NUM => 3; | |
####################### Public attributes ######################## | ||
################################################################## | ||
|
||
=head2 id_run | ||
An optional attribute | ||
=cut | ||
|
||
has '+id_run' => ( | ||
'lazy_build' => 1, | ||
'required' => 0, | ||
); | ||
sub _build_id_run { | ||
my ($self) = @_; | ||
if($self->has_tracking_run()){ | ||
return $self->run()->id_run(); | ||
} | ||
croak 'id_run or a run is required'; | ||
} | ||
|
||
=head2 extend | ||
A boolean attribute, false by default. | ||
|
@@ -509,7 +491,7 @@ David K. Jackson E<lt>[email protected]<gt> | |
=head1 LICENSE AND COPYRIGHT | ||
Copyright (C) 2019, 2020, 2023 Genome Research Ltd. | ||
Copyright (C) 2019,2020,2023,2024 Genome Research Ltd. | ||
This file is part of NPG. | ||
|
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 |
---|---|---|
|
@@ -8,18 +8,24 @@ use Readonly; | |
use File::Copy; | ||
use File::Spec::Functions; | ||
use Carp; | ||
use List::MoreUtils qw(none); | ||
|
||
use npg::samplesheet; | ||
use npg_tracking::Schema; | ||
use WTSI::DNAP::Warehouse::Schema; | ||
use st::api::lims::samplesheet; | ||
use npg::samplesheet; | ||
use npg::samplesheet::novaseq_xseries; | ||
|
||
with q(MooseX::Log::Log4perl); | ||
|
||
our $VERSION = '0'; | ||
|
||
Readonly::Scalar my $MISEQ_INSTRUMENT_FORMAT => 'MiSeq'; | ||
Readonly::Scalar my $DEFAULT_SLEEP => 90; | ||
Readonly::Array my @INSTRUMENT_FORMATS => ( | ||
$MISEQ_INSTRUMENT_FORMAT, | ||
$npg::samplesheet::novaseq_xseries::NX_INSTRUMENT_FORMAT | ||
); | ||
|
||
##no critic (Subroutines::ProhibitUnusedPrivateSubroutine) | ||
|
||
|
@@ -97,7 +103,7 @@ Tests that a valid instrument format is used. | |
|
||
sub BUILD { | ||
my $self = shift; | ||
if ($self->instrument_format ne $MISEQ_INSTRUMENT_FORMAT) { | ||
if (none {$self->instrument_format eq $_ } @INSTRUMENT_FORMATS) { | ||
my $m = sprintf | ||
'Samplesheet auto-generator is not implemented for %s instrument format', | ||
$self->instrument_format; | ||
|
@@ -141,9 +147,20 @@ sub process { | |
my $id_run = $r->id_run; | ||
$self->log->info('Considering ' . join q[,],$id_run,$r->instrument->name); | ||
|
||
my $ss = npg::samplesheet->new( | ||
run => $r, mlwh_schema => $self->mlwh_schema | ||
); | ||
my $ss; | ||
if ($self->instrument_format eq $MISEQ_INSTRUMENT_FORMAT) { | ||
$ss = npg::samplesheet->new( | ||
run => $r, | ||
mlwh_schema => $self->mlwh_schema | ||
); | ||
} else { | ||
$ss = npg::samplesheet::novaseq_xseries->new( | ||
run => $r, | ||
mlwh_schema => $self->mlwh_schema, | ||
align => 1 | ||
); | ||
} | ||
|
||
my $method_name = | ||
'_valid_samplesheet_file_exists_for_' . $self->instrument_format; | ||
my $generate_new = !$self->$method_name($ss, $id_run); | ||
|
@@ -241,6 +258,22 @@ sub _valid_samplesheet_file_exists_for_MiSeq {##no critic (NamingConventions::Ca | |
return; | ||
} | ||
|
||
sub _valid_samplesheet_file_exists_for_NovaSeqX {##no critic (NamingConventions::Capitalization) | ||
my ($self, $ss_object, $id_run) = @_; | ||
|
||
# The default samplesheet name starts with the date string. A new | ||
# samplesheet will be generated each day. Not a problem since the run | ||
# should either progress or be cancelled. | ||
|
||
my $o = $ss_object->output; | ||
if (-e $o) { | ||
$self->log->info(qq($o already exists for $id_run)); | ||
return 1; | ||
}; | ||
|
||
return; | ||
} | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
|
||
1; | ||
|
@@ -273,6 +306,8 @@ __END__ | |
=item Carp | ||
=item List::MoreUtils | ||
=item npg_tracking::Schema | ||
=item npg::samplesheet | ||
|
@@ -293,7 +328,7 @@ David K. Jackson E<lt>[email protected]<gt> | |
=head1 LICENSE AND COPYRIGHT | ||
Copyright (C) 2012,2013,2014,2019,2021,2023 GRL. | ||
Copyright (C) 2012,2013,2014,2019,2021,2023,2024 GRL. | ||
This file is part of NPG. | ||
|
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 |
---|---|---|
|
@@ -57,8 +57,16 @@ Run ID, an optional attribute. | |
=cut | ||
|
||
has '+id_run' => ( | ||
'lazy_build' => 1, | ||
'required' => 0, | ||
); | ||
sub _build_id_run { | ||
my $self = shift; | ||
if ($self->has_tracking_run()) { | ||
return $self->run()->id_run(); | ||
} | ||
croak 'id_run or a run is required'; | ||
} | ||
|
||
|
||
=head2 batch_id | ||
|
@@ -228,7 +236,7 @@ Marina Gourtovaia E<lt>[email protected]<gt> | |
=head1 LICENSE AND COPYRIGHT | ||
Copyright (C) 2019, 2020, 2023 Genome Research Ltd. | ||
Copyright (C) 2019,2020,2023,2024 Genome Research Ltd. | ||
This file is part of NPG. | ||
|
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 |
---|---|---|
|
@@ -10,14 +10,18 @@ use List::MoreUtils qw(any none uniq); | |
use List::Util qw(first max); | ||
use DateTime; | ||
use Data::UUID; | ||
use Try::Tiny; | ||
|
||
use npg_tracking::util::types; | ||
use st::api::lims::samplesheet; | ||
|
||
extends 'npg::samplesheet::base'; | ||
with 'MooseX::Getopt'; | ||
|
||
our $VERSION = '0'; | ||
|
||
Readonly::Scalar our $NX_INSTRUMENT_FORMAT => 'NovaSeqX'; | ||
|
||
Readonly::Scalar my $READ1_LENGTH => 151; | ||
Readonly::Scalar my $READ2_LENGTH => 151; | ||
Readonly::Scalar my $LIST_INDEX_TAG1 => 2; | ||
|
@@ -98,7 +102,7 @@ has 'dragen_software_version' => ( | |
sub _build_dragen_software_version { | ||
my $self = shift; | ||
|
||
if (!$self->has_id_run) { | ||
if (!$self->id_run) { | ||
croak 'DRAGEN software version cannot be retrieved. ' . | ||
'Either supply it as an argument or supply existing id_run'; | ||
} | ||
|
@@ -135,7 +139,7 @@ sub _build_file_name { | |
my $self = shift; | ||
|
||
my $file_name; | ||
if ($self->has_id_run) { | ||
if ($self->id_run) { | ||
$file_name = join q[_], | ||
$self->run_name, | ||
q[ssbatch] . $self->batch_id; | ||
|
@@ -185,10 +189,24 @@ sub _build_output { | |
|
||
|
||
has '+id_run' => ( | ||
'isa' => 'Maybe[NpgTrackingRunId]', | ||
'documentation' => 'NPG run ID, optional; if supplied, the record for this '. | ||
'run should exists in the run tracking database', | ||
); | ||
around '_build_id_run' => sub { | ||
my $orig = shift; | ||
my $self = shift; | ||
|
||
# Parent's builder method errors if id_run cannot be inferred from | ||
# the database record. Here we allow for this attribute to be undefined. | ||
# Depending on how other atributes are defined, it might be possible to | ||
# generate the samplesheet. | ||
my $id_run; | ||
try { | ||
$id_run = $self->$orig(@_); | ||
}; | ||
return $id_run; | ||
}; | ||
|
||
has '+batch_id' => ( | ||
'documentation' => 'LIMS batch identifier, optional. If not set, will be ' . | ||
|
@@ -325,7 +343,7 @@ sub _build_run_name { | |
|
||
my $run_name; | ||
if ($self->id_run()) { | ||
if ($self->run->instrument_format()->model() !~ /NovaSeqX/smx) { | ||
if ($self->run->instrument_format()->model() !~ /$NX_INSTRUMENT_FORMAT/smx) { | ||
croak 'Instrument is not registered as NovaSeq X Series ' . | ||
'in the tracking database'; | ||
} | ||
|
@@ -865,6 +883,10 @@ __END__ | |
=item Data::UUID | ||
=item Try::Tiny | ||
=item npg_tracking::util::types | ||
=back | ||
=head1 BUGS AND LIMITATIONS | ||
|
@@ -877,7 +899,7 @@ Marina Gourtovaia E<lt>[email protected]<gt> | |
=head1 LICENSE AND COPYRIGHT | ||
Copyright (C) 2023 Genome Research Ltd. | ||
Copyright (C) 2023,2024 Genome Research Ltd. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
|
Oops, something went wrong.