Add tests for memory leaks and weaken for Issue #81
[bioperl-live.git] / t / SeqIO / locuslink.t
blob97f7438f884d798e02bc193164064662058a4060
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN {
7         use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 26,
11                -requires_module => 'Graph::Directed');
12         
13         use_ok('Bio::SeqIO::locuslink');
14         use_ok('Bio::SeqFeature::Generic');
15         use_ok('Bio::SeqFeature::AnnotationAdaptor');
18 my $seqin = Bio::SeqIO->new(-file => test_input_file('test.locuslink'),
19                             -format => 'locuslink');
20 ok $seqin;
21 isa_ok($seqin, 'Bio::SeqIO');
22 my $seqout = Bio::SeqIO->new(-file => ">".test_output_file(),
23                              -format => 'embl');
25 # process and write to output
26 my @seqs = ();
28 while(my $seq = $seqin->next_seq()) {
29     push(@seqs, $seq);
30     
31     # create an artificial feature to stick the annotation on
32     my $fea = Bio::SeqFeature::Generic->new(-start => 1, -end => 9999,
33                                             -strand => 1,
34                                             -primary => 'annotation');
35     my $ac = Bio::SeqFeature::AnnotationAdaptor->new(-feature => $fea);
36     foreach my $k ($seq->annotation->get_all_annotation_keys()) {
37         foreach my $ann ($seq->annotation->get_Annotations($k)) {
38             next unless $ann->isa("Bio::Annotation::SimpleValue");
39             $ac->add_Annotation($ann);
40         }
41     }
42     $seq->add_SeqFeature($fea);
43     $seqout->write_seq($seq);
46 is (scalar(@seqs), 2);
48 is ($seqs[0]->desc,
49     "amiloride binding protein 1 (amine oxidase (copper-containing))");
50 is ($seqs[0]->accession, "26");
51 is ($seqs[0]->display_id, "ABP1");
52 is ($seqs[0]->species->binomial, "Homo sapiens");
55 my @dblinks = $seqs[0]->annotation->get_Annotations('dblink');
56 my %counts = map { ($_->database(),0) } @dblinks;
57 foreach (@dblinks) { $counts{$_->database()}++; }
59 is ($counts{GenBank}, 11);
60 is ($counts{RefSeq}, 4);
61 is ($counts{UniGene}, 1);
62 is ($counts{Pfam}, 1);
63 is ($counts{STS}, 2);
64 is ($counts{MIM}, 1);
65 is ($counts{PUBMED}, 6);
66 is (scalar(@dblinks), 27);
68 is ($seqs[1]->desc, "v-abl Abelson murine leukemia viral oncogene homolog 2 (arg, Abelson-related gene)");
69 is ($seqs[1]->display_id, "ABL2");
71 my $ac = $seqs[1]->annotation;
72 my @keys = $ac->get_all_annotation_keys();
73 is (scalar(@keys), 19);
75 my ($cmt) = $ac->get_Annotations('comment');
76 is (length($cmt->text), 403);
78 my @isoforms = qw(a b);
79 foreach ($ac->get_Annotations('PRODUCT')) {
80     is ($_->value,
81         "v-abl Abelson murine leukemia viral oncogene homolog 2 isoform ".
82         shift(@isoforms));
85 my @goann = ();
86 foreach my $k (@keys) {
87     foreach my $ann ($ac->get_Annotations($k)) {
88         next unless $ann->isa("Bio::Ontology::TermI");
89         push(@goann, $ann);
90     }
92 is (scalar(@goann), 4);
93 @goann = sort { $a->as_text() cmp $b->as_text() } @goann;
94 is ($goann[2]->as_text, "cellular component|cytoplasm|");