1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 463,
10 -requires_module => 'IO::Scalar');
12 use_ok('Bio::Tools::CodonTable');
13 use_ok('Bio::SeqIO::table');
36 my @num_anns = (5, 5, 5, 5, 6, 7, 7, 7, 7, 7);
37 my @psg = (0, 0, 1, 1, 0, 0, 0, 0, 0, 0);
38 my @rs = (0, 0, 0, 0, 1, 1, 1, 1, 1, 1);
40 ok my $seqin = Bio::SeqIO->new(-file => test_input_file("test.tsv"),
42 -species => "Homo sapiens",
46 -accession_number => 2,
50 run_tests([@names],[@accs],[@num_anns],[@psg],[@rs]);
54 ok $seqin = Bio::SeqIO->new(-file => test_input_file("test.tsv"),
56 -species => "Homo sapiens",
60 -accession_number => 2,
62 -colnames => "[Family,Subfamily,Pseudogene?,Protein,Novelty]",
64 run_tests([@names],[@accs],[4,4,4,4,4,5,5,5,5,5],[@psg],[@rs]);
68 ok $seqin = Bio::SeqIO->new(-file => test_input_file("test.tsv"),
70 -species => "Homo sapiens",
74 -accession_number => 2,
76 -annotation => "[4,5,6,8,10]",
78 run_tests([@names],[@accs],[4,4,4,4,4,5,5,5,5,5],[@psg],[@rs]);
80 # Tests to check that 'description' is read from 'table' format
81 ok $seqin = Bio::SeqIO->new(
82 -file => test_input_file("test-1.tab"),
86 -accession_number => 1,
91 my $seq = $seqin->next_seq;
93 is( $seq->desc, 'd1');
94 is( $seq->display_id, 'n1');
95 is( $seq->seq, 'aaaa');
96 $seq = $seqin->next_seq;
98 is( $seq->desc, 'd2');
99 is( $seq->display_id, 'n2');
100 is( $seq->seq, 'tttt');
104 # Tests to check that we can _not_ write to 'table' format
105 ok $seqin = Bio::SeqIO->new(
106 -file => test_input_file("test-1.tab.gb"),
110 my $seq = $seqin->next_seq;
112 my $tmpfile = test_output_file();
113 my $seqout = Bio::SeqIO->new( -format => 'table', -file => ">$tmpfile" );
114 # dies_ok not available
115 # dies_ok { $seqout->write_seq($seq) } "write_seq() not implemented";
117 # Need Spreadsheet::ParseExcel installed for testing Excel format
119 test_skip(-tests => 112, -requires_module => 'Spreadsheet::ParseExcel');
121 ok $seqin = Bio::SeqIO->new(-file => test_input_file("test.xls"),
123 -species => "Homo sapiens",
126 -accession_number => 2,
130 run_tests([@names],[@accs],[@num_anns],[@psg],[@rs]);
136 my ($names_,$accs_,$num_anns_,$psg_,$rs_) = @_;
138 my @names = @$names_;
140 my @num_anns = @$num_anns_;
145 my $translator = Bio::Tools::CodonTable->new(-id => 1);
146 while (my $seq = $seqin->next_seq()) {
148 is ($seq->display_id, shift(@names));
149 is ($seq->accession_number, shift(@accs));
151 is ($seq->species->binomial, "Homo sapiens");
152 my @anns = $seq->annotation->get_Annotations();
153 is (scalar(@anns), shift(@num_anns));
154 @anns = grep { $_->value eq "Y";
155 } $seq->annotation->get_Annotations("Pseudogene?");
156 is (scalar(@anns), shift(@psg));
158 # check sequences and that they translate to what we expect
159 if (($n >= 5) && ($seq->display_id ne "MARK3")) {
163 while ($frame <= 2) {
164 my $inframe = substr($dna,$frame);
165 # translate to protein
166 my $protseq = $translator->translate($inframe);
167 # chop off everything after the stop and before the first Met
168 while ($protseq =~ /(M[^\*]+)/g) {
169 $protein = $1 if length($1) > length($protein);
173 # retrieve expected result from annotation and compare
174 my ($protann) = $seq->annotation->get_Annotations("Protein");
175 ok (defined $protann);
176 is ($protein, $protann->value);
179 @anns = grep { $_->value eq "Known - Refseq";
180 } $seq->annotation->get_Annotations("Novelty");
181 is (scalar(@anns), shift(@rs));
182 @anns = $seq->annotation->get_Annotations("Subfamily");
183 is (scalar(@anns), ($n <= 5) ? 0 : 1);
184 @anns = $seq->annotation->get_Annotations("Family");
185 is (scalar(@anns), 1);
186 is (substr($anns[0]->value,0,4), ($n <= 4) ? "A6" : "CAMK");