1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 22,
11 -requires_modules => [],
12 -requires_networking => 0,
15 use_ok('Bio::SeqIO::fasta');
18 my $verbose = test_debug();
21 my $seqio_obj = Bio::SeqIO->new(-file => test_input_file("test.$format"),
24 isa_ok($seqio_obj, 'Bio::SeqIO');
26 my @methods = qw(next_seq write_seq);
27 foreach my $method (@methods) {
28 can_ok($seqio_obj, $method) ||
29 diag "$method method not implemented for $format";
32 # checking the first sequence object
33 my $seq_obj = $seqio_obj->next_seq();
34 isa_ok($seq_obj, 'Bio::Seq');
35 my %expected = ('seq' => 'MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGL' .
36 'DYRTTDENLKAHEKWGNIVDVVVMKDPRTKRSRGFGFI' .
37 'TYSHSSMIDEAQKSRPHKIDGRVEPKRAVPRQDIDSPN' .
38 'AGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVDNIVI' .
39 'DKETGKKRGFAFVEFDDYDPVDKVVLQKQHQLNGKMVD' .
40 'VKKALPKNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGN' .
41 'QNGGGNWNNGGNNWGNNRGNDNWGNNSFGGGGGGGGGY' .
42 'GGGNNSWGNNNPWDNGNGGGNFGGGGNNWNGGNDFGGY' .
43 'QQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGN' .
46 'primary_id' => 'roa1_drome',
47 'description' => qr(Rea guano receptor type III),
49 is ($seq_obj->seq(), $expected{'seq'}, 'sequence');
50 is ($seq_obj->length(), $expected{'length'}, 'length');
51 is ($seq_obj->primary_id(), $expected{'primary_id'}, 'primary_id');
52 like ($seq_obj->description(), $expected{'description'}, 'description');
55 # checking the second sequence object
56 my $seq_obj2 = $seqio_obj->next_seq();
57 isa_ok($seq_obj2, 'Bio::Seq');
58 my %expected2 = ('seq' => 'MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGL' .
59 'DYRTTDENLKAHEKWGNIVDVVVMKDPTSTSTSTSTST' .
60 'STSTSTMIDEAQKSRPHKIDGRVEPKRAVPRQDIDSPN' .
61 'AGATVKKLFVGALKDDHDEQSIRDYFQHLLLLLLLDLL' .
62 'LLDLLLLDLLLFVEFDDYDPVDKVVLQKQHQLNGKMVD' .
63 'VKKALPKNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGN' .
64 'QNGGGNWNNGGNNWGNNRGNDNWGNNSFGGGGGGGGGY' .
65 'GGGNNSWGNNNPWDNGNGGGNFGGGGNNWNGGNDFGGY' .
66 'QQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGN' .
69 'primary_id' => 'roa2_drome',
70 'description' => qr(Rea guano ligand),
72 is ($seq_obj2->seq(), $expected2{'seq'}, 'sequence');
73 is ($seq_obj2->length(), $expected2{'length'}, 'length');
74 is ($seq_obj2->primary_id(), $expected2{'primary_id'}, 'primary_id');
75 like ($seq_obj2->description(), $expected2{'description'}, 'description');
79 test_skip(-tests => 4, -requires_modules => [qw(Algorithm::Diff
82 use_ok('Algorithm::Diff');
83 eval "use Algorithm::Diff qw(diff LCS);";
84 use_ok('IO::ScalarArray');
87 my ($file, $type) = ("test.$format", $format);
88 my $filename = test_input_file($file);
89 print "processing file $filename\n" if $verbose;
90 open(FILE, "< $filename") or die("cannot open $filename");
92 my $in = new IO::String(join('', @datain));
93 my $seqin = new Bio::SeqIO( -fh => $in,
95 my $out = new IO::String;
96 my $seqout = new Bio::SeqIO( -fh => $out,
99 while( defined($seq = $seqin->next_seq) ) {
100 $seqout->write_seq($seq);
104 my $strref = $out->string_ref;
105 my @dataout = map { $_."\n"} split(/\n/, $$strref );
106 my @diffs = &diff( \@datain, \@dataout);
107 is(@diffs, 0, "$format format can round-trip");
109 if(@diffs && $verbose) {
110 foreach my $d ( @diffs ) {
111 foreach my $diff ( @$d ) {
113 print $diff->[0], $diff->[1], "\n>", $diff->[2], "\n";
116 print "in is \n", join('', @datain), "\n";
117 print "out is \n", join('',@dataout), "\n";
123 # test genbank, gcg, ace against fasta (should throw an exception on each)
125 for my $file (qw(roa1.genbank test.gcg test.ace test.raw)) {
126 my $in = Bio::SeqIO->new(-file => test_input_file($file),
128 throws_ok {$in->next_seq}
129 qr/The sequence does not appear to be FASTA format/, "dies with $file";