~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to t/LocalDB/Taxonomy/silva.t

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use strict;
 
2
 
 
3
BEGIN { 
 
4
    use lib '.';
 
5
    use Bio::Root::Test;
 
6
    test_begin( -tests => 42 );
 
7
    use_ok('Bio::DB::Taxonomy');
 
8
    use_ok('Bio::Tree::Tree');
 
9
}
 
10
 
 
11
 
 
12
my ($db, $id, @ids, $node, $node2, $ancestor, @children, %common_names, $tree, @descs);
 
13
 
 
14
 
 
15
# Test Bio::DB::Taxonomy::silva
 
16
 
 
17
ok $db = Bio::DB::Taxonomy->new( -source => 'silva' );
 
18
 
 
19
isa_ok $db, 'Bio::DB::Taxonomy::silva';
 
20
isa_ok $db, 'Bio::DB::Taxonomy::list';
 
21
isa_ok $db, 'Bio::DB::Taxonomy';
 
22
 
 
23
ok $db = Bio::DB::Taxonomy->new(
 
24
   -source   => 'silva',
 
25
   -taxofile => test_input_file('taxonomy', 'silva_SSURef_108_tax_silva_trunc.fasta'),
 
26
);
 
27
 
 
28
@ids = $db->get_taxonid('Homo sapiens');
 
29
is scalar @ids, 0;
 
30
 
 
31
@ids = $db->get_taxonid('Rattus norvegicus');
 
32
is scalar @ids, 1;
 
33
$id = $ids[0];
 
34
 
 
35
ok $node = $db->get_taxon($id);
 
36
is $node->id, $id;
 
37
is $node->object_id, $node->id;
 
38
is $node->ncbi_taxid, undef;
 
39
is $node->rank, undef;
 
40
is $node->parent_id, 'sv72';
 
41
is $node->node_name, 'Rattus norvegicus';
 
42
is $node->scientific_name, $node->node_name;
 
43
 
 
44
is ${$node->name('scientific')}[0], $node->node_name;
 
45
 
 
46
# it has a common name in Silva, but Bio::DB::Taxonomy::silva does not record it
 
47
%common_names = map { $_ => 1 } $node->common_names;
 
48
is scalar keys %common_names, 0;
 
49
 
 
50
is $node->division, undef;
 
51
is $node->genetic_code, undef;
 
52
is $node->mitochondrial_genetic_code, undef;
 
53
 
 
54
# briefly test some Bio::Tree::NodeI methods
 
55
ok $ancestor = $node->ancestor;
 
56
is $ancestor->scientific_name, '';
 
57
ok $ancestor = $ancestor->ancestor;
 
58
is $ancestor->scientific_name, 'Rattus';
 
59
ok $ancestor = $ancestor->ancestor;
 
60
is $ancestor->scientific_name, 'Murinae';
 
61
 
 
62
# unless set explicitly, Bio::Taxon doesn't return anything for
 
63
# each_Descendent; must ask the database directly
 
64
@ids = $db->get_taxonid('Metazoa');
 
65
is scalar @ids, 1;
 
66
$id = $ids[0];
 
67
ok $node = $db->get_taxon($id);
 
68
ok @children = $node->db_handle->each_Descendent($node);
 
69
is scalar @children, 3; # Chordata, Platyhelminthes, Metazoa
 
70
 
 
71
# do some trickier things...
 
72
ok $node2 = $db->get_taxon('sv112');
 
73
is $node2->scientific_name, 'Mucoromycotina';
 
74
 
 
75
# briefly check that we can use some Tree methods
 
76
$tree = Bio::Tree::Tree->new();
 
77
is $tree->get_lca($node, $node2)->scientific_name, 'Eukaryota';
 
78
 
 
79
# can we actually form a Tree and use other Tree methods?
 
80
ok $tree = Bio::Tree::Tree->new(-node => $node2);
 
81
is $tree->number_nodes, 5;
 
82
is $tree->get_nodes, 5;
 
83
 
 
84
# check that getting the ancestor still works now we have explitly set the
 
85
# ancestor by making a Tree
 
86
is $node2->ancestor->scientific_name, 'Basal fungal lineages';
 
87
 
 
88
# we can recursively fetch all descendents of a taxon
 
89
my $lca = $db->get_taxon( -name => 'Liliopsida' );
 
90
ok @descs = $db->each_Descendent($lca);
 
91
is scalar @descs, 1;
 
92
@descs = $db->get_all_Descendents($lca);
 
93
is scalar @descs, 9;
 
94