Commit 5415237e authored by Tiago Grego's avatar Tiago Grego
Browse files

updated tests to include so_terms

parent 04887198
{
'port' => '3306',
'driver' => 'mysql',
'user' => 'test_user',
'db_version' => 93,
'pass' => 'passwd',
'host' => 'localhost'
}
{
'driver' => 'SQLite',
'dbdir' => '/home/tgrego/temp/',
'user' => 'test_user',
}
......@@ -52,19 +52,21 @@ is($biotype1->object_type, 'gene', 'Biotype is from Gene object');
is($biotype1->name, 'protein_coding', 'Biotype name is protein_coding');
is($biotype1->biotype_group, 'coding', 'Biotype group is coding');
is($biotype1->so_acc, 'SO:0001217', 'Biotype protein_coding refers to SO:0001217');
is($biotype1->so_term, 'protein_coding_gene', 'Biotype protein_coding refers to SO term protein_coding_gene');
throws_ok { $biotype1->so_acc('test') } qr/so_acc must be a Sequence Ontology accession/, 'so_acc() requires a SO acc like string';
throws_ok { $biotype1->object_type('test') } qr/object_type must be gene or transcript/, 'object_type() must be gene or transcript';
# test transcript biotype object
my $transcript = $gene->canonical_transcript;
debug("transcript biotype");
is($transcript->biotype, 'protein_coding', "Trancript biotype is protein_coding");
is($transcript->biotype, 'protein_coding', "Transcript biotype is protein_coding");
my $biotype2 = $transcript->get_Biotype;
ok($biotype2->isa("Bio::EnsEMBL::Biotype"), "Biotype object retrieved successfully");
is($biotype2->object_type, 'transcript', 'Biotype is from Transcript object');
is($biotype2->name, 'protein_coding', 'Biotype name is protein_coding');
is($biotype2->biotype_group, 'coding', 'Biotype group is coding');
is($biotype2->so_acc, 'SO:0000234', 'Biotype protein_coding refers to SO:0000234');
is($biotype2->so_term, 'mRNA', 'Biotype protein_coding refers to SO term mRNA');
ok($transcript->set_Biotype('new_biotype'), "Can successfully set new_biotype");
throws_ok { $gene->set_Biotype() } qr/No argument provided/, 'set_Biotype() requires an argument';
......@@ -77,6 +79,7 @@ is($biotype3->object_type, 'gene', 'Biotype is from Gene object');
is($biotype3->name, 'tRNA', 'Biotype name is tRNA');
is($biotype3->biotype_group, 'snoncoding', 'Biotype group is snoncoding');
is($biotype3->so_acc, 'SO:0001263', 'Biotype tRNA refers to SO:0001263');
is($biotype3->so_term, 'ncRNA_gene', 'Biotype protein_coding refers to SO term ncRNA_gene');
# set biotype with term not in database
debug("set biotype with term not in db");
......@@ -87,6 +90,7 @@ is($biotype4->object_type, 'gene', 'Biotype is from Gene object');
is($biotype4->name, 'dummy', 'Biotype name is dummy');
is($biotype4->biotype_group, undef, 'Biotype group is not set');
is($biotype4->so_acc, undef, 'Biotype SO acc is not set');
is($biotype4->so_term, undef, 'Biotype SO term is not set');
throws_ok { $gene->set_Biotype() } qr/No argument provided/, 'set_Biotype() requires an argument';
# test fetch biotypes of object_type gene
......@@ -95,7 +99,7 @@ my $biotypes1 = $biotype_adaptor->fetch_all_by_object_type('gene');
is(ref $biotypes1, 'ARRAY', 'Got an array');
is(scalar @{$biotypes1}, '2', 'of size 2');
is_deeply($biotypes1, [$biotype1, $biotype3], 'with the correct objects');
my $warning1 = warning {
my $warning1 = warning {
$biotypes1 = $biotype_adaptor->fetch_all_by_object_type('none') };
like( $warning1,
qr/No objects retrieved. Check if object_type 'none' is correct./,
......
......@@ -35,11 +35,10 @@ ok($db);
my $stable_id = 'ENST00000217347';
my $transcript_adaptor = $db->get_TranscriptAdaptor();
my $transcript =
$transcript_adaptor->fetch_by_stable_id($stable_id);
my $transcript = $transcript_adaptor->fetch_by_stable_id($stable_id);
my @cds = @{ $transcript->get_all_CDS() };
my @cds = @{ $transcript->get_all_CDS() };
my @exons = @{ $transcript->get_all_translateable_Exons() };
my $n = scalar(@cds);
......@@ -50,6 +49,7 @@ for (my $i = 0; $i < $n; $i++) {
is($cds[0]->start, $transcript->coding_region_start, "First cds is coding start");
is($cds[$n-1]->end, $transcript->coding_region_end, "Last cds is coding end");
is($cds[0]->feature_so_acc, 'SO:0000316', 'CDS feature SO acc is correct (CDS)');;
is($cds[0]->feature_so_acc, 'SO:0000316', 'CDS feature SO acc is correct (CDS)');
is($cds[0]->feature_so_term, 'CDS', 'CDS feature SO term is correct (CDS)');;
done_testing();
......@@ -159,5 +159,6 @@ ok($f);
is($dnaf->feature_so_acc, 'SO:0000347', 'DnaDnaAlignFeature feature SO acc is correct (nucleotide_match)');
is($dnaf->feature_so_term, 'nucleotide_match', 'DnaDnaAlignFeature feature SO term is correct (nucleotide_match)');
done_testing();
......@@ -116,6 +116,7 @@ ok($dnaf->end == 16);
ok( scalar($dnaf->ungapped_features) == 2);
is($dnaf->feature_so_acc, 'SO:0000349', 'dnaPepAlignFeature feature SO acc is correct (protein_match)');
is($dnaf->feature_so_term, 'protein_match', 'dnaPepAlignFeature feature SO term is correct (protein_match)');
#
# 12 Test retrieval from database
......
......@@ -114,6 +114,7 @@ allow_warnings(0) if $db->dbc->driver() eq 'SQLite';
ok($exon->dbID() && $exon->adaptor == $exonad);
is($exon->feature_so_acc, 'SO:0000147', 'Exon feature SO acc is correct (exon)');
is($exon->feature_so_term, 'exon', 'Exon feature SO term is correct (exon)');
# now test fetch_by_dbID
......
......@@ -68,6 +68,8 @@ ok($feature->strand == $strand);
ok($feature->analysis == $analysis);
ok($feature->slice == $slice);
is($feature->feature_so_acc, 'SO:0000001', 'Feature feature SO acc is correct (feature)');
is($feature->feature_so_term, 'region', 'Feature feature SO term is correct (feature)');
#
# Test setters
......
......@@ -99,6 +99,7 @@ debug("Gene display xref id: " . $gene->display_xref->dbID);
ok($gene->display_xref->dbID() == 128324);
is($gene->feature_so_acc, 'SO:0000704', 'Gene feature SO acc is correct (gene)');
is($gene->feature_so_term, 'gene', 'Gene feature SO term is correct (gene)');
# test the getters and setters
ok(test_getter_setter($gene, "external_name", "banana"));
......
......@@ -58,6 +58,7 @@ ok($kb->name() eq $name);
ok($kb->slice == $slice);
ok($kb->display_id eq $name);
is($kb->feature_so_acc, 'SO:0000341', 'KaryotypeBand feature SO acc is correct (chromosome_band)');
is($kb->feature_so_term, 'chromosome_band', 'KaryotypeBand feature SO term is correct (chromosome_band)');
#
# test getter/setters
......
......@@ -32,6 +32,7 @@ my $mf = Bio::EnsEMBL::MiscFeature->new(-START => 10,
ok($mf->start() == 10 && $mf->end() == 100);
is($mf->feature_so_acc, 'SO:0001411', 'MiscFeature feature SO acc is correct (biological_region)');
is($mf->feature_so_term, 'biological_region', 'MiscFeature feature SO term is correct (biological_region)');
#
......
......@@ -132,6 +132,7 @@ $exon->strand( 1 );
$pt->add_Exon($exon);
is($exon->feature_so_acc, 'SO:0000147', 'PredictionExon feature SO acc is correct (exon)');
is($exon->feature_so_term, 'exon', 'PredictionExon feature SO term is correct (exon)');
#check that transcript start + end updated
ok( $pt->end() == 50 );
......
......@@ -87,6 +87,7 @@ ok($rf->score == $score);
ok($rf->repeat_consensus == $repeat_consensus);
is($rf->feature_so_acc, 'SO:0000657', 'RepeatFeature feature SO acc is correct (repeat_region)');
is($rf->feature_so_term, 'repeat_region', 'RepeatFeature feature SO term is correct (repeat_region)');
#
# Test Getter/Setters
......
......@@ -151,6 +151,7 @@ my $ids = $sfa->list_dbIDs();
ok (@{$ids});
is($feat->feature_so_acc, 'SO:0001411', 'SimpleFeature feature SO acc is correct (biological_region)');
is($feat->feature_so_term, 'biological_region', 'SimpleFeature feature SO term is correct (biological_region)');
ok($feat->display_id eq $feat->display_label);
......
......@@ -163,6 +163,7 @@ is( $tr->coding_region_start(), 85834, 'Correct coding region start' );
is( $tr->coding_region_end(), 108631, 'Correct coding region end' );
is( $tr->feature_so_acc, 'SO:0000673', 'Transcript feature SO acc is correct (transcript)' );
is( $tr->feature_so_term, 'transcript', 'Transcript feature SO term is correct (transcript)' );
my @pepcoords = $tr->pep2genomic( 10, 20 );
is( $pepcoords[0]->start(), 85861, 'Correct translation start' );
......
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