-
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.
Enhanced a textual listing of instruments.
Added a column for recently used staging servers so that the loaders can easily spot instruments, which write to the same server.
- Loading branch information
Showing
4 changed files
with
157 additions
and
42 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 |
---|---|---|
|
@@ -2,9 +2,15 @@ package npg::model::instrument; | |
|
||
use strict; | ||
use warnings; | ||
use base qw(npg::model); | ||
use English qw(-no_match_vars); | ||
use File::Spec; | ||
use Carp; | ||
use DateTime; | ||
use DateTime::Duration; | ||
use DateTime::Format::MySQL; | ||
use List::MoreUtils qw(any uniq); | ||
use base qw(npg::model); | ||
|
||
use npg::model::user; | ||
use npg::model::run; | ||
use npg::model::instrument_format; | ||
|
@@ -15,10 +21,6 @@ use npg::model::instrument_annotation; | |
use npg::model::annotation; | ||
use npg::model::instrument_designation; | ||
use npg::model::designation; | ||
use DateTime; | ||
use DateTime::Duration; | ||
use DateTime::Format::MySQL; | ||
use List::MoreUtils qw/any/; | ||
|
||
our $VERSION = '0'; | ||
|
||
|
@@ -380,6 +382,46 @@ sub latest_annotation { | |
return $self->{latest_annotation}; | ||
} | ||
|
||
sub recent_staging_servers { | ||
my $self = shift; | ||
|
||
my $run_status = q[run in progress]; | ||
my $query = q[SELECT folder_path_glob FROM instrument | ||
JOIN run USING(id_instrument) | ||
JOIN run_status USING(id_run) | ||
JOIN run_status_dict USING(id_run_status_dict) | ||
WHERE folder_path_glob IS NOT NULL | ||
AND LENGTH(folder_path_glob) != 0 | ||
AND id_instrument=? AND description=? | ||
ORDER BY date DESC]; | ||
my $dbh = $self->util->dbh(); | ||
# Four rather than two latest runs since NovaSeq(X) instruments have | ||
# two sides, which write to the same staging server. | ||
my $rows = $dbh->selectall_arrayref($query, {RaiseError => 1, MaxRows => 4}, | ||
$self->id_instrument(), $run_status); | ||
my @globs = uniq map { $_->[0] } @{$rows}; | ||
# We do not need more that two unique globs. | ||
while (scalar @globs > 2) { | ||
pop @globs | ||
} | ||
|
||
my @servers = (); | ||
foreach my $area (@globs) { | ||
my @dirs = File::Spec->splitdir($area); | ||
# Current (May 2024) folder path globs look like | ||
# /{export,nfs}/esa-sv-20201215-03/IL_seq_data/*/ | ||
##no critic (ValuesAndExpressions::ProhibitMagicNumbers) | ||
if (@dirs >= 3 and $dirs[0] eq q[]) { | ||
push @servers, $dirs[2]; | ||
} else { | ||
push @servers, $area; | ||
} | ||
##use critic | ||
} | ||
|
||
return @servers; | ||
} | ||
|
||
sub does_sequencing { | ||
my $self = shift; | ||
return ($self->instrument_format->model && | ||
|
@@ -595,9 +637,9 @@ npg::model::instrument | |
=head1 DESCRIPTION | ||
Clearpress model for an instrument. | ||
To be replaced by DBIx model. Contains duplicates of functions in | ||
npg_tracking::Schema::Result::Instrument. When editing the code | ||
of this module consider if any changes are meeded in the other module. | ||
Contains duplicates of functions in npg_tracking::Schema::Result::Instrument. | ||
When editing the code of this module consider if any changes are needed in | ||
the other module. | ||
=head1 SUBROUTINES/METHODS | ||
|
@@ -621,11 +663,6 @@ npg::model::instrument | |
my $arAllInstruments = $oInstrument->instruments(); | ||
=head2 instrument_by_ipaddr - npg::model::instrument by its IP address | ||
my $oInstrument = $oInstrument->instrument_by_ipaddr('127.0.0.1'); | ||
instrument_by_instrument_comp | ||
=head2 instrument_by_instrument_comp - npg::model::instrument by its instrument_comp name | ||
=head2 current_instruments - arrayref of all npg::model::instruments with iscurrent=1 | ||
|
@@ -637,16 +674,6 @@ instrument_by_instrument_comp | |
my $lab = 'Sulston'; | ||
my $arCurrentSulstonInstruments = $oInstrument->current_instruments_from_lab($lab); | ||
=head2 last_wash_instrument_status - npg::model::instrument_status (or undef) corresponding to the last 'wash performed' state | ||
my $oInstrumentStatus = $oInstrument->last_wash_instrument_status(); | ||
=head2 check_wash_status - boolean whether this instrument needs washing | ||
Has a side-effect of updating an instrument's current instrument_status to 'wash required' | ||
$bNeedAWash = $oInstrument->check_wash_status(); | ||
=head2 runs - arrayref of npg::model::runs for this instrument | ||
my $arRuns = $oInstrument->runs(); | ||
|
@@ -719,6 +746,9 @@ Has a side-effect of updating an instrument's current instrument_status to 'wash | |
=head2 fc_slots2blocking_runs - a hash reference mapping instrument flowcell slots to blocking runs; tags for slots are used as keys | ||
=head2 recent_staging_servers - returns a list of names of staging servers | ||
this instrument most recently transferred data to, most recent server first. | ||
=head2 does_sequencing - returns true is the instrument does sequencing, false otherwise | ||
=head2 is_two_slot_instrument - returns true if this instrument has two slots, false otherwise | ||
|
@@ -729,7 +759,7 @@ returns true if the instrument is a MiSeq, false otherwise | |
=head2 is_cbot_instrument - returns true if this instrument is CBot, false otherwise | ||
=head2 current_run_by_id - returns one of current runs with teh argument id or nothing if a list of current runs does not contain a run with this id | ||
=head2 current_run_by_id - returns one of current runs with the argument id or nothing if a list of current runs does not contain a run with this id | ||
my $id_run = 22; | ||
my $run = $oInstrument->current_run_by_id($id_run); | ||
|
@@ -761,27 +791,21 @@ returns true if the instrument is a MiSeq, false otherwise | |
=item base | ||
=item npg::model | ||
=item File::Spec | ||
=item English | ||
=item Carp | ||
=item npg::model::user | ||
=item npg::model::run | ||
=item npg::model::instrument_format | ||
=item npg::model::instrument_status | ||
=item Readonly | ||
=item npg::model::instrument_status_dict | ||
=item DateTime | ||
=item npg::model::instrument_mod | ||
=item DateTime::Duration | ||
=item DateTime | ||
=item DateTime::Format::MySQL | ||
=item Readonly | ||
=item List::MoreUtils | ||
=back | ||
|
@@ -793,15 +817,15 @@ returns true if the instrument is a MiSeq, false otherwise | |
=over | ||
=item Roger Pettett, E<lt>[email protected]E<gt> | ||
=item Roger Pettett | ||
=item Marina Gourtovaia | ||
=back | ||
=head1 LICENSE AND COPYRIGHT | ||
Copyright (C) 2006,2008,2013,2014,2016,2018,2021 Genome Research Ltd. | ||
Copyright (C) 2006,2008,2013,2014,2016,2018,2021,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
Oops, something went wrong.