Skip to content
Snippets Groups Projects
Commit 2579f26b authored by Kieron Taylor's avatar Kieron Taylor :angry:
Browse files

Taxonomy name endpoint created, basic tests for all taxonomy endpoints.

parent 10a3a9d6
No related branches found
No related tags found
No related merge requests found
......@@ -36,15 +36,18 @@ sub classification : Chained('taxonomy_root') PathPart('classification') Args(1)
$self->status_ok($c, entity => $entity);
}
sub name_get {}
sub name_GET {}
sub name : Chained('taxonomy_root') PathPart('name') Args(1) ActionClass('REST') {
my ($self, $c, $id) = @_;
$id = uri_unescape($id);
$c->log->debug($id);
my $simple = $c->request->param('simple');
my $taxons = $self->_name($c,$id);
# remove any duplicates in the list
my %list = map { $_ => 1 } @$taxons;
@$taxons = keys %list;
$self->status_ok($c, entity => $self->_encode_array($taxons));
my %list = map { $_->taxon_id => $_ } @$taxons;
@$taxons = map { $list{$_} } keys %list;
$self->status_ok($c, entity => $self->_encode_array($taxons,$simple));
}
sub taxon {
......
......@@ -13,16 +13,70 @@ use Test::More;
use Catalyst::Test ();
use Bio::EnsEMBL::Test::MultiTestDB;
my $dba = Bio::EnsEMBL::Test::MultiTestDB->new();
my $dba = Bio::EnsEMBL::Test::MultiTestDB->new('multi');
Catalyst::Test->import('EnsEMBL::REST');
my $expected = qq();
#is_json_GET("/lookup/id/$basic_id?expand=1;format=condensed", $expanded_response, 'Get of a known ID with expanded option will return transcripts as well');
#is_json_GET("/taxonomy/classification/homo sapiens", $expected, 'Check taxonomy endpoint with valid data');
$expected = {scientific_name => "Homo sapiens",
name => "Homo sapiens",
id => "9606",
tags => {"ensembl alias name" => ["Human"],"scientific name" => ["Homo sapiens"],"genbank common name" => ["human"],"common name" => ["man"],"name" => ["Homo sapiens"],"authority" => ["Homo sapiens Linnaeus, 1758"]},
leaf => 1
};
# Leaf => 1 is only true in test data.
$expected = qq({"scientific_name":"Homo sapiens","name":"Homo sapiens","id":"9606","tags":{"ensembl alias name":["Human"],"scientific name":["Homo sapiens"],"genbank common name":["human"],"common name":["man"],"name":["Homo sapiens"],"authority":["Homo sapiens Linnaeus, 1758"]},"leaf":0});
is_json_GET("/taxonomy/id/9606?content-type=application/json;simple=1", $expected, 'Check id endpoint with valid data');
action_bad("/taxonomyid/11111111111111", 'ID should not be found. Fail');
action_bad("/taxonomyid/-1", 'ID should not be found.');
is_json_GET("/taxonomy/name/human?simple=1", [$expected], 'Test human lookup with name');
my $result = json_GET("/taxonomy/name/canis%?simple=1",'Select wolf');
is($result->[0]->{'id'},'9612','Wolf found by wildcarded Canis');
is($result->[1]->{'id'},'9615','Beagle found by wildcarded Canis');
is($result->[2]->{'id'},'9611','Canis node found by wildcarded Canis');
$expected = [{
children => [
{
id => '33154',
leaf => 0,
name => 'Opisthokonta',
scientific_name => 'Opisthokonta',
tags => {
authority => ['Opisthokonta Cavalier-Smith 1987'],
'ensembl alias name' => ['Animals and Fungi'],
'ensembl timetree mya' => ['1500'],
name => ['Opisthokonta'],
'scientific name' => ['Opisthokonta'],
synonym => ['Fungi/Metazoa group','opisthokonts']
}
}
],
id => '2759',
leaf => 0,
name => 'Eukaryota',
parent => {
id => '131567' ,
leaf => 0 ,
name => 'cellular organisms' ,
scientific_name => 'cellular organisms' ,
tags => {
name => ['cellular organisms'],
'scientific name' => ['cellular organisms'],
synonym => ['biota'],
}
},
scientific_name => 'Eukaryota',
tags => {
'blast name' => ['eukaryotes'],
'common name' => ['eukaryotes'],
'genbank common name' => ['eucaryotes'],
name => ['Eukaryota'],
'scientific name' => ['Eukaryota'],
synonym => ['Eucarya','Eucaryotae','Eukarya','Eukaryotae']
},
}];
is_json_GET("/taxonomy/classification/2759?content-type=application/json", $expected, 'Test classification response for Eukaryotes');
action_bad("/taxonomy/classification?A;content-type=application/json", 'Classification in bad data case');
done_testing();
\ No newline at end of file
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