diff --git a/modules/Bio/EnsEMBL/AltAlleleGroup.pm b/modules/Bio/EnsEMBL/AltAlleleGroup.pm index 54b286662d61126cf205897b776b8bac63bfde37..cca48d6c7335ca5badea43cd059f844cf77a101e 100644 --- a/modules/Bio/EnsEMBL/AltAlleleGroup.pm +++ b/modules/Bio/EnsEMBL/AltAlleleGroup.pm @@ -224,7 +224,8 @@ sub rep_Gene_id { $self->{'MEMBERS'} = $list; return $new_id; } elsif ($new_id && !$change) { - throw("Requested representative gene ID was not set because it is not in this AltAlleleGroup, ID ".$self->dbID); + my $db_id = $self->dbID() || 'unknown'; + throw("Requested representative gene ID was not set because it is not in this AltAlleleGroup, ID $db_id"); } else { warning("No representative allele currently set for this AltAlleleGroup"); diff --git a/modules/t/MultiTestDB.conf.default b/modules/t/MultiTestDB.conf.default index c3bc1fde9c0b0d7c641d0e5fb4e0cbea72c5c479..cbf5fbda54854b12a19c6e838ea9f736b8ea4c2a 100644 --- a/modules/t/MultiTestDB.conf.default +++ b/modules/t/MultiTestDB.conf.default @@ -9,6 +9,7 @@ 'core' => 'Bio::EnsEMBL::DBSQL::DBAdaptor', 'patch' => 'Bio::EnsEMBL::DBSQL::DBAdaptor', 'empty' => 'Bio::EnsEMBL::DBSQL::DBAdaptor', + 'patch' => 'Bio::EnsEMBL::DBSQL::DBAdaptor', }, 'circ' => { 'core' => 'Bio::EnsEMBL::DBSQL::DBAdaptor', diff --git a/modules/t/altAlleleGroup.t b/modules/t/altAlleleGroup.t index 4f364e2bbb19c04242ff187cfc3580f6fb83050e..416bcbd938edf204a98fa03a9bbee473904e7eb2 100644 --- a/modules/t/altAlleleGroup.t +++ b/modules/t/altAlleleGroup.t @@ -36,10 +36,14 @@ is_deeply($id_list,[qw( 1 2 3 )], "Get all Gene IDs within a prefab group"); my $id = $group->rep_Gene_id(); is($id,'2',"Get reference Gene ID"); -is($other_group->rep_Gene_id(),undef,"Test behaviour without a reference Gene set"); +warns_like { + is($other_group->rep_Gene_id(),undef,"Test behaviour without a reference Gene set"); +} qr/No representative allele currently set/, 'Ensuring appropriate warning about lack of reference gene is emitted'; $group->unset_rep_Gene_id(); -is($group->rep_Gene_id(), undef,"Check successful unsetting."); +warns_like { + is($group->rep_Gene_id(), undef,"Check successful unsetting."); +} qr/No representative allele currently set/, 'Ensuring appropriate warning about lack of reference gene is emitted'; throws_ok{$group->rep_Gene_id(5)} qr/Requested representative gene ID/, "Exception thrown when invalid ID given"; ok($group->rep_Gene_id(3) == 3,"Successful setting of reference gene"); diff --git a/modules/t/dbEntries.t b/modules/t/dbEntries.t index f74400887edcec8ae3c0a2a14fcee13af125c9a5..77c2738922709f0c8f6780dce2291f0d4b0e3467 100644 --- a/modules/t/dbEntries.t +++ b/modules/t/dbEntries.t @@ -199,44 +199,44 @@ $xref = Bio::EnsEMBL::DBEntry->new ); my $threaded; - use Config; - if($Config{useithreads}) { - note 'Using threaded tests'; - require threads; - $threaded = 1; - { - local $ENV{RUNTESTS_HARNESS} = 1; - local $ENV{RUNTESTS_HARNESS_NORESTORE} = 1; - - # db connection must be severed for threads to access DB - $dbEntryAdaptor->dbc->disconnect_if_idle(); - $multi->get_DBAdaptor('empty'); # seem to have to do this to stop thread whinging under some perls - - my $parallel_store = sub{ - my $xref_id = $dbEntryAdaptor->store( $xref, $tr->dbID, "Transcript" ); - return $xref_id - }; - - my $thread1 = threads->create($parallel_store); - my $thread2 = threads->create($parallel_store); - my $thread3 = threads->create($parallel_store); - - - my @xref_ids; - @xref_ids = ($thread1->join,$thread2->join,$thread3->join); - - note("Threaded xrefs: ".$xref_ids[0]." ".$xref_ids[1]." ".$xref_ids[2]); - - # Test 10 - Verify that only one xref has been inserted under parallel inserts - is($xref_ids[0], 1000009, 'Thread 1 ID assertion'); - is($xref_ids[1], $xref_ids[0], 'Thread 2 ID is the same as thread 1'); - is($xref_ids[2], $xref_ids[0], 'Thread 3 ID is the same as thread 1'); - } - - } - else { - note 'Skipping threaded tests'; +use Config; +if($Config{useithreads}) { + note 'Using threaded tests'; + require threads; + $threaded = 1; + { + local $ENV{RUNTESTS_HARNESS} = 1; + local $ENV{RUNTESTS_HARNESS_NORESTORE} = 1; + + # db connection must be severed for threads to access DB + $dbEntryAdaptor->dbc->disconnect_if_idle(); + $multi->get_DBAdaptor('empty'); # seem to have to do this to stop thread whinging under some perls + + my $parallel_store = sub{ + my $xref_id = $dbEntryAdaptor->store( $xref, $tr->dbID, "Transcript" ); + return $xref_id + }; + + my $thread1 = threads->create($parallel_store); + my $thread2 = threads->create($parallel_store); + my $thread3 = threads->create($parallel_store); + + + my @xref_ids; + @xref_ids = ($thread1->join,$thread2->join,$thread3->join); + + note("Threaded xrefs: ".$xref_ids[0]." ".$xref_ids[1]." ".$xref_ids[2]); + + # Test 10 - Verify that only one xref has been inserted under parallel inserts + is($xref_ids[0], 1000003, 'Thread 1 ID assertion'); + is($xref_ids[1], $xref_ids[0], 'Thread 2 ID is the same as thread 1'); + is($xref_ids[2], $xref_ids[0], 'Thread 3 ID is the same as thread 1'); } + +} +else { + note 'Skipping threaded tests'; +} # Test 11 - Exception testing on ->store() @@ -260,9 +260,9 @@ $xref = Bio::EnsEMBL::DBEntry->new my $xref_id = $dbEntryAdaptor->store($xref, undef, "Transcript"); note("Xref_id from insert: ".$xref_id); if ($threaded) { - ok($xref_id == 1000010); + ok($xref_id == 1000004); } else { - is($xref_id,1000009, "dbID for new DBEntry."); + is($xref_id,1000003, "dbID for new DBEntry."); } # diff --git a/modules/t/gene.t b/modules/t/gene.t index 010dc2fd18877de386a51a9c3bc3ebd6b124322b..5ae01f58cd2c841a4e0e45a0c0177eff55b7f5cb 100644 --- a/modules/t/gene.t +++ b/modules/t/gene.t @@ -544,15 +544,16 @@ push(@alt_genes, $ga->fetch_by_dbID(18270)); push(@alt_genes, $ga->fetch_by_dbID(18271)); push(@alt_genes, $ga->fetch_by_dbID(18272)); -warns_like( - sub { -# my ($stdout_ref, $stderr_ref) = @_; - $ga->store_alt_alleles(\@alt_genes); -# my $check = qr/.+alternative.+reference\ssequence.+Ignoring/; -# like(${$stderr_ref}, $check, 'Checking we are still warning about multiple alt_alleles on refs'); - }, qr/.+alternative.+reference\ssequence.+Ignoring/, 'Checking we are still warning about multiple alt_alleles on refs'); +warns_like { + $ga->store_alt_alleles(\@alt_genes); +} qr/.+alternative.+reference\ssequence.+Ignoring/, 'Checking we are still warning about multiple alt_alleles on refs'; $gene = $ga->fetch_by_dbID(18270); -$alt_genes = $gene->get_all_alt_alleles(); + +note 'Do not use GeneAdaptor::store_alt_alleles() for storing alt alleles. Ensuring we still warn'; +warns_like { + $alt_genes = $gene->get_all_alt_alleles(); +} qr/Supplied gene has no alternative alleles/, 'Passing multiple genes to GeneAdaptor::store_alt_alleles() results in no REF being stored'; + %gene_ids = (18271 => 1, 18272 => 1); $ok = 1;