tag fourth (and hopefully last) alpha
[bioperl-live.git] / branch-1-6 / t / AlignIO / stockholm.t
blob51f00407625fb3d2b07395d772abc843dfdda91a
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: stockholm.t 14971 2008-10-28 16:08:52Z cjfields $
4 use strict;
6 BEGIN {
7         use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 83);
11         
12         use_ok('Bio::AlignIO::stockholm');
15 my $DEBUG = test_debug();
17 my ($str,$aln,$strout,$status);
19 # STOCKHOLM (multiple concatenated files)
20 # Rfam
21 $str  = Bio::AlignIO->new(
22     '-file'     => test_input_file("rfam_tests.stk"),
23     '-format'   => 'stockholm');
24 $strout = Bio::AlignIO->new('-file'  => ">".test_output_file(),
25                 '-format' => 'stockholm', );
27 isa_ok($str,'Bio::AlignIO');
28 $aln = $str->next_aln();
29 isa_ok($aln,'Bio::Align::AlignI');
30 is($aln->source, 'stockholm');
31 is($aln->get_seq_by_pos(1)->get_nse, 'Z11765.1/1-89');
32 is($aln->accession, 'RF00006');
33 is($aln->id, 'Vault');
34 is($aln->description,'Vault RNA');
35 # annotation
36 my ($ann) = $aln->annotation->get_Annotations('alignment_comment');
37 isa_ok($ann, 'Bio::Annotation::Comment');
38 is($ann->text,'This family of RNAs are found as part of the enigmatic vault'.
39    ' ribonucleoprotein complex. The complex consists of a major vault protein'.
40    ' (MVP), two minor vault proteins (VPARP and TEP1), and several small '.
41    'untranslated RNA molecules. It has been suggested that the vault complex '.
42    'is involved in drug resistance. We have identified a putative novel vault '.
43    'RNA on chromosome 5 EMBL:AC005219.','Stockholm annotation');
44 is($ann->tagname,'alignment_comment','Stockholm annotation');
46 # test output
47 $status = $strout->write_aln($aln);
48 is $status, 1, "stockholm output test";
50 $aln = $str->next_aln();
51 isa_ok($aln,'Bio::Align::AlignI');
52 is($aln->source, 'stockholm');
53 is($aln->get_seq_by_pos(1)->get_nse, 'L43844.1/2-149');
54 is($aln->get_seq_by_pos(1)->version, '1');
55 is($aln->accession, 'RF00007');
56 is($aln->id, 'U12');
57 is($aln->description,'U12 minor spliceosomal RNA');
58 my @anns = $aln->annotation->get_Annotations('reference');
59 $ann = shift @anns;
60 isa_ok($ann, 'Bio::Annotation::Reference', 'Stockholm annotation');
61 $ann = shift @anns;
62 is($ann->pubmed,'9149533', 'Stockholm annotation');
63 is($ann->title,
64    'Pre-mRNA splicing: the discovery of a new spliceosome doubles the challenge.',
65    'Stockholm annotation');
66 is($ann->authors,'Tarn WY, Steitz JA;', 'Stockholm annotation');
67 is($ann->location,'Trends Biochem Sci 1997;22:132-137.', 'Stockholm annotation');
68 # alignment meta data
69 my $meta = $aln->consensus_meta;
70 isa_ok($meta, 'Bio::Seq::MetaI');
71 my ($name) = $meta->meta_names;
72 is($name,'SS_cons', 'Rfam meta data');
73 my $meta_str = $meta->named_meta($name);
74 is($meta_str, '...<<<<<..........>>>>>........<<<<......<<<<......>>>>>>>>'.
75    '<<<<<.......>>>>>...........<<<<<<<...<<<<<<<.....>>>>>>>.>>>>>>>..<<<'.
76    '<<<<<<.........>>>>>>>>>...', 'Rfam meta data');
77 $aln = $str->next_aln();
78 is($aln->source, 'stockholm');
79 isa_ok($aln,'Bio::Align::AlignI');
80 is($aln->get_seq_by_pos(1)->get_nse, 'AJ295015.1/1-58');
81 is($aln->accession, 'RF00008');
82 is($aln->id, 'Hammerhead_3');
83 is($aln->description,'Hammerhead ribozyme (type III)');
84 # alignment meta data
85 $meta = $aln->consensus_meta;
86 isa_ok($meta, 'Bio::Seq::MetaI');
87 ($name) = $meta->meta_names;
88 is($name,'SS_cons', 'Rfam meta data');
89 $meta_str = $meta->named_meta($name);
90 is($meta_str, '.<<<<<<..<<<<<.........>>>>>.......<<<<.....................'.
91    '...........>>>>...>>>>>>.', 'Rfam meta data');
93 # STOCKHOLM (Pfam)
94 $str  = Bio::AlignIO->new(
95     '-file'     => test_input_file("pfam_tests.stk"),
96     '-format'   => 'stockholm');
97 isa_ok($str,'Bio::AlignIO');
98 $aln = $str->next_aln();
99 is($aln->source, 'stockholm');
100 isa_ok($aln,'Bio::Align::AlignI');
101 is($aln->get_seq_by_pos(1)->get_nse, 'RAD25_SCHPO/5-240');
102 is($aln->accession, 'PF00244.9');
103 is($aln->id, '14-3-3');
104 is($aln->description,'14-3-3 protein');
105 ($ann) = $aln->annotation->get_Annotations('gathering_threshold');
106 isa_ok($ann, 'Bio::Annotation::SimpleValue');
107 is($ann->display_text, '25.00 25.00; 25.00 25.00;', 'Pfam annotation');
108 $aln = $str->next_aln();
109 is($aln->source, 'stockholm');
110 isa_ok($aln,'Bio::Align::AlignI');
111 is($aln->get_seq_by_pos(1)->get_nse, 'COMB_CLOAB/6-235');
112 is($aln->accession, 'PF04029.4');
113 is($aln->id, '2-ph_phosp');
114 is($aln->description,'2-phosphosulpholactate phosphatase');
115 $aln = $str->next_aln();
116 isa_ok($aln,'Bio::Align::AlignI');
117 is($aln->source, 'stockholm');
118 is($aln->get_seq_by_pos(1)->get_nse, 'Y278_HAEIN/174-219');
119 is($aln->accession, 'PF03475.3');
120 is($aln->id, '3-alpha');
121 is($aln->description,'3-alpha domain');
122 # alignment meta data
123 $meta = $aln->consensus_meta;
124 isa_ok($meta, 'Bio::Seq::MetaI');
125 my %test_data = ('SA_cons'  => '6000320010013274....3372052026033.108303630350385563',
126                  'SS_cons'  => 'SCBHHHHHHHHHTSCC....CHHHHHHHHTSTT.CCHHHHHHHHHHHHHSSC',
127                  'seq_cons' => 'plTVtclsclhasc......stphLcphLshss.Lupsa+cohpK+lspshs',);
128 for my $name ($meta->meta_names) {
129     ok(exists $test_data{$name}, 'Pfam aln meta data');
130     $meta_str = $meta->named_meta($name);
131     is($meta_str, $test_data{$name}, 'Pfam aln meta data');
133 %test_data = ();
134 # sequence meta data
135 %test_data = ('SA'  => '6000320010013274....3372052026033.108303630350385563',
136               'SS'  => 'SCBHHHHHHHHHTSCC....CHHHHHHHHTSTT.CCHHHHHHHHHHHHHSSC');
137 for my $seq ($aln->each_seq) {
138     for my $name ($seq->meta_names) {
139         ok(exists $test_data{$name}, 'Pfam seq meta data');
140         is($seq->named_meta($name), $test_data{$name}, 'Pfam seq meta data');
141     }
144 # sequence-specific alignments
145 # these are generally DBLinks. However, simple DBLinks are not RangeI, so these
146 # are now Target (which now is-a DBLink). Since these are per-seq, these are
147 # stored in a full-length SeqFeature as annotation. For now only sequences which
148 # have this annotation have a SeqFeature.
150 my @feats = $aln->get_SeqFeatures;
151 is(scalar(@feats),6);
152 isa_ok($feats[0], 'Bio::SeqFeatureI');
153 isa_ok($feats[0]->entire_seq, 'Bio::Seq::Meta');
155 my ($link)  = $feats[0]->annotation->get_Annotations('dblink');
156 isa_ok($link, 'Bio::AnnotationI');
157 isa_ok($link, 'Bio::Annotation::DBLink');
158 is($link->database, 'PDB');
159 is($link->start, '178');
160 is($link->end, '224');
161 is($link->primary_id, '1o65');
162 is($link->target_id, '1o65');  # if not set, defaults to primary_id
163 is($link->optional_id, 'A');
164 ($link)  = $feats[3]->annotation->get_Annotations('dblink');
165 is($link->database, 'PDB');
166 is($link->start, '178');
167 is($link->end, '224');
168 is($link->target_id, '1o67');