~ubuntu-branches/ubuntu/lucid/bioperl/lucid

« back to all changes in this revision

Viewing changes to t/EMBOSS.t

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2004-04-18 14:24:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040418142411-gr92uexquw4w8liq
Tags: 1.4-1
* New upstream release
* Examples and working code are installed by default to usr/bin,
  this has been moved to usr/share/doc/bioperl/bin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
# -*-Perl-*-
3
 
## Bioperl Test Harness Script for Modules
4
 
## $Id: EMBOSS.t,v 1.6.2.3 2002/03/18 14:31:09 jason Exp $
5
 
 
6
 
# Before `make install' is performed this script should be runnable with
7
 
# `make test'. After `make install' it should work as `perl test.t'
8
 
 
9
 
use strict;
10
 
BEGIN {
11
 
    use vars qw($NTESTS);
12
 
    # to handle systems with no installed Test module
13
 
    # we include the t dir (where a copy of Test.pm is located)
14
 
    # as a fallback
15
 
    eval { require Test; };
16
 
    if( $@ ) {
17
 
        use lib 't';
18
 
    }
19
 
    use Test;
20
 
    $NTESTS = 18;
21
 
    plan tests => $NTESTS }
22
 
 
23
 
use Bio::Factory::EMBOSS;
24
 
use Bio::Root::IO;
25
 
use Bio::SeqIO;
26
 
use Bio::AlignIO;
27
 
my $compseqoutfile = 'dna1.4.compseq';
28
 
my $wateroutfile   = 'cysprot.water';
29
 
my $consoutfile    = 'cysprot.cons';
30
 
END { 
31
 
 
32
 
    foreach ( $Test::ntest..$NTESTS ) { 
33
 
        skip("EMBOSS not installed locally",1);
34
 
    }
35
 
    unlink($compseqoutfile);
36
 
    unlink($wateroutfile);
37
 
    unlink($consoutfile);
38
 
}
39
 
 
40
 
    
41
 
my $verbose = $ENV{'BIOPERLDEBUG'} || -1;
42
 
ok(1);
43
 
 
44
 
## End of black magic.
45
 
##
46
 
## Insert additional test code below but remember to change
47
 
## the print "1..x\n" in the BEGIN block to reflect the
48
 
## total number of tests that will be run. 
49
 
 
50
 
my $factory = new Bio::Factory::EMBOSS(-verbose => $verbose);
51
 
 
52
 
ok($factory);
53
 
my $compseqapp = $factory->program('compseq');
54
 
if( ! $compseqapp ) { 
55
 
    # no EMBOSS installed
56
 
    exit();
57
 
}
58
 
 
59
 
ok($compseqapp);
60
 
my %input = ( '-word' => 4,
61
 
              '-sequence' => Bio::Root::IO->catfile('t',
62
 
                                                   'data',
63
 
                                                   'dna1.fa'),
64
 
              '-outfile' => $compseqoutfile);
65
 
$compseqapp->run(\%input);
66
 
ok(-e $compseqoutfile);
67
 
#if( open(IN, $compseqoutfile) ) {
68
 
#    while(<IN>) { print }
69
 
#}
70
 
 
71
 
my $water = $factory->program('water');
72
 
 
73
 
ok ($water);
74
 
 
75
 
# testing in-memory use of 
76
 
my $in = new Bio::SeqIO(-format => 'fasta', 
77
 
                        -file =>  Bio::Root::IO->catfile('t',
78
 
                                                   'data',
79
 
                                                         'cysprot1a.fa'));
80
 
my $seq = $in->next_seq();
81
 
ok($seq);
82
 
my @amino;
83
 
$in = new Bio::SeqIO(-format => 'fasta', 
84
 
                        -file =>  Bio::Root::IO->catfile('t',
85
 
                                                         'data',
86
 
                                                         'amino.fa'));
87
 
while( my $s = $in->next_seq) {
88
 
    push @amino, $s;
89
 
}
90
 
$water->run({ '-sequencea' => $seq,
91
 
              '-seqall'    => \@amino,
92
 
              '-gapopen'   => '10.0',
93
 
              '-gapextend' => '0.5',
94
 
              '-outfile'   => $wateroutfile});
95
 
 
96
 
ok(-e $wateroutfile);
97
 
 
98
 
my $alnin = new Bio::AlignIO(-format => 'emboss',
99
 
                            -file   => $wateroutfile);
100
 
 
101
 
ok( $alnin);
102
 
my $aln = $alnin->next_aln;
103
 
ok($aln);
104
 
ok($aln->length, 43);
105
 
ok($aln->overall_percentage_identity, 100);
106
 
ok($aln->average_percentage_identity, 100);
107
 
 
108
 
my ($first) = $aln->each_seq();
109
 
ok($first->seq(), 'SCWSFSTTGNVEGQHFISQNKLVSLSEQNLVDCDHECMEYEGE');
110
 
$aln = $alnin->next_aln;
111
 
ok($aln);
112
 
ok($aln->length, 339);
113
 
ok(sprintf("%.2f",$aln->overall_percentage_identity), 33.04);
114
 
ok(sprintf("%.2f",$aln->average_percentage_identity), 40.58);
115
 
 
116
 
my $cons = $factory->program('cons');
117
 
$cons->verbose(0);
118
 
$in = new Bio::AlignIO(-format => 'msf',
119
 
                          -file   => Bio::Root::IO->catfile('t',
120
 
                                                            'data',
121
 
                                                            'cysprot.msf'));
122
 
my $aln2 = $in->next_aln;
123
 
$cons->run({ '-msf'   => $aln2,
124
 
             '-outseq'=> $consoutfile});
125
 
 
126
 
ok(-e $consoutfile);