1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 87);
11 use_ok('Bio::AlignIO::stockholm');
14 my $DEBUG = test_debug();
16 my ($str,$aln,$strout,$status);
18 # STOCKHOLM (multiple concatenated files)
20 $str = Bio::AlignIO->new(
21 '-file' => test_input_file("rfam_tests.stk"),
22 '-format' => 'stockholm');
23 $strout = Bio::AlignIO->new('-file' => ">".test_output_file(),
24 '-format' => 'stockholm', );
26 isa_ok($str,'Bio::AlignIO');
27 $aln = $str->next_aln();
28 isa_ok($aln,'Bio::Align::AlignI');
29 is($aln->source, 'stockholm');
30 is($aln->get_seq_by_pos(1)->get_nse, 'Z11765.1/1-89');
31 is($aln->accession, 'RF00006');
32 is($aln->id, 'Vault');
33 is($aln->description,'Vault RNA');
35 my ($ann) = $aln->annotation->get_Annotations('alignment_comment');
36 isa_ok($ann, 'Bio::Annotation::Comment');
37 is($ann->text,'This family of RNAs are found as part of the enigmatic vault'.
38 ' ribonucleoprotein complex. The complex consists of a major vault protein'.
39 ' (MVP), two minor vault proteins (VPARP and TEP1), and several small '.
40 'untranslated RNA molecules. It has been suggested that the vault complex '.
41 'is involved in drug resistance. We have identified a putative novel vault '.
42 'RNA on chromosome 5 EMBL:AC005219.','Stockholm annotation');
43 is($ann->tagname,'alignment_comment','Stockholm annotation');
46 $status = $strout->write_aln($aln);
47 is $status, 1, "stockholm output test";
49 $aln = $str->next_aln();
50 isa_ok($aln,'Bio::Align::AlignI');
51 is($aln->source, 'stockholm');
52 is($aln->get_seq_by_pos(1)->get_nse, 'L43844.1/2-149');
53 is($aln->get_seq_by_pos(1)->version, '1');
54 is($aln->accession, 'RF00007');
56 is($aln->description,'U12 minor spliceosomal RNA');
57 my @anns = $aln->annotation->get_Annotations('reference');
59 isa_ok($ann, 'Bio::Annotation::Reference', 'Stockholm annotation');
61 is($ann->pubmed,'9149533', 'Stockholm annotation');
63 'Pre-mRNA splicing: the discovery of a new spliceosome doubles the challenge.',
64 'Stockholm annotation');
65 is($ann->authors,'Tarn WY, Steitz JA;', 'Stockholm annotation');
66 is($ann->location,'Trends Biochem Sci 1997;22:132-137.', 'Stockholm annotation');
68 my $meta = $aln->consensus_meta;
69 isa_ok($meta, 'Bio::Seq::MetaI');
70 my ($name) = $meta->meta_names;
71 is($name,'SS_cons', 'Rfam meta data');
72 my $meta_str = $meta->named_meta($name);
73 is($meta_str, '...<<<<<..........>>>>>........<<<<......<<<<......>>>>>>>>'.
74 '<<<<<.......>>>>>...........<<<<<<<...<<<<<<<.....>>>>>>>.>>>>>>>..<<<'.
75 '<<<<<<.........>>>>>>>>>...', 'Rfam meta data');
76 $aln = $str->next_aln();
77 is($aln->source, 'stockholm');
78 isa_ok($aln,'Bio::Align::AlignI');
79 is($aln->get_seq_by_pos(1)->get_nse, 'AJ295015.1/58-1');
80 is($aln->get_seq_by_pos(1)->strand, -1);
81 is($aln->accession, 'RF00008');
82 is($aln->id, 'Hammerhead_3');
83 is($aln->description,'Hammerhead ribozyme (type III)');
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');
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');
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');
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');
172 my $in = Bio::AlignIO->new(-file => test_input_file('tiny.stk'),
173 -format => 'stockholm');
174 $aln = $in->next_aln;
175 is($aln->id, 'NoName');
176 is($aln->get_seq_by_id('a')->display_id, 'a');
177 is($aln->get_seq_by_id('b')->display_id, 'b');