Skip to content

Commit

Permalink
Merge pull request #822 from mgcam/qc_db_access
Browse files Browse the repository at this point in the history
Removed pipeline dependency on npg_qc::Schema
  • Loading branch information
jmtcsngr authored Feb 7, 2024
2 parents fcdbf6c + ea8db8b commit 9558231
Show file tree
Hide file tree
Showing 14 changed files with 7 additions and 688 deletions.
8 changes: 0 additions & 8 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -1030,14 +1030,6 @@ t/data/qc/references/Homo_sapiens/1000Genomes_hs37d5/all/fasta/hs37d5.fa
t/data/qc/references/PhiX/default/all/fasta/PhiX.fasta
t/data/qc/samplesheet_14043.csv
t/data/qc/samplesheet_14353.csv
t/data/qc_outcomes/fixtures/000-mqc_library_outcome_dict.yml
t/data/qc_outcomes/fixtures/000-mqc_outcome_dict.yml
t/data/qc_outcomes/fixtures/000-uqc_outcome_dict.yml
t/data/qc_outcomes/fixtures/200-seq_component.yml
t/data/qc_outcomes/fixtures/300-seq_component_composition.yml
t/data/qc_outcomes/fixtures/300-seq_composition.yml
t/data/qc_outcomes/fixtures/400-mqc_library_outcome_ent.yml
t/data/qc_outcomes/fixtures/README
t/data/release/config/archive_off/product_release.yml
t/data/release/config/archive_on/product_release.yml
t/data/release/config/bqsr_off/product_release.yml
Expand Down
16 changes: 0 additions & 16 deletions lib/npg_pipeline/base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,6 @@ within npg_pipeline package
=head2 npg_tracking_schema
=head2 qc_schema
An attribute caching a connection to a QC database.
The attribute is allowed to be undefined and is implicitly undefined
since no default or build method is provided. This is done in order
to prevent the automatic connection to a database in child classes.
=cut

has 'qc_schema' => (
metaclass => 'NoGetopt',
isa => 'Maybe[npg_qc::Schema]',
is => 'ro',
required => 0,
);

=head2 flowcell_id
=head2 tracking_run
Expand Down
110 changes: 0 additions & 110 deletions lib/npg_pipeline/product.pm
Original file line number Diff line number Diff line change
Expand Up @@ -598,116 +598,6 @@ sub chunk_as_product {
return __PACKAGE__->new($ref);
}


=head2 final_seqqc_objs
Returns a list of DBIx row objects representing a sequencing QC outcomes
for component lanes of this product. If not all lanes have a final outcome,
an empty list is returned.
npg_qc::Schema object argument is required.
use List::MoreUtils qw/all any/;
my @seq_qc_objs = $p->final_seqqc_objs($schema);
my $passed = @seq_qc_objs && (all { $_->is_accepted } @seq_qc_objs);
my $failed = !@seq_qc_objs || (any { $_->is_rejected } @seq_qc_objs);
=cut

sub final_seqqc_objs {
my ($self, $schema) = @_;

$schema or croak 'qc schema argument is required';

my @lp = $self->lanes_as_products;
my @seqqc = grep { $_->has_final_outcome }
$schema->resultset('MqcOutcomeEnt')
->search_via_composition([map{$_->composition}@lp])->all;
if (@lp != @seqqc) {
return;
}

return @seqqc;
}

=head2 seqqc_objs
Returns a list of DBIx row objects representing a sequencing QC outcomes
for component lanes of this product, even if not all outcomes are final.
npg_qc::Schema object argument is required.
use List::MoreUtils qw/all any/;
my @seq_qc_objs = $p->seqqc_objs($schema);
#these may or may not be final outcomes
my $passed = @seq_qc_objs && (all { $_->is_accepted } @seq_qc_objs);
my $failed = !@seq_qc_objs || (any { $_->is_rejected } @seq_qc_objs);
=cut

sub seqqc_objs {
my ($self, $schema) = @_;

$schema or croak 'qc schema argument is required';

my @lp = $self->lanes_as_products;
my @seqqc = $schema->resultset('MqcOutcomeEnt')
->search_via_composition([map{$_->composition}@lp])->all;
if (@lp != @seqqc) {
return;
}
return @seqqc;
}

=head2 final_libqc_obj
Returns a DBIx row object representing a final library QC outcome.
Returns an undefined value if the final library QC outcome is
not available for this product.
npg_qc::Schema object argument is required.
my $lib_qc_obj = $p->final_libqc_obj($schema);
print $lib_qc_obj->is_accepted;
=cut

sub final_libqc_obj {
my ($self, $schema) = @_;

$schema or croak 'qc schema argument is required';

my $libqc = $schema->resultset('MqcLibraryOutcomeEnt')
->search_via_composition([$self->composition])->next;
if ($libqc && $libqc->has_final_outcome) {
return $libqc;
}

return;
}

=head2 libqc_obj
Returns a DBIx row object representing the library QC outcome.
Returns an undefined value if the library QC outcome is
not available for this product.
npg_qc::Schema object argument is required.
my $lib_qc_obj = $p->libqc_obj($schema);
=cut

sub libqc_obj {
my ($self, $schema) = @_;

$schema or croak 'qc schema argument is required';

return $schema->resultset('MqcLibraryOutcomeEnt')
->search_via_composition([$self->composition])->next;
}



__PACKAGE__->meta->make_immutable;

1;
Expand Down
8 changes: 5 additions & 3 deletions lib/npg_pipeline/validation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,11 @@ a database connection.
=cut

has '+qc_schema' => (
lazy => 1,
builder => '_build_qc_schema',
has 'qc_schema' => (
isa => 'npg_qc::Schema',
is => 'ro',
required => 0,
lazy_build => 1,
);
sub _build_qc_schema {
return npg_qc::Schema->connect();
Expand Down
11 changes: 2 additions & 9 deletions t/15-product-release.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ Log::Log4perl->easy_init({level => $INFO,
with 'npg_testing::db';
}

# See README in fixtures for a description of the test data.
my $qc = TestDB->new (
sqlite_utf8_enabled => 1,
verbose => 0)->create_test_db('npg_qc::Schema');

local $ENV{NPG_CACHED_SAMPLESHEET_FILE} =
't/data/novaseq/180709_A00538_0010_BH3FCMDRXX/' .
'Data/Intensities/BAM_basecalls_20180805-013153/' .
Expand All @@ -49,8 +44,7 @@ subtest 'expected_files' => sub {
(conf_path => "t/data/release/config/archive_on",
runfolder_path => $runfolder_path,
id_run => 26291,
timestamp => $timestamp,
qc_schema => $qc);
timestamp => $timestamp);

my $path = "$runfolder_path/Data/Intensities/" .
'BAM_basecalls_20180805-013153/no_cal/archive/plex1';
Expand Down Expand Up @@ -86,8 +80,7 @@ subtest 'expected_unaligned_files' => sub {
(conf_path => "t/data/release/config/archive_on",
runfolder_path => $runfolder_path,
id_run => 26291,
timestamp => $timestamp,
qc_schema => $qc);
timestamp => $timestamp);

my $product = $archiver->products->{data_products}->[4];
my $path = "$runfolder_path/Data/Intensities/" .
Expand Down
32 changes: 0 additions & 32 deletions t/data/qc_outcomes/fixtures/000-mqc_library_outcome_dict.yml

This file was deleted.

27 changes: 0 additions & 27 deletions t/data/qc_outcomes/fixtures/000-mqc_outcome_dict.yml

This file was deleted.

16 changes: 0 additions & 16 deletions t/data/qc_outcomes/fixtures/000-uqc_outcome_dict.yml

This file was deleted.

Loading

0 comments on commit 9558231

Please sign in to comment.