1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 22,
10 -requires_modules => [],
11 -requires_networking => 0,
14 use_ok('Bio::SeqIO::fasta');
17 my $verbose = test_debug();
20 my $seqio_obj = Bio::SeqIO->new(-file => test_input_file("test.$format"),
23 isa_ok($seqio_obj, 'Bio::SeqIO');
25 my @methods = qw(next_seq write_seq);
26 foreach my $method (@methods) {
27 can_ok($seqio_obj, $method) ||
28 diag "$method method not implemented for $format";
31 # checking the first sequence object
32 my $seq_obj = $seqio_obj->next_seq();
33 isa_ok($seq_obj, 'Bio::Seq');
34 my %expected = ('seq' => 'MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGL' .
35 'DYRTTDENLKAHEKWGNIVDVVVMKDPRTKRSRGFGFI' .
36 'TYSHSSMIDEAQKSRPHKIDGRVEPKRAVPRQDIDSPN' .
37 'AGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVDNIVI' .
38 'DKETGKKRGFAFVEFDDYDPVDKVVLQKQHQLNGKMVD' .
39 'VKKALPKNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGN' .
40 'QNGGGNWNNGGNNWGNNRGNDNWGNNSFGGGGGGGGGY' .
41 'GGGNNSWGNNNPWDNGNGGGNFGGGGNNWNGGNDFGGY' .
42 'QQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGN' .
45 'primary_id' => 'roa1_drome',
46 'description' => qr(Rea guano receptor type III),
48 is ($seq_obj->seq(), $expected{'seq'}, 'sequence');
49 is ($seq_obj->length(), $expected{'length'}, 'length');
50 is ($seq_obj->primary_id(), $expected{'primary_id'}, 'primary_id');
51 like ($seq_obj->description(), $expected{'description'}, 'description');
54 # checking the second sequence object
55 my $seq_obj2 = $seqio_obj->next_seq();
56 isa_ok($seq_obj2, 'Bio::Seq');
57 my %expected2 = ('seq' => 'MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGL' .
58 'DYRTTDENLKAHEKWGNIVDVVVMKDPTSTSTSTSTST' .
59 'STSTSTMIDEAQKSRPHKIDGRVEPKRAVPRQDIDSPN' .
60 'AGATVKKLFVGALKDDHDEQSIRDYFQHLLLLLLLDLL' .
61 'LLDLLLLDLLLFVEFDDYDPVDKVVLQKQHQLNGKMVD' .
62 'VKKALPKNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGN' .
63 'QNGGGNWNNGGNNWGNNRGNDNWGNNSFGGGGGGGGGY' .
64 'GGGNNSWGNNNPWDNGNGGGNFGGGGNNWNGGNDFGGY' .
65 'QQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGN' .
68 'primary_id' => 'roa2_drome',
69 'description' => qr(Rea guano ligand),
71 is ($seq_obj2->seq(), $expected2{'seq'}, 'sequence');
72 is ($seq_obj2->length(), $expected2{'length'}, 'length');
73 is ($seq_obj2->primary_id(), $expected2{'primary_id'}, 'primary_id');
74 like ($seq_obj2->description(), $expected2{'description'}, 'description');
78 test_skip(-tests => 4, -requires_modules => [qw(Algorithm::Diff
81 use_ok('Algorithm::Diff');
82 eval "use Algorithm::Diff qw(diff LCS);";
83 use_ok('IO::ScalarArray');
86 my ($file, $type) = ("test.$format", $format);
87 my $filename = test_input_file($file);
88 print "processing file $filename\n" if $verbose;
89 open my $FILE, '<', $filename or die "Could not read file '$filename': $!\n";
93 my $in = new IO::String(join('', @datain));
94 my $seqin = new Bio::SeqIO( -fh => $in,
96 my $out = new IO::String;
97 my $seqout = new Bio::SeqIO( -fh => $out,
100 while( defined($seq = $seqin->next_seq) ) {
101 $seqout->write_seq($seq);
105 my $strref = $out->string_ref;
106 my @dataout = map { $_."\n"} split(/\n/, $$strref );
107 my @diffs = &diff( \@datain, \@dataout);
108 is(@diffs, 0, "$format format can round-trip");
110 if(@diffs && $verbose) {
111 foreach my $d ( @diffs ) {
112 foreach my $diff ( @$d ) {
114 print $diff->[0], $diff->[1], "\n>", $diff->[2], "\n";
117 print "in is \n", join('', @datain), "\n";
118 print "out is \n", join('',@dataout), "\n";
124 # test genbank, gcg, ace against fasta (should throw an exception on each)
126 for my $file (qw(roa1.genbank test.gcg test.ace test.raw)) {
127 my $in = Bio::SeqIO->new(-file => test_input_file($file),
129 throws_ok {$in->next_seq}
130 qr/The sequence does not appear to be FASTA format/, "dies with $file";