Skip to content

Commit

Permalink
Merge pull request wtsi-npg#889 from mgcam/lane_type_qc4review_latest
Browse files Browse the repository at this point in the history
Robo evaluation for lanes
  • Loading branch information
marcomoscasgr authored Nov 19, 2024
2 parents b64aa9f + 443bd72 commit 9c3d68b
Show file tree
Hide file tree
Showing 15 changed files with 630 additions and 233 deletions.
25 changes: 25 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
LIST OF CHANGES FOR NPG-QC PACKAGE

- npg_qc::autoqc::qc_store - changed loading of ORM classes into memory
to on demand at run time.
- Added lane-level assessment to RoboQC:
- Extended npg_qc::Schema::Result::Review class to enable saving of
sequencing (lane-level) QC outcomes to database
- Extended npg_qc::autoqc::check::review to enable lane-level assessment
and documented the new feature.
- Made redundant 'qc_type' key of the 'robo' configuration.
- Fixed a bug in creating a list of class names in
npg_qc::autoqc::check::review.
A list of names for result classes to be loaded was inferred
from all criteria in the 'robo' section under consideration.
Until now this did not pesent a problem since even when a number
of different criteria sections were present in the study RoboQC
section of the configuration file, it was possible to load all of
the AutoQC results for any given entity.
The bug is revealed when lane-level assessment is added to
the 'robo' section under the 'default' configuration. This
type of assessment might require presence of lane-level autoqc
results for checks that are never performed on sample level,
'tag_metrics' check being the most obvious example.
The fix is to infer the list of class names from the criteria,
which are going to be evaluated for the entity, rather than
from a collection of criteria from the whole 'robo' section.

release 73.0.0 (2024-10-24)
- Removed from the repository unused test data.
- npg_qc::autoqc::check::review:
Expand Down
7 changes: 5 additions & 2 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,9 @@ t/data/autoqc/review/with_criteria/product_release.yml
t/data/autoqc/review/with_na_criteria/product_release.yml
t/data/autoqc/review/no_criteria_section/product_release.yml
t/data/autoqc/review/not_hash/product_release.yml
t/data/autoqc/review/mqc_type/product_release.yml
t/data/autoqc/review/lib_type_scalar/product_release.yml
t/data/autoqc/review/lims_applicability_empty/product_release.yml
t/data/autoqc/review/no_known_applicability_type/product_release.yml
t/data/autoqc/review/unknown_qc_type/product_release.yml
t/data/autoqc/review/default_and_study_section/product_release.yml
t/data/autoqc/review/default_section/product_release.yml
t/data/autoqc/review/wrong_default_and_study_section/product_release.yml
Expand Down Expand Up @@ -672,6 +671,10 @@ t/data/qc_store/26291/plex3/qc/26291#3.bam_flagstats.json
t/data/qc_store/26291/plex3/qc/26291#3_phix.bam_flagstats.json
t/data/qc_store/26291/lane1/qc/26291_1.tag_metrics.json
t/data/qc_store/26291/lane2/qc/26291_2.tag_metrics.json
t/data/runfolder_49285/240802_A00537_1044_BHJKCGDSXC.tar.gz
t/data/runfolder_49285/README
t/data/runfolder_49285/product_release.yml
t/data/runfolder_49285/samplesheet_49285.csv
t/data/samtools_stats/26597_1_F0xB00.stats
t/data/samtools_stats/26607_1#20_F0xB00.stats
t/data/samtools_stats/26607_1#20_F0xB00.samtools_stats.json
Expand Down
38 changes: 20 additions & 18 deletions lib/npg_qc/Schema/Result/Review.pm
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,16 @@ __PACKAGE__->might_have (
},
);

=head2 uqc_outcome_ent
=head2 mqc_seq_outcome_ent
Type: might_have
Related object: L<npg_qc::Schema::Result::MqcLibraryOutcomeEnt>
=cut

__PACKAGE__->might_have (
'uqc_outcome_ent',
'npg_qc::Schema::Result::UqcOutcomeEnt',
'mqc_seq_outcome_ent',
'npg_qc::Schema::Result::MqcOutcomeEnt',
{ 'foreign.id_seq_composition' => 'self.id_seq_composition' },
{
is_deferrable => 1,
Expand Down Expand Up @@ -320,21 +320,15 @@ __PACKAGE__->has_many(
Both update and insert methods are modified.
If the qc outcome attribute is defined we will try saving this
outcome as either library mqc outcome or uqc outcome.
outcome as either library or sequencing mqc outcome.
If a final library mqc outcome already exists for this product
and we are trying to save a different final qc outcome, neither
the review nor the mqc records are created and an error is raised.
If a final mqc outcome already exists for this product and we are
trying to save a different final qc outcome, neither the review nor
the mqc records are created and an error is raised.
Saving a review result with a preliminary outcome should always
create or update a review row, but a library mqc outcome for the
product will only be updated if there is no existing final mqc
outcome.
The type of existing qc outcome is not checked at the point of
update. Therefore, it is possible to create by mistake a review
record to which different types of roboqc-derived qc outcomes
are linked.
create or update a review row, but the mqc outcome itself is only
updated if there is no existing final mqc outcome.
=cut

Expand Down Expand Up @@ -391,13 +385,21 @@ sub _save_qc_outcome {
my ($self, $qc_outcome) = @_;
#####
# What kind of qc outcome we need to update/create?
my $entity_type = (grep { $_ =~ /_outcome\Z/xms } keys %{$qc_outcome})[0];
# The value below can be either 'mqc_outcome' or 'mqc_seq_outcome'.
my $outcome_type = (grep { $_ =~ /_outcome\Z/xms } keys %{$qc_outcome})[0];
#####
# Find an existing qc outcome in the outcomes table or
# create a new object.
my $qc_row = $self->find_or_new_related($entity_type . '_ent',
my $qc_row = $self->find_or_new_related($outcome_type . '_ent',
{'id_seq_composition' => $self->id_seq_composition});

my $outcome_description = $qc_outcome->{$outcome_type};
# The outcome should be saved under the 'mqc_outcome' key.
if ($outcome_type ne 'mqc_outcome') {
$qc_outcome->{'mqc_outcome'} = $outcome_description;
delete $qc_outcome->{$outcome_type};
}

my $update_or_create = 1;
try {
$update_or_create = $qc_row->valid4update($qc_outcome);
Expand All @@ -408,7 +410,7 @@ sub _save_qc_outcome {
# no mqc update and no error. We might be archiving post-manual QC.
if (($err =~ /Final\ outcome\ cannot\ be\ updated/xms) and
(not $qc_row->mqc_outcome
->is_final_outcome_description($qc_outcome->{'mqc_outcome'}))) {
->is_final_outcome_description($outcome_description))) {
$update_or_create = 0;
} else {
croak "Not saving review result. $err for " . $qc_row->composition->freeze();
Expand Down
Loading

0 comments on commit 9c3d68b

Please sign in to comment.