Skip to content

Commit

Permalink
Stop parsing run details out of folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcam committed Mar 7, 2024
1 parent f6ca2f7 commit cb4cafd
Show file tree
Hide file tree
Showing 11 changed files with 256 additions and 891 deletions.
3 changes: 0 additions & 3 deletions Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,9 @@ my $builder = $class->new(

'build_requires' => {
'ExtUtils::CBuilder' => 0,
'Archive::Tar' => 0,
'DateTime::Duration' => 0,
'DateTime::Format::SQLite' => 0,
'HTTP::Headers' => 0,
'IO::File' => 0,
'IPC::Open2' => 0,
'List::Util' => 0,
'Test::Compile' => 0,
'Test::Distribution' => 0,
Expand Down
11 changes: 11 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
LIST OF CHANGES


- npg_tracking::illumina::run::short_info
- Stopped parsing out run details from the run folder name. Deleted
attributes, which were populated this way: 'name', 'instrument_string',
'slot', 'flowcell_id'.
- Deleted 'short_reference' method.
- npg_tracking::illumina::run::folder
- Removed dependency on 'short_reference' method, which used to be
provided by npg_tracking::illumina::run::short_info.
- Introduce a check to ensure that the run folder name on staging and
in the database, when both are available, are the same.

release 100.0.1
- For aggregation of lims objects by library in st::api::lims, do not
consider the same library with different tag index in the same lane
Expand Down
1 change: 0 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ t/80-npg_tracking-report-events.t
t/80-npg_tracking-report-event2followers.t
t/80-npg_tracking-report-event2subscribers.t
t/data/schema.txt
t/data/090414_IL24_2726.tar.bz2
t/data/dbic_fixtures/000-Designation.yml
t/data/dbic_fixtures/000-EntityType.yml
t/data/dbic_fixtures/000-InstrumentModDict.yml
Expand Down
69 changes: 38 additions & 31 deletions lib/npg_tracking/illumina/run/folder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,45 @@ sub _build_runfolder_path {
my $path = $self->_get_path_from_given_path();
$path && return $path;

# get info form DB if there - could be better integrated....
if ($self->npg_tracking_schema() and
my $db_runfolder_name;
my $runfolder_name;
if ( $self->can('run_folder') and $self->has_run_folder ) {
$runfolder_name = $self->run_folder;
}

if ( $self->npg_tracking_schema() and
$self->can(q(id_run)) and $self->id_run() ) {
if (! $self->tracking_run->is_tag_set(q(staging))) {
croak q{NPG tracking reports run }.$self->id_run().q{ no longer on staging}
if (not $self->tracking_run->is_tag_set(q(staging))) {
croak sprintf 'NPG tracking reports run %i no longer on staging',
$self->id_run;
}
if (my $gpath = $self->tracking_run->folder_path_glob and
my $fname = $self->tracking_run->folder_name) {
return $self->_get_path_from_glob_pattern(catfile($gpath, $fname));
$db_runfolder_name = $self->tracking_run->folder_name;
if ($db_runfolder_name) {
if (my $gpath = $self->tracking_run->folder_path_glob) {
$path = $self->_get_path_from_glob_pattern(
catfile($gpath, $db_runfolder_name)
);
}
}
}

return $self->_get_path_from_short_reference();
if ( (not $path) and $runfolder_name ) {
$path = $self->_get_path_from_glob_pattern(
$self->_folder_path_glob_pattern() . $runfolder_name
);
}

if ( $db_runfolder_name and $runfolder_name and
($db_runfolder_name ne $runfolder_name) ) {
carp sprintf 'Inconsistent db and given run folder name: %s, %s',
$db_runfolder_name, $runfolder_name;
}

if (not $path) {
croak 'Failed to infer runfolder_path';
}

return $path;
}

sub _build_analysis_path {
Expand Down Expand Up @@ -230,6 +256,7 @@ sub _build_subpath {
last;
}
}

return $path;
}

Expand Down Expand Up @@ -261,25 +288,6 @@ sub _infer_analysis_path {
return catdir( @path_components );
}

sub _get_path_from_short_reference {
my ($self) = @_;

if ( !$self->can(q(short_reference)) || !$self->short_reference() ) {
croak q{Not enough information to obtain the path};
}

# works out by 'glob'ing the filesystem, the path to the run_folder based on
# short_reference string

my $sr = $self->short_reference();
if ($sr =~ /\a(\d+)\z/xms) {
$sr = q{_{r,}} . $sr;
}

return $self->_get_path_from_glob_pattern(
$self->_folder_path_glob_pattern() . q{*} . $sr . q[{,_*}]);
}

sub _get_path_from_glob_pattern {
my ($self, $glob_pattern) = @_;

Expand Down Expand Up @@ -368,14 +376,13 @@ npg_tracking::illumina::run::folder
=head1 DESCRIPTION
This package might need to have something provide the short_reference method,
This package might need to have something provide the run_folder accessor
either declared in your class or via inheritance from
npg_tracking::illumina::run::short_info, which is the preferred option.
Failure to have provided a short_reference method might cause a run-time error
Failure to have provided the runfolder accessor might cause a run-time error
if your class needs to obtain any paths where a path or subpath was not given
and access to the tracking database is not available.
to glob for it).
In addition to this, you can add an analysis_path, which is the path to the
recalibrated directory, which will be used to construct other paths from.
Expand Down Expand Up @@ -469,7 +476,7 @@ Might be undefined.
=head1 LICENSE AND COPYRIGHT
Copyright (C) 2013,2014,2015,2018,2019,2020,2023 Genome Research Ltd.
Copyright (C) 2013,2014,2015,2018,2019,2020,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
Expand Down
Loading

0 comments on commit cb4cafd

Please sign in to comment.