File: EMBOSS.t

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 (126 lines) | stat: -rw-r--r-- 3,120 bytes parent folder | download
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

# -*-Perl-*-
## Bioperl Test Harness Script for Modules
## $Id: EMBOSS.t,v 1.6.2.3 2002/03/18 14:31:09 jason Exp $

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.t'

use strict;
BEGIN {
    use vars qw($NTESTS);
    # to handle systems with no installed Test module
    # we include the t dir (where a copy of Test.pm is located)
    # as a fallback
    eval { require Test; };
    if( $@ ) {
	use lib 't';
    }
    use Test;
    $NTESTS = 18;
    plan tests => $NTESTS }

use Bio::Factory::EMBOSS;
use Bio::Root::IO;
use Bio::SeqIO;
use Bio::AlignIO;
my $compseqoutfile = 'dna1.4.compseq';
my $wateroutfile   = 'cysprot.water';
my $consoutfile    = 'cysprot.cons';
END { 

    foreach ( $Test::ntest..$NTESTS ) { 
	skip("EMBOSS not installed locally",1);
    }
    unlink($compseqoutfile);
    unlink($wateroutfile);
    unlink($consoutfile);
}

    
my $verbose = $ENV{'BIOPERLDEBUG'} || -1;
ok(1);

## End of black magic.
##
## Insert additional test code below but remember to change
## the print "1..x\n" in the BEGIN block to reflect the
## total number of tests that will be run. 

my $factory = new Bio::Factory::EMBOSS(-verbose => $verbose);

ok($factory);
my $compseqapp = $factory->program('compseq');
if( ! $compseqapp ) { 
    # no EMBOSS installed
    exit();
}

ok($compseqapp);
my %input = ( '-word' => 4,
	      '-sequence' => Bio::Root::IO->catfile('t',
						   'data',
						   'dna1.fa'),
	      '-outfile' => $compseqoutfile);
$compseqapp->run(\%input);
ok(-e $compseqoutfile);
#if( open(IN, $compseqoutfile) ) {
#    while(<IN>) { print }
#}

my $water = $factory->program('water');

ok ($water);

# testing in-memory use of 
my $in = new Bio::SeqIO(-format => 'fasta', 
			-file =>  Bio::Root::IO->catfile('t',
						   'data',
							 'cysprot1a.fa'));
my $seq = $in->next_seq();
ok($seq);
my @amino;
$in = new Bio::SeqIO(-format => 'fasta', 
			-file =>  Bio::Root::IO->catfile('t',
							 'data',
							 'amino.fa'));
while( my $s = $in->next_seq) {
    push @amino, $s;
}
$water->run({ '-sequencea' => $seq,
	      '-seqall'    => \@amino,
	      '-gapopen'   => '10.0',
	      '-gapextend' => '0.5',
	      '-outfile'   => $wateroutfile});

ok(-e $wateroutfile);

my $alnin = new Bio::AlignIO(-format => 'emboss',
			    -file   => $wateroutfile);

ok( $alnin);
my $aln = $alnin->next_aln;
ok($aln);
ok($aln->length, 43);
ok($aln->overall_percentage_identity, 100);
ok($aln->average_percentage_identity, 100);

my ($first) = $aln->each_seq();
ok($first->seq(), 'SCWSFSTTGNVEGQHFISQNKLVSLSEQNLVDCDHECMEYEGE');
$aln = $alnin->next_aln;
ok($aln);
ok($aln->length, 339);
ok(sprintf("%.2f",$aln->overall_percentage_identity), 33.04);
ok(sprintf("%.2f",$aln->average_percentage_identity), 40.58);

my $cons = $factory->program('cons');
$cons->verbose(0);
$in = new Bio::AlignIO(-format => 'msf',
			  -file   => Bio::Root::IO->catfile('t',
							    'data',
							    'cysprot.msf'));
my $aln2 = $in->next_aln;
$cons->run({ '-msf'   => $aln2,
	     '-outseq'=> $consoutfile});

ok(-e $consoutfile);