1 # -*-Perl-*- Test Harness script for Bioperl
8 test_begin(-tests => 137);
12 my $verbosity = test_debug;
14 my ($seqio, $seq); # predeclare variables for strict
17 ok $seqio = Bio::SeqIO->new('-file' => test_input_file('test.genbank'),
18 '-format' => 'GenBank');
19 $seqio->verbose($verbosity);
22 my @loci = qw(U63596 U63595 M37762 NT_010368 L26462);
23 my @numfeas = (3,1,6,3,26);
25 while ($seq = $seqio->next_seq) {
26 is $seq->accession_number, $loci[$numseqs++];
27 ok $seq->annotation->get_Annotations;
28 is scalar($seq->top_SeqFeatures), $numfeas[$numseqs-1];
29 ok $seq->species->binomial;
37 $seqio = Bio::SeqIO->new('-file' => test_input_file('test.genbank'),
38 '-format' => 'GenBank');
40 $seqio->verbose($verbosity);
41 ok my $seqbuilder = $seqio->sequence_builder;
42 isa_ok $seqbuilder, "Bio::Factory::ObjectBuilderI";
43 $seqbuilder->want_none;
44 $seqbuilder->add_wanted_slot('display_id','accession_number','desc');
48 while ($seq = $seqio->next_seq) {
49 is $seq->accession_number, $loci[$numseqs++];
50 is scalar(grep { ! ($_->tagname eq "keyword" ||
51 $_->tagname eq "date_changed" ||
52 $_->tagname eq "secondary_accession"); }
53 $seq->annotation->get_Annotations), 0;
55 is scalar($seq->top_SeqFeatures), 0;
58 is scalar($seq->top_SeqFeatures), $numfeas[$numseqs-1];
60 is $seq->species, undef;
64 # switch on features for the last 2 seqs
65 $seqbuilder->add_wanted_slot('features') if $numseqs == 3;
69 # everything but no sequence, and no features
70 $seqio = Bio::SeqIO->new('-file' => test_input_file('test.genbank'),
71 '-format' => 'GenBank');
73 $seqio->verbose($verbosity);
74 $seqbuilder = $seqio->sequence_builder;
76 $seqbuilder->add_unwanted_slot('seq','features');
80 while ($seq = $seqio->next_seq) {
81 is $seq->accession_number, $loci[$numseqs++];
82 ok scalar($seq->annotation->get_Annotations);
84 is scalar($seq->top_SeqFeatures), 0;
87 is scalar($seq->top_SeqFeatures), $numfeas[$numseqs-1];
89 ok $seq->species->binomial;
93 # switch on features for the last 2 seqs
95 $seqbuilder->add_unwanted_slot(
96 grep { $_ ne 'features'; } $seqbuilder->remove_unwanted_slots
102 # skip sequences less than 100bp or accession like 'NT_*'
103 $seqio = Bio::SeqIO->new('-file' => test_input_file('test.genbank'),
104 '-format' => 'GenBank');
106 $seqio->verbose($verbosity);
107 $seqbuilder = $seqio->sequence_builder;
108 # we could have as well combined the two conditions into one, but we want to
109 # test the implicit AND here
110 $seqbuilder->add_object_condition(sub {
112 return 0 if($h->{'-length'} < 100);
115 $seqbuilder->add_object_condition(sub {
117 return 0 if($h->{'-display_id'} =~ /^NT_/);
124 while ($seq = $seqio->next_seq) {
126 is $seq->accession_number, $loci[$i];
127 ok scalar($seq->annotation->get_Annotations);
128 is scalar($seq->top_SeqFeatures), $numfeas[$i];
129 ok $seq->species->binomial;