1 # -*-Perl-*- Test Harness script for Bioperl
8 test_begin(-tests => 351,
9 -requires_module => 'IO::Scalar');
11 use_ok('Bio::Tools::CodonTable');
12 use_ok('Bio::SeqIO::table');
35 my @num_anns = (5, 5, 5, 5, 6, 7, 7, 7, 7, 7);
36 my @psg = (0, 0, 1, 1, 0, 0, 0, 0, 0, 0);
37 my @rs = (0, 0, 0, 0, 1, 1, 1, 1, 1, 1);
39 ok my $seqin = Bio::SeqIO->new(-file => test_input_file("test.tsv"),
41 -species => "Homo sapiens",
45 -accession_number => 2,
49 run_tests([@names],[@accs],[@num_anns],[@psg],[@rs]);
53 ok $seqin = Bio::SeqIO->new(-file => test_input_file("test.tsv"),
55 -species => "Homo sapiens",
59 -accession_number => 2,
61 -colnames => "[Family,Subfamily,Pseudogene?,Protein,Novelty]",
63 run_tests([@names],[@accs],[4,4,4,4,4,5,5,5,5,5],[@psg],[@rs]);
67 ok $seqin = Bio::SeqIO->new(-file => test_input_file("test.tsv"),
69 -species => "Homo sapiens",
73 -accession_number => 2,
75 -annotation => "[4,5,6,8,10]",
77 run_tests([@names],[@accs],[4,4,4,4,4,5,5,5,5,5],[@psg],[@rs]);
79 # Tests to check that 'description' is read from 'table' format
80 ok $seqin = Bio::SeqIO->new(
81 -file => test_input_file("test-1.tab"),
85 -accession_number => 1,
90 my $seq = $seqin->next_seq;
92 is( $seq->desc, 'd1');
93 is( $seq->display_id, 'n1');
94 is( $seq->seq, 'aaaa');
95 $seq = $seqin->next_seq;
97 is( $seq->desc, 'd2');
98 is( $seq->display_id, 'n2');
99 is( $seq->seq, 'tttt');
103 # Tests to check that we can _not_ write to 'table' format
104 ok $seqin = Bio::SeqIO->new(
105 -file => test_input_file("test-1.tab.gb"),
109 $seq = $seqin->next_seq;
111 my $tmpfile = test_output_file();
112 my $seqout = Bio::SeqIO->new( -format => 'table', -file => ">$tmpfile" );
113 # dies_ok not available
114 # dies_ok { $seqout->write_seq($seq) } "write_seq() not implemented";
117 my ($names_,$accs_,$num_anns_,$psg_,$rs_) = @_;
119 my @names = @$names_;
121 my @num_anns = @$num_anns_;
126 my $translator = Bio::Tools::CodonTable->new(-id => 1);
127 while (my $seq = $seqin->next_seq()) {
129 is ($seq->display_id, shift(@names));
130 is ($seq->accession_number, shift(@accs));
132 is ($seq->species->binomial, "Homo sapiens");
133 my @anns = $seq->annotation->get_Annotations();
134 is (scalar(@anns), shift(@num_anns));
135 @anns = grep { $_->value eq "Y";
136 } $seq->annotation->get_Annotations("Pseudogene?");
137 is (scalar(@anns), shift(@psg));
139 # check sequences and that they translate to what we expect
140 if (($n >= 5) && ($seq->display_id ne "MARK3")) {
144 while ($frame <= 2) {
145 my $inframe = substr($dna,$frame);
146 # translate to protein
147 my $protseq = $translator->translate($inframe);
148 # chop off everything after the stop and before the first Met
149 while ($protseq =~ /(M[^\*]+)/g) {
150 $protein = $1 if length($1) > length($protein);
154 # retrieve expected result from annotation and compare
155 my ($protann) = $seq->annotation->get_Annotations("Protein");
156 ok (defined $protann);
157 is ($protein, $protann->value);
160 @anns = grep { $_->value eq "Known - Refseq";
161 } $seq->annotation->get_Annotations("Novelty");
162 is (scalar(@anns), shift(@rs));
163 @anns = $seq->annotation->get_Annotations("Subfamily");
164 is (scalar(@anns), ($n <= 5) ? 0 : 1);
165 @anns = $seq->annotation->get_Annotations("Family");
166 is (scalar(@anns), 1);
167 is (substr($anns[0]->value,0,4), ($n <= 4) ? "A6" : "CAMK");