[bug 2637]
[bioperl-live.git] / t / Phenotype / OMIMparser.t
blob83dd0167dcceb4b37a6dd7a625f003bebe3b0cbf
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 => 175);
11     
12     use_ok('Bio::Phenotype::OMIM::OMIMparser');
16 my $omim_parser = Bio::Phenotype::OMIM::OMIMparser->new( -genemap  => test_input_file('omim_genemap_test'),
17                                                          -omimtext => test_input_file('omim_text_test'));
19 isa_ok( $omim_parser, "Bio::Phenotype::OMIM::OMIMparser");
21 my $omim_entry = $omim_parser->next_phenotype();
23 isa_ok($omim_entry, "Bio::Phenotype::OMIM::OMIMentry");
25 is( $omim_entry->MIM_number(), "100500" );
26 is( $omim_entry->title(), "*100500 title" );
27 is( $omim_entry->alternative_titles_and_symbols(), ";;title1;;\ntitle2;;\ntitle3" );
28 is( $omim_entry->more_than_two_genes(), 0 );
29 is( $omim_entry->is_separate(), 1 );
30 is( $omim_entry->description(), undef); # "DESCRIPTION1\nDESCRIPTION2" );
31 is( $omim_entry->mapping_method(), "M method 1" );
32 is( $omim_entry->gene_status(), "C" );
33 is( $omim_entry->comment(), "comment1" );
34 is( $omim_entry->edited(), undef); # "ed1\ned2\ned3" );
35 is( $omim_entry->created(), undef); # "cd1\ncd2\ncd3" );
36 is( $omim_entry->contributors, undef); # "cn1\ncn2\ncn3" );
37 is( $omim_entry->additional_references(), "sa" );
38 is( ref($omim_entry->clinical_symptoms()), 'HASH' );
39 is( $omim_entry->species()->binomial(), "Homo sapiens" );
42 my $mini_mim = $omim_entry->miniMIM();
44 isa_ok( $mini_mim,"Bio::Phenotype::OMIM::MiniMIMentry" );
45 is( $mini_mim->description(), "Mini MIM text" );
46 is( $mini_mim->created(), "Mini MIM - cd" );
47 is( $mini_mim->contributors(), "Mini MIM - cn" );
48 is( $mini_mim->edited(), "Mini MIM - ed" );
51 my @corrs      = $omim_entry->each_Correlate();
53 is( $corrs[ 0 ]->name(), "mousecorrelate1" );
54 is( $corrs[ 0 ]->type(), "OMIM mouse correlate" );
55 is( $corrs[ 0 ]->species()->binomial(), "Mus musculus" );
58 my @cps        = $omim_entry->each_CytoPosition();
60 is( $cps[ 0 ]->value(), "1pter-p36.14" );
63 my @gss        = $omim_entry->each_gene_symbol();
65 is( $gss[ 0 ], "gene-symbol1" );
68 my @refs       = $omim_entry->each_Reference();
70 is( $refs[ 0 ]->authors(), "Author11, A. A.; Author12, A. A." );
71 is( $refs[ 0 ]->title(), "Title 1." );
72 is( $refs[ 0 ]->location(), "Am. J. Med. Genet1. 11 11-111 \(1981\)" );
74 is( $refs[ 1 ]->authors(), "Author21, A. A.; Author22, A. A." );
75 is( $refs[ 1 ]->title(), "Title 2." );
76 is( $refs[ 1 ]->location(), "Am. J. Med. Genet2. 12 22-222 \(1982\)" );
78 is( $refs[ 2 ]->authors(), "Author31, A. A.; Author32, A. A." );
79 is( $refs[ 2 ]->title(), "Title 3." );
80 is( $refs[ 2 ]->location(), "Am. J. Med. Genet3. 13 33-333 \(1983\)" );
82 is( $refs[ 3 ]->authors(), "" );
83 is( $refs[ 3 ]->title(), "other reference undef format" );
84 is( $refs[ 3 ]->location(), "" );
88 my @avs        = $omim_entry->each_AllelicVariant();
90 is( $avs[ 0 ]->number(), ".0001" );
91 is( $avs[ 0 ]->title(), "ALCOHOL INTOLERANCE, ACUTE" );
92 is( $avs[ 0 ]->symbol(), "ALDH2" );
93 is( $avs[ 0 ]->description(), "AV1-text" );
94 is( $avs[ 0 ]->aa_ori(), "GLU" );
95 is( $avs[ 0 ]->aa_mut(), "LYS" );
96 is( $avs[ 0 ]->position(), "487" );
97 is( $avs[ 0 ]->additional_mutations(), "" );
100 is( $avs[ 1 ]->number(), ".0002" );
101 is( $avs[ 1 ]->title(), "MYASTHENIC SYNDROME, SLOW-CHANNEL CONGENITAL" );
102 is( $avs[ 1 ]->symbol(), "CHRNA1" );
103 is( $avs[ 1 ]->description(), "AV2-text" );
104 is( $avs[ 1 ]->aa_ori(), "VAL" );
105 is( $avs[ 1 ]->aa_mut(), "MET" );
106 is( $avs[ 1 ]->position(), "156" );
107 is( $avs[ 1 ]->additional_mutations(), "" );
110 is( $avs[ 2 ]->number(), ".0003" );
111 is( $avs[ 2 ]->title(), "MYASTHENIC SYNDROME, SLOW-CHANNEL CONGENITAL" );
112 is( $avs[ 2 ]->symbol(), "CHRNE" );
113 is( $avs[ 2 ]->description(), "AV2-text a\nAV2-text b" );
114 is( $avs[ 2 ]->aa_ori(), "ARG" );
115 is( $avs[ 2 ]->aa_mut(), "LEU" );
116 is( $avs[ 2 ]->position(), "147" );
117 is( $avs[ 2 ]->additional_mutations(), "" );
120 is( $avs[ 3 ]->number(), ".0004" );
121 is( $avs[ 3 ]->title(), "MYASTHENIC SYNDROME, SLOW-CHANNEL CONGENITAL" );
122 is( $avs[ 3 ]->symbol(), "CHRNE" );
123 is( $avs[ 3 ]->description(), "Sieb et al. (2000) found that a brother and sister with congenital\nmyasthenic syndrome (601462) were compound heterozygotes for a deletion\nof 911T and a splicing mutation (IVS4+1G-A; 100725.0007)." );
124 is( $avs[ 3 ]->aa_ori(), "" );
125 is( $avs[ 3 ]->aa_mut(), "" );
126 is( $avs[ 3 ]->position(), "" );
127 is( $avs[ 3 ]->additional_mutations(), "1-BP DEL, 911T" );
130 is( $avs[ 4 ]->number(), ".0005" );
131 is( $avs[ 4 ]->title(), "MYASTHENIC SYNDROME, SLOW-CHANNEL CONGENITAL" );
132 is( $avs[ 4 ]->symbol(), "CHRNE" );
133 is( $avs[ 4 ]->description(), "See 100725.0006 and Sieb et al. (2000)." );
134 is( $avs[ 4 ]->aa_ori(), "" );
135 is( $avs[ 4 ]->aa_mut(), "" );
136 is( $avs[ 4 ]->position(), "" );
137 is( $avs[ 4 ]->additional_mutations(), "IVS4DS, G-A, +1" );
141 is( $avs[ 5 ]->number(), ".0006" );
142 is( $avs[ 5 ]->title(), "MYASTHENIC SYNDROME, SLOW-CHANNEL CONGENITAL" );
143 is( $avs[ 5 ]->symbol(), "CHRNE" );
144 is( $avs[ 5 ]->description(), "AV6-text" );
145 is( $avs[ 5 ]->aa_ori(), "" );
146 is( $avs[ 5 ]->aa_mut(), "" );
147 is( $avs[ 5 ]->position(), "" );
148 is( $avs[ 5 ]->additional_mutations(), "1-BP DEL, 1030C" );
154 my $omim_entry2 = $omim_parser->next_phenotype();
157 isa_ok( $omim_entry2, "Bio::Phenotype::OMIM::OMIMentry" );
159 is( $omim_entry2->MIM_number(), "100501" );
160 is( $omim_entry2->title(), "#100501 second entry" );
161 is( $omim_entry2->alternative_titles_and_symbols(), ";;title1;;\ntitle2;;\ntitle3" );
162 is( $omim_entry2->more_than_two_genes(), 1 );
163 is( $omim_entry2->is_separate(), 0 );
164 is( $omim_entry2->description(), undef); # "DESCRIPTION1\nDESCRIPTION2" );
165 is( $omim_entry2->mapping_method(), "M method 2" );
166 is( $omim_entry2->gene_status(), "C" );
167 is( $omim_entry2->comment(), "comment2" );
168 is( $omim_entry2->edited(), undef); # "ed1\ned2\ned3" );
169 is( $omim_entry2->created(), undef); # "cd1\ncd2\ncd3" );
170 is( $omim_entry2->contributors(), undef); # "cn1\ncn2\ncn3" );
171 is( $omim_entry2->additional_references(), "sa" );
173 my $cs = $omim_entry2->clinical_symptoms();
174 is( ref($cs), 'HASH' );
175 is( $omim_entry2->species()->binomial(), "Homo sapiens" );
178 $mini_mim   = $omim_entry2->miniMIM();
180 isa_ok( $mini_mim, "Bio::Phenotype::OMIM::MiniMIMentry" );
181 is( $mini_mim->description(), "Mini MIM text" );
182 is( $mini_mim->created(), "Mini MIM - cd" );
183 is( $mini_mim->contributors(), "Mini MIM - cn" );
184 is( $mini_mim->edited(), "Mini MIM - ed" );
187 @corrs      = $omim_entry2->each_Correlate();
189 is( $corrs[ 0 ]->name(), "mousecorrelate2" );
190 is( $corrs[ 0 ]->type(), "OMIM mouse correlate" );
191 is( $corrs[ 0 ]->species()->binomial(), "Mus musculus" );
194 @cps        = $omim_entry2->each_CytoPosition();
196 is( $cps[ 0 ]->value(), "1pter-p36.15" );
199 @gss        = $omim_entry2->each_gene_symbol();
201 is( $gss[ 0 ], "gene-symbol2" );
204 @refs       = $omim_entry2->each_Reference();
206 is( $refs[ 0 ]->authors(), "Author11, A. A.; Author12, A. A." );
207 is( $refs[ 0 ]->title(), "Title 1." );
208 is( $refs[ 0 ]->location(), "Am. J. Med. Genet1. 11 11-111 \(1981\)" );
210 is( $refs[ 1 ]->authors(), "Author21, A. A.; Author22, A. A." );
211 is( $refs[ 1 ]->title(), "Title 2." );
212 is( $refs[ 1 ]->location(), "Am. J. Med. Genet2. 12 22-222 \(1982\)" );
214 is( $refs[ 2 ]->authors(), "Author31, A. A.; Author32, A. A." );
215 is( $refs[ 2 ]->title(), "Title 3." );
216 is( $refs[ 2 ]->location(), "Am. J. Med. Genet3. 13 33-333 \(1983\)" );
218 is( $refs[ 3 ]->authors(), "" );
219 is( $refs[ 3 ]->title(), "other reference undef format" );
220 is( $refs[ 3 ]->location(), "" );
224 @avs        = $omim_entry2->each_AllelicVariant();
226 is( $avs[ 0 ]->number(), ".0001" );
227 is( $avs[ 0 ]->title(), "ALCOHOL INTOLERANCE, ACUTE" );
228 is( $avs[ 0 ]->symbol(), "ALDH2" );
229 is( $avs[ 0 ]->description(), "AV1-text" );
230 is( $avs[ 0 ]->aa_ori(), "GLU" );
231 is( $avs[ 0 ]->aa_mut(), "LYS" );
232 is( $avs[ 0 ]->position(), "487" );
233 is( $avs[ 0 ]->additional_mutations(), "" );
236 is( $avs[ 1 ]->number(), ".0002" );
237 is( $avs[ 1 ]->title(), "MYASTHENIC SYNDROME, SLOW-CHANNEL CONGENITAL" );
238 is( $avs[ 1 ]->symbol(), "CHRNA1" );
239 is( $avs[ 1 ]->description(), "AV2-text" );
240 is( $avs[ 1 ]->aa_ori(), "VAL" );
241 is( $avs[ 1 ]->aa_mut(), "MET" );
242 is( $avs[ 1 ]->position(), "156" );
243 is( $avs[ 1 ]->additional_mutations(), "" );
246 is( $avs[ 2 ]->number(), ".0003" );
247 is( $avs[ 2 ]->title(), "MYASTHENIC SYNDROME, SLOW-CHANNEL CONGENITAL" );
248 is( $avs[ 2 ]->symbol(), "CHRNE" );
249 is( $avs[ 2 ]->description(), "AV2-text a\nAV2-text b" );
250 is( $avs[ 2 ]->aa_ori(), "ARG" );
251 is( $avs[ 2 ]->aa_mut(), "LEU" );
252 is( $avs[ 2 ]->position(), "147" );
253 is( $avs[ 2 ]->additional_mutations(), "" );
256 is( $avs[ 3 ]->number(), ".0004" );
257 is( $avs[ 3 ]->title(), "MYASTHENIC SYNDROME, SLOW-CHANNEL CONGENITAL" );
258 is( $avs[ 3 ]->symbol(), "CHRNE" );
259 is( $avs[ 3 ]->description(), "Sieb et al. (2000) found that a brother and sister with congenital\nmyasthenic syndrome (601462) were compound heterozygotes for a deletion\nof 911T and a splicing mutation (IVS4+1G-A; 100725.0007)." );
260 is( $avs[ 3 ]->aa_ori(), "" );
261 is( $avs[ 3 ]->aa_mut(), "" );
262 is( $avs[ 3 ]->position(), "" );
263 is( $avs[ 3 ]->additional_mutations(), "1-BP DEL, 911T" );
266 is( $avs[ 4 ]->number(), ".0005" );
267 is( $avs[ 4 ]->title(), "MYASTHENIC SYNDROME, SLOW-CHANNEL CONGENITAL" );
268 is( $avs[ 4 ]->symbol(), "CHRNE" );
269 is( $avs[ 4 ]->description(), "See 100725.0006 and Sieb et al. (2000)." );
270 is( $avs[ 4 ]->aa_ori(), "" );
271 is( $avs[ 4 ]->aa_mut(), "" );
272 is( $avs[ 4 ]->position(), "" );
273 is( $avs[ 4 ]->additional_mutations(), "IVS4DS, G-A, +1" );
277 is( $avs[ 5 ]->number(), ".0006" );
278 is( $avs[ 5 ]->title(), "MYASTHENIC SYNDROME, SLOW-CHANNEL CONGENITAL" );
279 is( $avs[ 5 ]->symbol(), "CHRNE" );
280 is( $avs[ 5 ]->description(), "AV6-text" );
281 is( $avs[ 5 ]->aa_ori(), "" );
282 is( $avs[ 5 ]->aa_mut(), "" );
283 is( $avs[ 5 ]->position(), "" );
284 is( $avs[ 5 ]->additional_mutations(), "1-BP DEL, 1030C" );
287 # catch missing linebreak
288 throws_ok { my $omim_parser = Bio::Phenotype::OMIM::OMIMparser->new(
289     -genemap  => test_input_file('omim_genemap_test_linebreak'),
290     -omimtext => test_input_file('omim_text_test'));
291 } qr/linebreak/, 'missing linebreak caught';