1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 17,
11 -requires_modules => [],
12 -requires_networking => 0,
15 use_ok('Bio::SeqIO::gcg');
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 isa_ok($seq_obj, 'Bio::Seq::RichSeq');
36 my %expected = ('seq' => 'MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGL' .
37 'DYRTTDENLKAHEKWGNIVDVVVMKDPRTKRSRGFGFI' .
38 'TYSHSSMIDEAQKSRPHKIDGRVEPKRAVPRQDIDSPN' .
39 'AGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVDNIVI' .
40 'DKETGKKRGFAFVEFDDYDPVDKVVLQKQHQLNGKMVD' .
41 'VKKALPKNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGN' .
42 'QNGGGNWNNGGNNWGNNRGNDNWGNNSFGGGGGGGGGY' .
43 'GGGNNSWGNNNPWDNGNGGGNFGGGGNNWNGGNDFGGY' .
44 'QQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGN' .
47 'primary_id' => 'roa1_drome',
48 'description' => qr(Rea guano receptor type III),
50 is ($seq_obj->seq(), $expected{'seq'}, 'sequence');
51 is ($seq_obj->length(), $expected{'length'}, 'length');
53 local $TODO = 'possible bug: RichSeq not setting primary_id?';
54 is ($seq_obj->primary_id(), $expected{'primary_id'}, 'primary_id');
56 like ($seq_obj->description(), $expected{'description'}, 'description');
58 # test DOS linefeeds in gcg parser
59 my $str = Bio::SeqIO->new(-file => test_input_file('test_badlf.gcg'),
63 my $seq = $str->next_seq();
64 isa_ok ($seq, 'Bio::SeqI');
65 is(length($seq->seq), $seq->length);
66 print "Sequence 1 of 1 from GCG stream:\n", $seq->seq, "\n" if( $verbose);
72 test_skip(-tests => 4, -requires_modules => [qw(Algorithm::Diff
75 use_ok('Algorithm::Diff');
76 eval "use Algorithm::Diff qw(diff LCS);";
77 use_ok('IO::ScalarArray');
80 my ($file, $type) = ("test.$format", $format);
81 my $filename = test_input_file($file);
82 print "processing file $filename\n" if $verbose;
83 open my $FILE, '<', $filename or die "Could not read file '$filename': $!\n";
87 my $in = new IO::String(join('', @datain));
88 my $seqin = new Bio::SeqIO( -fh => $in,
90 my $out = new IO::String;
91 my $seqout = new Bio::SeqIO( -fh => $out,
94 while( defined($seq = $seqin->next_seq) ) {
95 $seqout->write_seq($seq);
99 my $strref = $out->string_ref;
100 my @dataout = map { $_."\n"} split(/\n/, $$strref );
101 my @diffs = &diff( \@datain, \@dataout);
102 is(@diffs, 0, "$format format can round-trip");
104 if(@diffs && $verbose) {
105 foreach my $d ( @diffs ) {
106 foreach my $diff ( @$d ) {
108 print $diff->[0], $diff->[1], "\n>", $diff->[2], "\n";
111 print "in is \n", join('', @datain), "\n";
112 print "out is \n", join('',@dataout), "\n";