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