~ubuntu-branches/ubuntu/vivid/bioperl/vivid

« back to all changes in this revision

Viewing changes to t/LocalDB/Taxonomy/greengenes.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 => 38 );
 
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::greengenes
 
16
 
 
17
ok $db = Bio::DB::Taxonomy->new( -source => 'greengenes' );
 
18
 
 
19
isa_ok $db, 'Bio::DB::Taxonomy::greengenes';
 
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   => 'greengenes',
 
25
   -taxofile => test_input_file('taxonomy', 'greengenes_taxonomy_16S_candiv_gg_2011_1.txt'),
 
26
);
 
27
 
 
28
@ids = $db->get_taxonid('Homo sapiens');
 
29
is scalar @ids, 0;
 
30
 
 
31
@ids = $db->get_taxonid('s__Bacteroides uniformis');
 
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, 'species';
 
40
is $node->parent_id, 'gg6';
 
41
is $node->node_name, 's__Bacteroides uniformis';
 
42
is $node->scientific_name, $node->node_name;
 
43
 
 
44
is ${$node->name('scientific')}[0], $node->node_name;
 
45
 
 
46
%common_names = map { $_ => 1 } $node->common_names;
 
47
is scalar keys %common_names, 0;
 
48
 
 
49
is $node->division, undef;
 
50
is $node->genetic_code, undef;
 
51
is $node->mitochondrial_genetic_code, undef;
 
52
 
 
53
# briefly test some Bio::Tree::NodeI methods
 
54
ok $ancestor = $node->ancestor;
 
55
is $ancestor->scientific_name, 'g__Bacteroides';
 
56
 
 
57
# unless set explicitly, Bio::Taxon doesn't return anything for
 
58
# each_Descendent; must ask the database directly
 
59
ok @children = $ancestor->db_handle->each_Descendent($ancestor);
 
60
is scalar @children, 2;
 
61
 
 
62
# do some trickier things...
 
63
ok $node2 = $db->get_taxon('gg104');
 
64
is $node2->scientific_name, 'o__Synergistales';
 
65
 
 
66
# briefly check that we can use some Tree methods
 
67
$tree = Bio::Tree::Tree->new();
 
68
is $tree->get_lca($node, $node2)->scientific_name, 'k__Bacteria';
 
69
 
 
70
# can we actually form a Tree and use other Tree methods?
 
71
ok $tree = Bio::Tree::Tree->new(-node => $node);
 
72
is $tree->number_nodes, 7;
 
73
is $tree->get_nodes, 7;
 
74
is $tree->find_node(-rank => 'genus')->scientific_name, 'g__Bacteroides';
 
75
is $tree->find_node(-rank => 'class')->scientific_name, 'c__Bacteroidia';
 
76
 
 
77
# check that getting the ancestor still works now we have explitly set the
 
78
# ancestor by making a Tree
 
79
is $node->ancestor->scientific_name, 'g__Bacteroides';
 
80
 
 
81
# we can recursively fetch all descendents of a taxon
 
82
my $lca = $db->get_taxon( -name => 'f__Enterobacteriaceae' );
 
83
ok @descs = $db->each_Descendent($lca);
 
84
is scalar @descs, 2;
 
85
@descs = $db->get_all_Descendents($lca);
 
86
is scalar @descs, 3;
 
87
 
 
88