Skip to content
Snippets Groups Projects
Commit cfb7a637 authored by Alessandro Vullo's avatar Alessandro Vullo
Browse files

Updates to reflect changes in SequenceOntologyMapper interface.

Removed dependencies on non-core APIs.
parent 7bc92775
No related branches found
No related tags found
No related merge requests found
......@@ -25,10 +25,6 @@ use Bio::EnsEMBL::Slice;
use Bio::EnsEMBL::SimpleFeature;
use Bio::EnsEMBL::MiscFeature;
use Bio::EnsEMBL::RepeatFeature;
use Bio::EnsEMBL::Variation::VariationFeature;
use Bio::EnsEMBL::Variation::StructuralVariationFeature;
use Bio::EnsEMBL::Compara::ConstrainedElement;
use Bio::EnsEMBL::Funcgen::RegulatoryFeature;
# Module compiles
ok(1, 'Bio::EnsEMBL::Utils::SequenceOntologyMapper compiles');
......@@ -37,22 +33,9 @@ ok(1, 'Bio::EnsEMBL::Utils::SequenceOntologyMapper compiles');
# Test constructor
#
throws_ok { new Bio::EnsEMBL::Utils::SequenceOntologyMapper() }
qr /No ontology term adaptor/, "constructor with no argument raises exception";
qr /No ontology term adaptor/, "constructor with no arg raises exception";
throws_ok { new Bio::EnsEMBL::Utils::SequenceOntologyMapper(bless({}, 'Someclass')) }
qr /Argument is not/, "constructor with object not of class OntologyTermAdaptor raises exception";
# my $registry = 'Bio::EnsEMBL::Registry';
# Bio::EnsEMBL::Registry->no_version_check(1);
# Bio::EnsEMBL::Registry->no_cache_warnings(1);
# $registry->load_registry_from_db(-host => '127.0.0.1',
# -port => 33061,
# -db_version => 73,
# -user => 'ensro',
# -no_cache => 1);
# my $oa = $registry->get_adaptor( 'Multi', 'Ontology', 'OntologyTerm' );
# assert_ref($oa, 'Bio::EnsEMBL::DBSQL::OntologyTermAdaptor');
qr /Argument is not/, "constructor with arg not of class OntologyTermAdaptor raises exception";
my $omulti = Bio::EnsEMBL::Test::MultiTestDB->new('ontology');
my $odb = $omulti->get_DBAdaptor('ontology');
......@@ -62,33 +45,41 @@ my $mapper = Bio::EnsEMBL::Utils::SequenceOntologyMapper->new($oa);
isa_ok($mapper, 'Bio::EnsEMBL::Utils::SequenceOntologyMapper');
#
# Test translate method
# Test to_accession/to_name methods
#
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new;
my $db = $multi->get_DBAdaptor('core');
my $mappings =
[
{ obj => Bio::EnsEMBL::Feature->new, term => 'region' },
{ obj => Bio::EnsEMBL::Gene->new, term => 'gene' },
{ obj => Bio::EnsEMBL::Transcript->new, term => 'transcript' },
{ obj => Bio::EnsEMBL::Exon->new, term => 'exon' },
{ obj => $db->get_SliceAdaptor->fetch_by_region('chromosome', '20', 30_270_000, 31_200_000), term => 'region' },
{ obj => Bio::EnsEMBL::SimpleFeature->new(), term => 'biological_region' },
{ obj => Bio::EnsEMBL::MiscFeature->new(), term => 'biological_region' },
{ obj => Bio::EnsEMBL::RepeatFeature->new(), term => 'repeat_region' },
{ obj => Bio::EnsEMBL::Variation::VariationFeature->new(), term => 'sequence_variant' },
{ obj => Bio::EnsEMBL::Variation::StructuralVariationFeature->new(), term => 'structural_variant' },
{ obj => Bio::EnsEMBL::Compara::ConstrainedElement->new(), term => 'DNA_constraint_sequence' }
# 'Bio::EnsEMBL::Funcgen::RegulatoryFeature' => 'regulatory_region'
# test generic feature
{ obj => Bio::EnsEMBL::Feature->new(), accession => 'SO:0000001', name => 'region' },
# test various genes with/without biotypes
{ obj => Bio::EnsEMBL::Gene->new(), accession => 'SO:0000704', name => 'gene' },
{ obj => Bio::EnsEMBL::Gene->new(-biotype => 'protein_coding'), accession => 'SO:0001217', name => 'protein_coding_gene' },
{ obj => Bio::EnsEMBL::Gene->new(-biotype => 'tRNA'), accession => 'SO:0001272', name => 'tRNA_gene' },
# test various transcripts with/without biotypes
{ obj => Bio::EnsEMBL::Transcript->new(), accession => 'SO:0000673', name => 'transcript' },
{ obj => Bio::EnsEMBL::Transcript->new(-biotype => 'processed_transcript'), accession => 'SO:0001503', name => 'processed_transcript' },
{ obj => Bio::EnsEMBL::Transcript->new(-biotype => 'retrotransposed'), accession => 'SO:0000569', name => 'retrotransposed' },
# exons
{ obj => Bio::EnsEMBL::Exon->new, accession => 'SO:0000147', name => 'exon' },
# slices
{ obj => $db->get_SliceAdaptor->fetch_by_region('chromosome', '20', 30_270_000, 31_200_000), accession => 'SO:0000001', name => 'region' },
# simple features
{ obj => Bio::EnsEMBL::SimpleFeature->new(), accession => 'SO:0001411', name => 'biological_region' },
# misc features
{ obj => Bio::EnsEMBL::MiscFeature->new(), accession => 'SO:0001411', name => 'biological_region' },
# repeat feature
{ obj => Bio::EnsEMBL::RepeatFeature->new(), accession => 'SO:0000657', name => 'repeat_region' },
];
throws_ok { $mapper->translate( bless({}, 'Someclass')) }
qr /not found/, "translate method raises exception";
map {
print ref($_->{obj}) and is($mapper->translate($_->{obj}), $_->{term}, sprintf "%s translates as assumed", ref($_->{obj})) }
is($mapper->to_accession($_->{obj}), $_->{accession}, sprintf "%s maps to correct accession", ref($_->{obj})) and
is($mapper->to_name($_->{obj}), $_->{name}, sprintf "%s maps to correct", ref($_->{obj})) }
@{$mappings};
done_testing();
......
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