Commit 680bb69c authored by Andy Yates's avatar Andy Yates
Browse files

cleaned up the alt allele, db entries and gene test cases

parent 45793d3c
......@@ -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");
......
......@@ -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',
......
......@@ -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");
......
......@@ -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.");
}
#
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment