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 my $FILE, '<', $filename or die "Could not read file '$filename': $!\n";
83 my $in = IO::String->new(join('', @datain));
84 my $seqin = Bio::SeqIO->new( -fh => $in,
86 my $out = IO::String->new;
87 my $seqout = Bio::SeqIO->new( -fh => $out,
90 while( defined($seq = $seqin->next_seq) ) {
91 $seqout->write_seq($seq);
95 my $strref = $out->string_ref;
96 my @dataout = map { $_."\n"} split(/\n/, $$strref );
97 my @diffs = &diff( \@datain, \@dataout);
98 is(@diffs, 0, "$format format can round-trip");
100 if(@diffs && $verbose) {
101 use Data::Dumper; # should be safe for 5.005 and greater
102 foreach my $d ( @diffs ) {
103 print STDERR Dumper $d;
104 foreach my $diff ( @$d ) {
106 print $diff->[0], $diff->[1], "\n>", $diff->[2], "\n";
109 print "in is \n", join('', @datain), "\n";
110 print "out is \n", join('',@dataout), "\n";
115 my @seq = qw(MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGLDYRTTDENLKAHEKWGNIVDVV
116 VMKDPRTKRSRGFGFITYSHSSMIDEAQKSRPHKIDGRVEPKRAVPRQDIDSPNAGATVK
117 KLFVGALKDDHDEQSIRDYFQHFGNIVDNIVIDKETGKKRGFAFVEFDDYDPVDKVVLQK
118 QHQLNGKMVDVKKALPKNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGNQNGGGNWNNGGN
119 NWGNNRGNDNWGNNSFGGGGGGGGGYGGGNNSWGNNNPWDNGNGGGNFGGGGNNWNGGND
120 FGGYQQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGNYGNNQGFNNGGNNRRY);
122 $seqio_obj = Bio::SeqIO->new(-file => test_input_file("test2.raw"),
125 is($seqio_obj->variant, 'multiple');
129 while (my $seq = $seqio_obj->next_seq) {
130 is($seq->seq, $seq[$ct]);
136 $seqio_obj = Bio::SeqIO->new(-file => test_input_file("test2.raw"),
137 -format => 'raw-single');
139 is($seqio_obj->variant, 'single');
141 my $seq = $seqio_obj->next_seq;
142 is($seq->seq, join('', @seq));
144 $seqio_obj = Bio::SeqIO->new(-file => test_input_file("test2.raw"),
146 -variant => 'single');
148 is($seqio_obj->variant, 'single');
150 $seq = $seqio_obj->next_seq;
151 is($seq->seq, join('', @seq));