File: testformats.pl

package info (click to toggle)
bioperl 1.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 10,784 kB
  • ctags: 4,962
  • sloc: perl: 70,732; xml: 3,279; lisp: 107; makefile: 53
file content (51 lines) | stat: -rw-r--r-- 1,440 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/local/bin/perl -w
use strict;

use Bio::SeqIO;
use Bio::Root::IO;
use Algorithm::Diff qw(diff LCS);
use IO::ScalarArray;
use IO::String;

my %files = ( 
#'test.embl'      => 'embl',
#	      'test.ace'       => 'ace',
	      'test.fasta'     => 'fasta',
#	      'test.game'      => 'game',
	      'test.gcg'       => 'gcg',
#	      'test.genbank'   => 'genbank',
	      'test.raw'       => 'raw',
#	      'test_badlf.gcg' => 'gcg'
	      );

while( my ($file, $type) = each %files ) {
    my $filename = Bio::Root::IO->catfile('t','data',$file);
    print "processing file $filename\n";
    open(FILE, "< $filename") or die("cannot open $filename");
    my @datain = <FILE>;
    my $in = new IO::String(join('', @datain));
    my $seqin = new Bio::SeqIO( -fh => $in,
				-format => $type);
    my $out = new IO::String;
    my $seqout = new Bio::SeqIO( -fh => $out,
				 -format => $type);
    my $seq;
    while( defined($seq = $seqin->next_seq) ) {	
	$seqout->write_seq($seq);
    }
    $seqout->close();
    $seqin->close();
    my $strref = $out->string_ref;
    my @dataout = map { $_."\n"} split(/\n/, $$strref );
    my @diffs = &diff( \@datain, \@dataout);
    foreach my $d ( @diffs ) {
	foreach my $diff ( @$d ) {
	    chomp($diff->[2]);
	    print $diff->[0], $diff->[1], "\n>", $diff->[2], "\n";
	}
    }
    if( @diffs ) {
	print "in is \n", join('', @datain), "\n";
	print "out is \n", join('',@dataout), "\n";	
    }
}