Skip to content

Commit

Permalink
Merge pull request #591 from wtsi-npg/devel
Browse files Browse the repository at this point in the history
mege devel into master to create release 66.1
  • Loading branch information
mgcam authored Jan 30, 2019
2 parents 57cfe27 + 62da5a8 commit 507b7e5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
LIST OF CHANGES FOR NPG-QC PACKAGE

release 66.1
- autoqc results loader to check for potential composition digest clashes
- amend upstream_tags check to find previous runs which have reached
status "analysis complete" (instead of "run complete")

release 66.0
- GUI for utility QC (inactive)
- add new bcfstats qc check + viewer change
Expand Down
15 changes: 13 additions & 2 deletions lib/npg_qc/Schema/ResultSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ sub find_seq_composition {
}

sub find_or_create_seq_composition {
my ($self, $composition) = @_;
my ($self, $composition, $check_digest) = @_;

$self->_validate($composition);
my $digest = $composition->digest;
Expand All @@ -133,7 +133,14 @@ sub find_or_create_seq_composition {
my $composition_row = $self->_find_composition($digest, $num_components);
# If composition exists, we assume that it's properly defined, i.e.
# all relevant components and records in the linking table exist.
if (!$composition_row) {
if ($composition_row) {
# If asked, ensure that the found row represents the same composition.
if ($check_digest &&
($composition->freeze ne $composition_row->create_composition()->freeze)) {
croak "A different composition object with the same digest '$digest' " .
'already exists in the database';
}
} else {
$composition_row = $schema->resultset('SeqComposition')
->create({
'digest' => $digest,
Expand Down Expand Up @@ -306,6 +313,10 @@ for every component-composition pair.
Gives an error if this resultset does not have a relationship to
the seq_composition table.
If a true value is given as a second attrubute and a composition object is
found, a check for a clash of sha256 digest of composition objects is performed.
Error is raised if the clashing digests are detected.
=head2 composition_fk_column_name
Returns the name of the column with a foreign key linking this table to the
Expand Down
2 changes: 1 addition & 1 deletion lib/npg_qc/autoqc/checks/upstream_tags.pm
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ sub _fetch_run_rows {
where
r.id_instrument = i.id_instrument
and r.id_run = rs.id_run
and rs.id_run_status_dict = 4
and rs.id_run_status_dict = 9
and i.id_instrument = (select id_instrument from run where id_run = ?)
and rs.date <= (select max(date) from run_status where id_run = ? and id_run_status_dict in (2,3,4))
and if(tr.id_tag=22, 'A', IF(tr.id_tag=23, 'B', 'X')) = (select if(id_tag=22, 'A', IF(id_tag=23, 'B', 'X')) from (run rx left outer join tag_run trx on rx.id_run = trx.id_run and trx.id_tag in (22,23)) where rx.id_run = ? and (trx.id_tag in (22,23) or trx.id_tag is null))
Expand Down
3 changes: 2 additions & 1 deletion lib/npg_qc/autoqc/db_loader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ sub _json2db{
if ($dbix_class_name && $self->_schema_has_source($dbix_class_name) &&
$self->_pass_filter($obj)) {
my $rs = $self->schema->resultset($dbix_class_name);
my $related_composition = $rs->find_or_create_seq_composition($obj->composition());
my $check_digest = 1;
my $related_composition = $rs->find_or_create_seq_composition($obj->composition(), $check_digest);
if (!$related_composition) {
croak 'Composition is not found/created';
}
Expand Down
19 changes: 16 additions & 3 deletions t/50-schema-resultset.t
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ subtest q[not saving composition subset value "all"] => sub {
my $id_run;

subtest q[finding existing composition] => sub {
plan tests => 15;
plan tests => 17;

my $rs_component = $schema->resultset('SeqComponent');
my $rs_composition = $schema->resultset('SeqComposition');
Expand Down Expand Up @@ -592,12 +592,25 @@ subtest q[finding existing composition] => sub {
$f->add_component(npg_tracking::glossary::composition::component::illumina
->new(%{$value}, tag_index => undef, subset => undef));
}
$row = $ssrs->find_or_create_seq_composition($f->create_composition());
my $c = $f->create_composition();
$row = $ssrs->find_or_create_seq_composition($c);
is($row->id_seq_composition, $pk_value, 'existing row returned');

my $row_to_change = $rs_component->search(
{id_run => $id_run,position => 1,tag_index => undef, subset => undef})->next();
$row_to_change or die 'Failed to find existing row';
$row_to_change->update({subset => 'human'});
my $d = $c->digest;
throws_ok {$ssrs->find_or_create_seq_composition($c, 1)}
qr/A different composition object with the same digest '$d' already exists in the database/,
'error detecting composition digest clash';
$row_to_change->update({subset => undef});
lives_ok {$ssrs->find_or_create_seq_composition($c, 1)}
'no error after removing the clash';
}

$count++;
}
}
};

subtest q[creating new composition from new and existing components] => sub {
Expand Down

0 comments on commit 507b7e5

Please sign in to comment.