1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 25,
11 -requires_modules => [],
12 -requires_networking => 0,
15 use_ok('Bio::SeqIO::raw');
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');
27 is $seqio_obj->variant, 'multiple';
29 my @methods = qw(next_seq write_seq);
30 foreach my $method (@methods) {
31 can_ok($seqio_obj, $method) ||
32 diag "$method method not implemented for $format";
35 # checking the first sequence object
36 my $seq_obj = $seqio_obj->next_seq();
37 isa_ok($seq_obj, 'Bio::Seq');
38 my %expected = ('seq' => 'MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGL' .
39 'DYRTTDENLKAHEKWGNIVDVVVMKDPRTKRSRGFGFI' .
40 'TYSHSSMIDEAQKSRPHKIDGRVEPKRAVPRQDIDSPN' .
41 'AGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVDNIVI' .
42 'DKETGKKRGFAFVEFDDYDPVDKVVLQKQHQLNGKMVD' .
43 'VKKALPKNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGN' .
44 'QNGGGNWNNGGNNWGNNRGNDNWGNNSFGGGGGGGGGY' .
45 'GGGNNSWGNNNPWDNGNGGGNFGGGGNNWNGGNDFGGY' .
46 'QQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGN' .
50 is ($seq_obj->seq(), $expected{'seq'}, 'sequence');
51 is ($seq_obj->length(), $expected{'length'}, 'length');
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' => 'MNKQRGTYSEVSLAQDPKRQQRKLKGNKISISGTKQEI' .
58 'FQVELNLQNASSDHQGNDKTYHCKGLLPPPEKLTAEVL' .
59 'GIICIVLMATVLKTIVLIPCIGVLEQNNFSLNRRMQKA' .
60 'RHCGHCPEEWITYSNSCYYIGKERRTWEERVCWPVLRR' .
64 is ($seq_obj2->seq(), $expected2{'seq'}, 'sequence');
65 is ($seq_obj2->length(), $expected2{'length'}, 'length');
70 test_skip(-tests => 2,
71 -requires_modules => [qw(Algorithm::Diff
74 use_ok('Algorithm::Diff', qw(diff LCS));
76 my ($file, $type) = ("test.$format", $format);
77 my $filename = test_input_file($file);
78 print "processing file $filename\n" if $verbose;
79 open(FILE, "< $filename") or die("cannot open $filename");
81 my $in = IO::String->new(join('', @datain));
82 my $seqin = Bio::SeqIO->new( -fh => $in,
84 my $out = IO::String->new;
85 my $seqout = Bio::SeqIO->new( -fh => $out,
88 while( defined($seq = $seqin->next_seq) ) {
89 $seqout->write_seq($seq);
93 my $strref = $out->string_ref;
94 my @dataout = map { $_."\n"} split(/\n/, $$strref );
95 my @diffs = &diff( \@datain, \@dataout);
96 is(@diffs, 0, "$format format can round-trip");
98 if(@diffs && $verbose) {
99 use Data::Dumper; # should be safe for 5.005 and greater
100 foreach my $d ( @diffs ) {
101 print STDERR Dumper $d;
102 foreach my $diff ( @$d ) {
104 print $diff->[0], $diff->[1], "\n>", $diff->[2], "\n";
107 print "in is \n", join('', @datain), "\n";
108 print "out is \n", join('',@dataout), "\n";
113 my @seq = qw(MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGLDYRTTDENLKAHEKWGNIVDVV
114 VMKDPRTKRSRGFGFITYSHSSMIDEAQKSRPHKIDGRVEPKRAVPRQDIDSPNAGATVK
115 KLFVGALKDDHDEQSIRDYFQHFGNIVDNIVIDKETGKKRGFAFVEFDDYDPVDKVVLQK
116 QHQLNGKMVDVKKALPKNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGNQNGGGNWNNGGN
117 NWGNNRGNDNWGNNSFGGGGGGGGGYGGGNNSWGNNNPWDNGNGGGNFGGGGNNWNGGND
118 FGGYQQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGNYGNNQGFNNGGNNRRY);
120 $seqio_obj = Bio::SeqIO->new(-file => test_input_file("test2.raw"),
123 is($seqio_obj->variant, 'multiple');
127 while (my $seq = $seqio_obj->next_seq) {
128 is($seq->seq, $seq[$ct]);
134 $seqio_obj = Bio::SeqIO->new(-file => test_input_file("test2.raw"),
135 -format => 'raw-single');
137 is($seqio_obj->variant, 'single');
139 my $seq = $seqio_obj->next_seq;
140 is($seq->seq, join('', @seq));
142 $seqio_obj = Bio::SeqIO->new(-file => test_input_file("test2.raw"),
144 -variant => 'single');
146 is($seqio_obj->variant, 'single');
148 $seq = $seqio_obj->next_seq;
149 is($seq->seq, join('', @seq));