1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 101);
15 my $verbosity = test_debug();
17 my ($seqio, $seq); # predeclare variables for strict
20 ok $seqio = Bio::SeqIO->new('-file'=> test_input_file('test.genbank'),
21 '-format' => 'GenBank');
22 $seqio->verbose($verbosity);
25 my @loci = qw(U63596 U63595 M37762 NT_010368 L26462);
26 my @numfeas = (3,1,6,3,26);
28 while($seq = $seqio->next_seq()) {
29 is ($seq->accession_number, $loci[$numseqs++]);
30 ok ($seq->annotation->get_Annotations());
31 is (scalar($seq->top_SeqFeatures), $numfeas[$numseqs-1]);
32 ok ($seq->species->binomial);
38 $seqio = Bio::SeqIO->new('-file'=> test_input_file('test.genbank'),
39 '-format' => 'GenBank');
41 $seqio->verbose($verbosity);
42 ok my $seqbuilder = $seqio->sequence_builder();
43 isa_ok $seqbuilder, "Bio::Factory::ObjectBuilderI";
44 $seqbuilder->want_none();
45 $seqbuilder->add_wanted_slot('display_id','accession_number','desc');
49 while($seq = $seqio->next_seq()) {
50 is ($seq->accession_number, $loci[$numseqs++]);
51 is (scalar(grep { ! ($_->tagname eq "keyword" ||
52 $_->tagname eq "date_changed" ||
53 $_->tagname eq "secondary_accession"); }
54 $seq->annotation->get_Annotations()), 0);
56 is (scalar($seq->top_SeqFeatures), 0);
59 is (scalar($seq->top_SeqFeatures), $numfeas[$numseqs-1]);
61 is ($seq->species, undef);
62 is ($seq->seq, undef);
63 # switch on features for the last 2 seqs
64 $seqbuilder->add_wanted_slot('features') if $numseqs == 3;
68 # everything but no sequence, and no features
69 $seqio = Bio::SeqIO->new('-file'=> test_input_file('test.genbank'),
70 '-format' => 'GenBank');
72 $seqio->verbose($verbosity);
73 $seqbuilder = $seqio->sequence_builder();
75 $seqbuilder->add_unwanted_slot('seq','features');
79 while($seq = $seqio->next_seq()) {
80 is ($seq->accession_number, $loci[$numseqs++]);
81 ok scalar($seq->annotation->get_Annotations());
83 is (scalar($seq->top_SeqFeatures), 0);
86 is (scalar($seq->top_SeqFeatures), $numfeas[$numseqs-1]);
88 ok $seq->species->binomial;
89 is ($seq->seq, undef);
90 # switch on features for the last 2 seqs
92 $seqbuilder->add_unwanted_slot(
93 grep { $_ ne 'features'; } $seqbuilder->remove_unwanted_slots());
98 # skip sequences less than 100bp or accession like 'NT_*'
99 $seqio = Bio::SeqIO->new('-file'=> test_input_file('test.genbank'),
100 '-format' => 'GenBank');
102 $seqio->verbose($verbosity);
103 $seqbuilder = $seqio->sequence_builder();
104 # we could have as well combined the two conditions into one, but we want to
105 # test the implicit AND here
106 $seqbuilder->add_object_condition(sub {
108 return 0 if($h->{'-length'} < 100);
111 $seqbuilder->add_object_condition(sub {
113 return 0 if($h->{'-display_id'} =~ /^NT_/);
120 while($seq = $seqio->next_seq()) {
122 is ($seq->accession_number, $loci[$i]);
123 ok scalar($seq->annotation->get_Annotations());
124 is (scalar($seq->top_SeqFeatures), $numfeas[$i]);
125 ok $seq->species->binomial;