~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to t/SeqIO/SeqIO.t

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
    use lib '.';
8
8
    use Bio::Root::Test;
9
9
    
10
 
    test_begin(-tests => 45);
11
 
        
12
 
        use_ok('Bio::SeqIO');
 
10
    test_begin(-tests => 51);
 
11
    
 
12
    use_ok('Bio::SeqIO');
13
13
}
14
14
 
15
15
my $verbose = test_debug();
18
18
# The following files or formats are failing: swiss genbank interpro embl
19
19
 
20
20
foreach my $format (@formats) {
21
 
        print "======== $format ========\n" if $verbose;
22
 
        read_write($format);
 
21
    print "======== $format ========\n" if $verbose;
 
22
    read_write($format);
23
23
}
24
24
 
25
25
sub read_write {
26
 
        my $format = shift;
27
 
        my $seq;
28
 
        my $str = Bio::SeqIO->new(-file=> test_input_file("test.$format"),
29
 
                                                          -format => $format);
30
 
        ok $seq = $str->next_seq();
31
 
        print "Sequence 1 of 2 from $format stream:\n", $seq->seq, "\n\n" if  $verbose;
32
 
        unless ($format eq 'raw') {
33
 
                is $seq->id, 'roa1_drome',"ID for format $format";
34
 
                is $seq->length, 358;
35
 
        }
36
 
        
37
 
        unless ($format eq 'gcg') { # GCG file can contain only one sequence
38
 
                ok $seq = $str->next_seq();
39
 
                print "Sequence 2 of 2 from $format stream:\n", $seq->seq, $seq->seq, "\n" if $verbose;
40
 
        }
41
 
        
42
 
        my $outfile = test_output_file();
43
 
        my $out = Bio::SeqIO->new(-file => ">$outfile",
44
 
                                                          -format => $format);
45
 
        ok $out->write_seq($seq);
46
 
        if ($format eq 'fasta') {
47
 
                my $id_type;
48
 
                ok($id_type = $out->preferred_id_type('accession.version'),
49
 
                        'accession.version');
50
 
        }
51
 
        
52
 
        ok -s $outfile;
 
26
    my $format = shift;
 
27
    my $seq;
 
28
    my $str = Bio::SeqIO->new(-file=> test_input_file("test.$format"),
 
29
                                  -format => $format);
 
30
 
 
31
        is $str->format(), $format;
 
32
 
 
33
    ok $seq = $str->next_seq();
 
34
    print "Sequence 1 of 2 from $format stream:\n", $seq->seq, "\n\n" if  $verbose;
 
35
    unless ($format eq 'raw') {
 
36
        is $seq->id, 'roa1_drome',"ID for format $format";
 
37
        is $seq->length, 358;
 
38
    }
 
39
    
 
40
    unless ($format eq 'gcg') { # GCG file can contain only one sequence
 
41
        ok $seq = $str->next_seq();
 
42
        print "Sequence 2 of 2 from $format stream:\n", $seq->seq, $seq->seq, "\n" if $verbose;
 
43
    }
 
44
    
 
45
    my $outfile = test_output_file();
 
46
    my $out = Bio::SeqIO->new(-file => ">$outfile",
 
47
                              -format => $format);
 
48
    ok $out->write_seq($seq);
 
49
    if ($format eq 'fasta') {
 
50
        my $id_type;
 
51
        ok($id_type = $out->preferred_id_type('accession.version'),
 
52
            'accession.version');
 
53
    }
 
54
    
 
55
    ok -s $outfile;
53
56
}
54
57
 
55
58
# from testformats.pl
85
88
        my $seqout = new Bio::SeqIO( -fh => $out,
86
89
                     -format => $type);
87
90
        my $seq;
88
 
        while( defined($seq = $seqin->next_seq) ) {     
 
91
        while( defined($seq = $seqin->next_seq) ) {
89
92
        $seqout->write_seq($seq);
90
93
        }
91
94
        $seqout->close();
103
106
                }
104
107
            }
105
108
            print "in is \n", join('', @datain), "\n";
106
 
            print "out is \n", join('',@dataout), "\n"; 
 
109
            print "out is \n", join('',@dataout), "\n";
107
110
        }
108
111
    }
109
112
}
132
135
 
133
136
throws_ok {
134
137
    Bio::SeqIO->new(-file => 'foo.bar');
135
 
} qr/Can not open 'foo.bar' for reading: No such file or directory/,
 
138
} qr/Can not open 'foo.bar' for reading:/,
136
139
    'Must pass a real file';
137
140