1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 25,
10 -requires_modules => [],
11 -requires_networking => 0,
14 use_ok('Bio::SeqIO::raw');
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');
26 is $seqio_obj->variant, 'multiple';
28 my @methods = qw(next_seq write_seq);
29 foreach my $method (@methods) {
30 can_ok($seqio_obj, $method) ||
31 diag "$method method not implemented for $format";
34 # checking the first sequence object
35 my $seq_obj = $seqio_obj->next_seq();
36 isa_ok($seq_obj, 'Bio::Seq');
37 my %expected = ('seq' => 'MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGL' .
38 'DYRTTDENLKAHEKWGNIVDVVVMKDPRTKRSRGFGFI' .
39 'TYSHSSMIDEAQKSRPHKIDGRVEPKRAVPRQDIDSPN' .
40 'AGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVDNIVI' .
41 'DKETGKKRGFAFVEFDDYDPVDKVVLQKQHQLNGKMVD' .
42 'VKKALPKNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGN' .
43 'QNGGGNWNNGGNNWGNNRGNDNWGNNSFGGGGGGGGGY' .
44 'GGGNNSWGNNNPWDNGNGGGNFGGGGNNWNGGNDFGGY' .
45 'QQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGN' .
49 is ($seq_obj->seq(), $expected{'seq'}, 'sequence');
50 is ($seq_obj->length(), $expected{'length'}, 'length');
53 # checking the second sequence object
54 my $seq_obj2 = $seqio_obj->next_seq();
55 isa_ok($seq_obj2, 'Bio::Seq');
56 my %expected2 = ('seq' => 'MNKQRGTYSEVSLAQDPKRQQRKLKGNKISISGTKQEI' .
57 'FQVELNLQNASSDHQGNDKTYHCKGLLPPPEKLTAEVL' .
58 'GIICIVLMATVLKTIVLIPCIGVLEQNNFSLNRRMQKA' .
59 'RHCGHCPEEWITYSNSCYYIGKERRTWEERVCWPVLRR' .
63 is ($seq_obj2->seq(), $expected2{'seq'}, 'sequence');
64 is ($seq_obj2->length(), $expected2{'length'}, 'length');
69 test_skip(-tests => 2,
70 -requires_modules => [qw(Algorithm::Diff
73 use_ok('Algorithm::Diff', qw(diff LCS));
75 my ($file, $type) = ("test.$format", $format);
76 my $filename = test_input_file($file);
77 print "processing file $filename\n" if $verbose;
78 open my $FILE, '<', $filename or die "Could not read file '$filename': $!\n";
82 my $in = IO::String->new(join('', @datain));
83 my $seqin = Bio::SeqIO->new( -fh => $in,
85 my $out = IO::String->new;
86 my $seqout = Bio::SeqIO->new( -fh => $out,
89 while( defined($seq = $seqin->next_seq) ) {
90 $seqout->write_seq($seq);
94 my $strref = $out->string_ref;
95 my @dataout = map { $_."\n"} split(/\n/, $$strref );
96 my @diffs = &diff( \@datain, \@dataout);
97 is(@diffs, 0, "$format format can round-trip");
99 if(@diffs && $verbose) {
100 use Data::Dumper; # should be safe for 5.005 and greater
101 foreach my $d ( @diffs ) {
102 print STDERR Dumper $d;
103 foreach my $diff ( @$d ) {
105 print $diff->[0], $diff->[1], "\n>", $diff->[2], "\n";
108 print "in is \n", join('', @datain), "\n";
109 print "out is \n", join('',@dataout), "\n";
114 my @seq = qw(MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGLDYRTTDENLKAHEKWGNIVDVV
115 VMKDPRTKRSRGFGFITYSHSSMIDEAQKSRPHKIDGRVEPKRAVPRQDIDSPNAGATVK
116 KLFVGALKDDHDEQSIRDYFQHFGNIVDNIVIDKETGKKRGFAFVEFDDYDPVDKVVLQK
117 QHQLNGKMVDVKKALPKNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGNQNGGGNWNNGGN
118 NWGNNRGNDNWGNNSFGGGGGGGGGYGGGNNSWGNNNPWDNGNGGGNFGGGGNNWNGGND
119 FGGYQQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGNYGNNQGFNNGGNNRRY);
121 $seqio_obj = Bio::SeqIO->new(-file => test_input_file("test2.raw"),
124 is($seqio_obj->variant, 'multiple');
128 while (my $seq = $seqio_obj->next_seq) {
129 is($seq->seq, $seq[$ct]);
135 $seqio_obj = Bio::SeqIO->new(-file => test_input_file("test2.raw"),
136 -format => 'raw-single');
138 is($seqio_obj->variant, 'single');
140 my $seq = $seqio_obj->next_seq;
141 is($seq->seq, join('', @seq));
143 $seqio_obj = Bio::SeqIO->new(-file => test_input_file("test2.raw"),
145 -variant => 'single');
147 is($seqio_obj->variant, 'single');
149 $seq = $seqio_obj->next_seq;
150 is($seq->seq, join('', @seq));