Skip to content

Commit

Permalink
Fixes and tests for lane-level entities
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcam committed Oct 24, 2024
1 parent 6e5d0d6 commit 250d960
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 13 deletions.
3 changes: 2 additions & 1 deletion lib/npg_qc/autoqc/checks/review.pm
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ sub generate_qc_outcome {
my $outcome = $package_name->generate_short_description(
$self->final_qc_outcome ? 1 : 0, $pass);

my $outcome_type = $self->lims->is_lane ? $QC_TYPE_SEQ : $QC_TYPE_LIB . '_outcome';
my $outcome_type = ($self->lims->is_lane ? $QC_TYPE_SEQ : $QC_TYPE_LIB)
. '_outcome';
return { $outcome_type => $outcome,
timestamp => create_current_timestamp(),
username => $ROBO_KEY };
Expand Down
70 changes: 62 additions & 8 deletions t/60-autoqc-checks-review.t
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ subtest 'evaluating generic for artic results' => sub {
};

subtest 'evaluating for LCMB library type' => sub {
plan tests => 2;
plan tests => 14;

my $test_data_path = 't/data/runfolder_49285';
my $runfolder_name = '240802_A00537_1044_BHJKCGDSXC';
Expand All @@ -834,24 +834,78 @@ subtest 'evaluating for LCMB library type' => sub {
verbose => 0
)->load();

my $rpt_list = "${id_run}:1:1";
my $init = {
my $check = npg_qc::autoqc::checks::review->new(
runfolder_path => $runfolder_path,
conf_path => $test_data_path,
rpt_list => $rpt_list,
rpt_list => "${id_run}:1:1",
use_db => 1,
_qc_schema => $schema
};
my $check = npg_qc::autoqc::checks::review->new($init);
lives_ok { $check->execute() } 'check runs OK';
);
lives_ok { $check->execute() } 'plex level check runs OK';
my %expected_evaluation_results = map { $_ => 1 } (
'sequence_error.pass && (sequence_error.forward_common_cigars->[0]->[0] =~ /\\A\\d+M\\Z/xsm)',
'sequence_error.pass && (sequence_error.reverse_common_cigars->[0]->[0] =~ /\\A\\d+M\\Z/xsm)',
'bam_flagstats.percent_mapped_reads && (bam_flagstats.percent_mapped_reads > 80)',
'verify_bam_id.pass'
);
is_deeply ($check->result()->evaluation_results(), \%expected_evaluation_results,
my $result = $check->result();
is_deeply ($result->evaluation_results(), \%expected_evaluation_results,
'sample evaluation results as expected');
is ($result->pass, 1, 'the check passed');
my $qc_outcome = $result->qc_outcome();
ok (defined $qc_outcome->{'timestamp'}, 'timestamp is set');
delete $qc_outcome->{'timestamp'};
is_deeply ($qc_outcome,
{'mqc_outcome' => 'Accepted preliminary', 'username' => 'robo_qc'},
'sample QC outcome is saved correctly'
);

$check = npg_qc::autoqc::checks::review->new(
runfolder_path => $runfolder_path,
conf_path => $test_data_path,
rpt_list => "${id_run}:1",
use_db => 1,
_qc_schema => $schema
);
lives_ok { $check->execute() } 'lane level check runs OK';
$result = $check->result();
%expected_evaluation_results = (
'tag_metrics.matches_pf_percent && (tag_metrics.perfect_matches_percent +' .
' tag_metrics.one_mismatch_percent) > 93' => 1,
'tag_metrics.all_reads * 302 > 750000000000' => 1
);
is_deeply ($result->evaluation_results(), \%expected_evaluation_results,
'lane evaluation results as expected');
is ($result->pass, 1, 'the check passed');
$qc_outcome = $result->qc_outcome();
ok (defined $qc_outcome->{'timestamp'}, 'timestamp is set');
delete $qc_outcome->{'timestamp'};
is_deeply ($qc_outcome,
{'mqc_seq_outcome' => 'Accepted preliminary', 'username' => 'robo_qc'},
'lane QC outcome is saved correctly'
);

$check = npg_qc::autoqc::checks::review->new(
runfolder_path => $runfolder_path,
conf_path => $test_data_path,
rpt_list => "${id_run}:2",
use_db => 1,
_qc_schema => $schema
);
lives_ok { $check->execute() } 'lane level check runs OK';
for my $key (keys %expected_evaluation_results) {
$expected_evaluation_results{$key} = 0;
}
$result = $check->result();
is_deeply ($result->evaluation_results(), \%expected_evaluation_results,
'lane evaluation results as expected');
is ($result->pass, 0, 'the check failed');
$qc_outcome = $result->qc_outcome();
delete $qc_outcome->{'timestamp'};
is_deeply ($qc_outcome,
{'mqc_seq_outcome' => 'Rejected preliminary', 'username' => 'robo_qc'},
'lane QC outcome is saved correctly'
);
};

1;
Binary file modified t/data/runfolder_49285/240802_A00537_1044_BHJKCGDSXC.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions t/data/runfolder_49285/README
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
22 October 2024

The tar.xz file in this directory contains a collection of files for run 49285.
At the time of writing the collection includes:
The 240802_A00537_1044_BHJKCGDSXC.tar.gz file in this directory contains a
collection of files for run 49285. At the time of writing the collection includes:

- JSON files for Autoqc results contains some lane-level data for lanes 1,2,3
and 4 plex-level results for plexes 1,2,3,0,888 for lane 1
Expand Down
5 changes: 3 additions & 2 deletions t/data/runfolder_49285/product_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ default:
criteria:
- applicability_criteria:
lims:
is_lane: 0
library_type: 'LCMB'
species_from_reference_genome: "Homo_sapiens"
alignments_in_bam: 1
Expand All @@ -34,6 +35,6 @@ default:
flowcell_mode: "S4"
cycle_count: 318
acceptance_criteria:
- "tag_metrics.matches_pf_percent && ((tag_metrics.perfect_matches_percent + tag_metrics.one_mismatch_percent) > 93"
- "tag_metrics.all_reads * 202 > 750000000000"
- "tag_metrics.matches_pf_percent && (tag_metrics.perfect_matches_percent + tag_metrics.one_mismatch_percent) > 93"
- "tag_metrics.all_reads * 302 > 750000000000"

0 comments on commit 250d960

Please sign in to comment.