1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 137);
13 my $verbosity = test_debug;
15 my ($seqio, $seq); # predeclare variables for strict
18 ok $seqio = Bio::SeqIO->new('-file' => test_input_file('test.genbank'),
19 '-format' => 'GenBank');
20 $seqio->verbose($verbosity);
23 my @loci = qw(U63596 U63595 M37762 NT_010368 L26462);
24 my @numfeas = (3,1,6,3,26);
26 while ($seq = $seqio->next_seq) {
27 is $seq->accession_number, $loci[$numseqs++];
28 ok $seq->annotation->get_Annotations;
29 is scalar($seq->top_SeqFeatures), $numfeas[$numseqs-1];
30 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;
65 # switch on features for the last 2 seqs
66 $seqbuilder->add_wanted_slot('features') if $numseqs == 3;
70 # everything but no sequence, and no features
71 $seqio = Bio::SeqIO->new('-file' => test_input_file('test.genbank'),
72 '-format' => 'GenBank');
74 $seqio->verbose($verbosity);
75 $seqbuilder = $seqio->sequence_builder;
77 $seqbuilder->add_unwanted_slot('seq','features');
81 while ($seq = $seqio->next_seq) {
82 is $seq->accession_number, $loci[$numseqs++];
83 ok scalar($seq->annotation->get_Annotations);
85 is scalar($seq->top_SeqFeatures), 0;
88 is scalar($seq->top_SeqFeatures), $numfeas[$numseqs-1];
90 ok $seq->species->binomial;
94 # switch on features for the last 2 seqs
96 $seqbuilder->add_unwanted_slot(
97 grep { $_ ne 'features'; } $seqbuilder->remove_unwanted_slots
103 # skip sequences less than 100bp or accession like 'NT_*'
104 $seqio = Bio::SeqIO->new('-file' => test_input_file('test.genbank'),
105 '-format' => 'GenBank');
107 $seqio->verbose($verbosity);
108 $seqbuilder = $seqio->sequence_builder;
109 # we could have as well combined the two conditions into one, but we want to
110 # test the implicit AND here
111 $seqbuilder->add_object_condition(sub {
113 return 0 if($h->{'-length'} < 100);
116 $seqbuilder->add_object_condition(sub {
118 return 0 if($h->{'-display_id'} =~ /^NT_/);
125 while ($seq = $seqio->next_seq) {
127 is $seq->accession_number, $loci[$i];
128 ok scalar($seq->annotation->get_Annotations);
129 is scalar($seq->top_SeqFeatures), $numfeas[$i];
130 ok $seq->species->binomial;