Tools/Run/Alignment/TCoffee.pm

filter: Statementstmt 28.3% 74 / 261 Branchbran 12.2% 13 / 106 Conditioncond 0.0% 0 / 41 MC/DCmcdc 0.0% 0 / 26 Subroutinesub 70.3% 19 / 27 Podpod 100% 10 / 10 totaltotal 24.6% 116 / 471 SCAR 79.2
CC
74
Cov
21%
_setinput
552.0
_run
380.0
_setparams
132.0
CRAP 2740.8
↑ Summary Installer/TCoffee.pm »
1 package Bio::Tools::Run::Alignment::TCoffee;
2 2 $Bio::Tools::Run::Alignment::TCoffee::VERSION = '1.7.2';
3 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 use vars qw($AUTOLOAD @ISA $PROGRAM_NAME $PROGRAM_DIR %DEFAULTS
8 @TCOFFEE_PARAMS @TCOFFEE_SWITCHES @OTHER_SWITCHES %OK_FIELD
9 2 ▶ );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Bio::Seq;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Bio::SeqIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Bio::SimpleAlign;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Bio::AlignIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use Bio::Root::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Bio::Factory::ApplicationFactoryI;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 2 @ISA = qw(Bio::Tools::Run::WrapperBase
21 Bio::Factory::ApplicationFactoryI);
22  
23 # ABSTRACT: Object for the calculation of a multiple sequence alignment from a set of unaligned sequences or alignments using the TCoffee program
24 # AUTHOR: Jason Stajich <jason@bioperl.org>
25 # AUTHOR: Peter Schattner <schattner@alum.mit.edu>
26 # OWNER: Jason Stajich <jason@bioperl.org>
27 # OWNER: Peter Schattner <schattner@alum.mit.edu>
28 # LICENSE: Perl_5
29  
30  
31 # You will need to enable TCoffee to find the tcoffee program. This can be done
32 # in (at least) twp ways:
33 # 1. define an environmental variable TCOFFEE:
34 # export TCOFFEEDIR=/home/progs/tcoffee or
35 # 2. include a definition of an environmental variable TCOFFEEDIR
36 # in every script that will
37 # use Bio::Tools::Run::Alignment::TCoffee.pm.
38 # BEGIN {$ENV{TCOFFEEDIR} = '/home/progs/tcoffee'; }
39  
40 BEGIN {
41 2 ▶ $PROGRAM_NAME = 't_coffee';
Subroutine BEGIN: called CC=2 SCAR=6.9
42 2 $PROGRAM_DIR = $ENV{'TCOFFEEDIR'};
43 2 %DEFAULTS = ( 'MATRIX' => 'blosum',
44 'OUTPUT' => 'clustalw',
45 'AFORMAT'=> 'msf',
46 'METHODS' => [qw(lalign_id_pair clustalw_pair)]
47 );
48  
49  
50 2 @TCOFFEE_PARAMS = qw(IN TYPE PARAMETERS DO_NORMALISE EXTEND
51 DP_MODE KTUPLE NDIAGS DIAG_MODE SIM_MATRIX
52 MATRIX GAPOPEN GAPEXT COSMETIC_PENALTY TG_MODE
53 WEIGHT SEQ_TO_ALIGN NEWTREE USETREE TREE_MODE
54 OUTFILE OUTPUT CASE CPU OUT_LIB OUTORDER SEQNOS
55 RUN_NAME CONVERT
56 );
57  
58 2 @TCOFFEE_SWITCHES = qw(QUICKTREE);
59  
60 2 @OTHER_SWITCHES = qw(QUIET ALIGN KEEPDND);
61  
62 # Authorize attribute fields
63 2 foreach my $attr ( @TCOFFEE_PARAMS, @TCOFFEE_SWITCHES, @OTHER_SWITCHES ) {
64 66 $OK_FIELD{$attr}++; }
65 }
66  
67  
68 sub program_name {
69 6 ▶ return $PROGRAM_NAME;
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
70 }
71  
72  
73 sub program_dir {
74 3 ▶ return $PROGRAM_DIR;
Subroutine program_dir: called CC=1 SCAR=0.0
Pod documented
75 }
76  
77 sub new {
78 1 ▶ my ($class,@args) = @_;
Subroutine new: called CC=6 SCAR=22.4
Pod documented
79 1 my $self = $class->SUPER::new(@args);
80 1 my ($attr, $value);
81  
82 1 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 1 1
83 0 $attr = shift @args;
84 0 $value = shift @args;
85 0 ▶ next if( $attr =~ /^-/); # don't want named parameters
Branch: 1 branch
BranchTrueFalseTotal
if $attr =~ /^-/ 0 0 0
86 0 $self->$attr($value);
87 }
88 1 ▶ $self->matrix($DEFAULTS{'MATRIX'}) unless( $self->matrix );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->matrix 1 0 1
89 1 ▶ $self->output($DEFAULTS{'OUTPUT'}) unless( $self->output );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->output 1 0 1
90 1 ▶ $self->methods($DEFAULTS{'METHODS'}) unless $self->methods;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->methods 1 0 1
91 # $self->aformat($DEFAULTS{'AFORMAT'}) unless $self->aformat;
92  
93 1 return $self;
94 }
95  
96 sub AUTOLOAD {
97 7 ▶ my $self = shift;
Subroutine AUTOLOAD: called CC=4 SCAR=14.0
98 7 my $attr = $AUTOLOAD;
99 7 $attr =~ s/.*:://;
100 7 $attr = uc $attr;
101 # aliasing
102 7 ▶ $attr = 'OUTFILE' if $attr eq 'OUTFILE_NAME';
Branch: 1 branch
BranchTrueFalseTotal
if $attr eq "OUTFILE_NAME" 0 7 7
103 7 ▶ $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $Bio::Tools::Run::Alignment::TCoffee::OK_FIELD{$attr} 0 7 7
104  
105 7 ▶ $self->{$attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 3 4 7
106 7 return $self->{$attr};
107 }
108  
109  
110 sub error_string{
111 0 ▶ my ($self,$value) = @_;
Subroutine error_string: not called CC=2 SCAR=17.9
Pod documented
112 0 ▶ if( defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
113 0 $self->{'error_string'} = $value;
114 }
115 0 return $self->{'error_string'};
116  
117 }
118  
119  
120 sub version {
121 1 ▶ my ($self) = @_;
Subroutine version: called CC=3 SCAR=18.1
Pod documented
122 1 my $exe;
123 1 ▶ return undef unless $exe = $self->executable;
Branch: 1 branch
BranchTrueFalseTotal
unless $exe = $self->executable 0 0 0
124 0 my $string = `$exe -quiet=stdout 2>&1` ;
125 0 $string =~ /Version_([\d.]+)/;
126 0 ▶ return $1 || undef;
Condition0%0/2
$1 || undef
l!l
00
MC/DC0%0/1
$1 || undef
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
127  
128 }
129  
130  
131 sub run{
132 0 ▶ my ($self,@args) = @_;
Subroutine run: not called CC=3 SCAR=24.8
Pod documented
133 0 my ($type,$seq,$profile) = $self->_rearrange([qw(TYPE
134 SEQ
135 PROFILE)],
136 @args);
137 0 ▶ if( $type =~ /align/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type =~ /align/i) { } 0 0 0
elsif ($type =~ /profile/i) { } 0 0 0
138 0 return $self->align($seq);
139 } elsif( $type =~ /profile/i ) {
140 0 return $self->profile_align($profile,$seq);
141 } else {
142 0 $self->warn("unrecognized alignment type $type\n");
143 }
144 0 return undef;
145 }
146  
147  
148 sub align {
149 0 ▶ my ($self,$input) = @_;
Subroutine align: not called CC=2 SCAR=17.9
Pod documented
150 # Create input file pointer
151 0 $self->io->_io_cleanup();
152 0 my ($infilename,$type) = $self->_setinput($input);
153 0 ▶ if (!$infilename) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($infilename) 0 0 0
154 0 $self->throw("Bad input data or less than 2 sequences in $input !");
155 }
156  
157 0 my $param_string = $self->_setparams();
158  
159 # run tcoffee
160 0 return $self->_run('align', [$infilename,$type], $param_string);
161 }
162  
163 #################################################
164  
165  
166 sub profile_align {
167 0 ▶ my $self = shift;
Subroutine profile_align: not called CC=5 SCAR=34.0
Pod documented
168 0 my $input1 = shift;
169 0 my $input2 = shift;
170  
171 0 my ($temp,$infilename1,$infilename2,$type1,$type2,$input,$seq);
172  
173 0 $self->io->_io_cleanup();
174 # Create input file pointers
175 0 ($infilename1,$type1) = $self->_setinput($input1);
176 0 ($infilename2,$type2) = $self->_setinput($input2);
177 0 ▶ unless ($type1) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type1) 0 0 0
178 0 $self->throw("Unknown type for first argument");
179 }
180 0 ▶ unless ($type2) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type2) 0 0 0
181 0 $self->throw("Unknown type for second argument")
182 }
183  
184 0 ▶ if (!$infilename1 || !$infilename2) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($infilename1 and $infilename2) 0 0 0
Condition0%0/3
$infilename1 and $infilename2
!ll&&!rl&&r
000
MC/DC0%0/2
$infilename1 and $infilename2
$infilename1 $infilename2
Truth table0%0/3
A and B
A= $infilename1B= $infilename2
ABresult
0X0
100
111
185 0 $self->throw("Bad input data: $input1 or $input2 !");
186 }
187  
188 0 my $param_string = $self->_setparams();
189 # run tcoffee
190 0 my $aln = $self->_run('profile-aln',
191 [$infilename1,$type1],
192 [$infilename2,$type2],
193 $param_string)
194 ;
195 }
196 #################################################
197  
198  
199 sub _run {
200 0 ▶ my ($infilename, $infile1,$infile2) = ('','','');
Subroutine _run: not called CC=19 SCAR=59.4
201 0 my $self = shift;
202 0 my $command = shift;
203 0 my $instring;
204 0 ▶ if ($command =~ /align/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command =~ /align/) 0 0 0
205 0 my $infile = shift ;
206 0 my $type;
207 0 ($infilename,$type) = @$infile;
208 0 $instring = '-in='.join(',',($infilename, 'X'.$self->matrix,
209 $self->methods));
210 }
211 0 ▶ if ($command =~ /profile/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command =~ /profile/) 0 0 0
212 0 my $in1 = shift ;
213 0 my $in2 = shift ;
214 0 my ($type1,$type2);
215 0 ($infile1,$type1) = @$in1;
216 0 ($infile2,$type2) = @$in2;
217 # in later versions (tested on 5.72 and 7.54) the API for profile
218 # alignment changed. This attempts to do the right thing for older
219 # versions but corrects for newer ones
220 0 ▶ if ($self->version && $self->version < 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->version and $self->version < 5) { } 0 0 0
Condition0%0/3
$self->version and $self->version < 5
!ll&&!rl&&r
000
MC/DC0%0/2
$self->version and $self->version < 5
$self->version $self->version < 5
Truth table0%0/3
A and B
A= $self->versionB= $self->version < 5
ABresult
0X0
100
111
221 # this breaks severely on newer TCoffee (>= v5)
222 0 ▶ unless (($self->matrix =~ /none/i) || ($self->matrix =~ /null/i) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->matrix =~ /none/i or $self->matrix =~ /null/i) { } 0 0 0
Condition0%0/3
$self->matrix =~ /none/i or $self->matrix =~ /null/i
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->matrix =~ /none/i or $self->matrix =~ /null/i
$self->matrix =~ /none/i $self->matrix =~ /null/i
Truth table0%0/3
A or B
A= $self->matrix =~ /none/iB= $self->matrix =~ /null/i
ABresult
1X1
011
000
223 $instring = '-in='.join(',',
224 ($type2.$infile2),
225 'X'.$self->matrix,
226 0 (map {'M'.$_} $self->methods)
227 );
228 0 $instring .= ' -profile='.$infile1;
229 } else {
230 $instring = '-in='.join(',',(
231 $type1.$infile1,
232 $type2.$infile2,
233 0 (map {'M'.$_} $self->methods)
234 )
235 );
236 }
237 } else {
238 0 ▶ if ($type2 eq 'S') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type2 eq 'S') { } 0 0 0
239 # second infile is a sequence, not an alignment
240 0 $instring .= ' -profile='.join(',',$infile1);
241 0 $instring .= ' -seq='.join(',',$infile2);
242 } else {
243 0 $instring .= ' -profile='.join(',',$infile1,$infile2);
244 }
245 0 ▶ $instring .= ' -matrix='.$self->matrix unless (($self->matrix =~ /none/i) || ($self->matrix =~ /null/i)) ;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->matrix =~ /none/i or $self->matrix =~ /null/i 0 0 0
Condition0%0/3
$self->matrix =~ /none/i or $self->matrix =~ /null/i
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->matrix =~ /none/i or $self->matrix =~ /null/i
$self->matrix =~ /none/i $self->matrix =~ /null/i
Truth table0%0/3
A or B
A= $self->matrix =~ /none/iB= $self->matrix =~ /null/i
ABresult
1X1
011
000
246 0 ▶ $instring .= ' -method='.join(',',$self->methods) if ($self->methods) ;
Branch: 1 branch
BranchTrueFalseTotal
if $self->methods 0 0 0
247 }
248 }
249 0 my $param_string = shift;
250 # my ($paramfh,$parameterFile) = $self->io->tempfile;
251 # print $paramfh ( "$instring\n-output=gcg$param_string") ;
252 # close($paramfh);
253 # my $commandstring = "t_coffee -output=gcg -parameters $parameterFile" ; ##MJL
254  
255 0 my $commandstring = $self->executable." $instring $param_string";
256  
257 #$self->debug( "tcoffee command = $commandstring \n");
258  
259 0 my $status = system($commandstring);
260 0 my $outfile = $self->outfile();
261  
262 0 ▶ if( !-e $outfile || -z $outfile ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not -e $outfile or -z $outfile) 0 0 0
Condition0%0/3
not -e $outfile or -z $outfile
l!l&&r!l&&!r
000
MC/DC0%0/2
not -e $outfile or -z $outfile
not -e $outfile -z $outfile
Truth table0%0/3
not(A) or B
A= not -e $outfileB= -z $outfile
ABresult
1X1
011
000
263 0 $self->warn( "TCoffee call crashed: $? [command $commandstring]\n");
264 0 return undef;
265 }
266  
267 # retrieve alignment (Note: MSF format for AlignIO = GCG format of
268 # tcoffee)
269  
270 0 my $in = Bio::AlignIO->new('-file' => $outfile, '-format' =>
271 $self->output);
272 0 my $aln = $in->next_aln();
273  
274 # Replace file suffix with dnd to find name of dendrogram file(s) to delete
275 0 ▶ if( ! $self->keepdnd ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->keepdnd) 0 0 0
276 0 foreach my $f ( $infilename, $infile1, $infile2 ) {
277 0 ▶ next if( !defined $f || $f eq '');
Branch: 1 branch
BranchTrueFalseTotal
if not defined $f or $f eq "" 0 0 0
Condition0%0/3
not defined $f or $f eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $f or $f eq ""
not defined $f $f eq ""
Truth table0%0/3
not(A) or B
A= not defined $fB= $f eq ""
ABresult
1X1
011
000
278 0 $f =~ s/\.[^\.]*$// ;
279 # because TCoffee writes these files to the CWD
280 0 ▶ if( $Bio::Root::IO::PATHSEP ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Bio::Root::IO::PATHSEP) { } 0 0 0
281 0 my @line = split(/$Bio::Root::IO::PATHSEP/, $f);
282 0 $f = pop @line;
283 } else {
284 0 (undef, undef, $f) = File::Spec->splitpath($f);
285 }
286 0 ▶ unlink $f .'.dnd' if( $f ne '' );
Branch: 1 branch
BranchTrueFalseTotal
if $f ne "" 0 0 0
287 }
288 }
289 0 return $aln;
290 }
291  
292  
293  
294 sub _setinput {
295 0 ▶ my ($self,$input) = @_;
Subroutine _setinput: not called CC=23 SCAR=63.1
296 0 my ($infilename, $seq, $temp, $tfh);
297 # If $input is not a reference it better be the name of a
298 # file with the sequence/ alignment data...
299 0 my $type = '';
300 0 ▶ if (! ref $input) {
Branch: 4 branches
BranchTrueFalseTotal
if (not ref $input) { } 0 0 0
elsif (ref($input) =~ /ARRAY/i) { } 0 0 0
elsif ($input->isa('Bio::Align::AlignI')) { } 0 0 0
elsif ($input->isa('Bio::PrimarySeqI')) { } 0 0 0
301 # check that file exists or throw
302 0 $infilename = $input;
303 0 ▶ unless (-e $input) {return 0;}
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $input) 0 0 0
304 # let's peek and guess
305 0 ▶ open(my $IN,$infilename) || $self->throw("Cannot open $infilename");
Branch: 1 branch
BranchTrueFalseTotal
open my $IN, $infilename or $self->throw("Cannot open $infilename") 0 0 0
306 0 my $header = <$IN>;
307 0 ▶ if( $header =~ /^\s+\d+\s+\d+/ ||
Branch: 1 branch
BranchTrueFalseTotal
if ($header =~ /^\s+\d+\s+\d+/ or $header =~ /Pileup/i or $header =~ /clustal/i) 0 0 0
Condition0%0/6
$header =~ /^\s+\d+\s+\d+/ or $header =~ /Pileup/i or $header =~ /clustal/i
l!l&&r!l&&!r
000
$header =~ /^\s+\d+\s+\d+/ or $header =~ /Pileup/i
l!l&&r!l&&!r
000
MC/DC0%0/3
$header =~ /^\s+\d+\s+\d+/ or $header =~ /Pileup/i or $header =~ /clustal/i
$header =~ /^\s+\d+\s+\d+/ $header =~ /Pileup/i $header =~ /clustal/i
Truth table0%0/4
A or B or C
A= $header =~ /^\s+\d+\s+\d+/B= $header =~ /Pileup/iC= $header =~ /clustal/i
ABCresult
1XX1
01X1
0011
0000
308 $header =~ /Pileup/i ||
309 $header =~ /clustal/i ) { # phylip
310 0 $type = 'A';
311 }
312  
313 # On some systems, having filenames with / in them (ie. a file in a
314 # directory) causes t-coffee to completely fail. It warns on all systems.
315 # The -no_warning option solves this, but there is still some strange
316 # bug when doing certain profile-related things. This is magically solved
317 # by copying the profile file to a temp file in the current directory, so
318 # it its filename supplied to t-coffee contains no /
319 # (It's messy here - I just do this to /all/ input files to most easily
320 # catch all variants of providing a profile - it may only be the last
321 # form (isa("Bio::PrimarySeqI")) that causes a problem?)
322  
323 0 my (undef, undef, $adjustedfilename) = File::Spec->splitpath($infilename);
324 0 ▶ if ($adjustedfilename ne $infilename) {
Branch: 1 branch
BranchTrueFalseTotal
if ($adjustedfilename ne $infilename) 0 0 0
325 0 my ($fh, $tempfile) = $self->io->tempfile(-dir => cwd());
326 0 seek($IN, 0, 0);
327 0 ▶ while (<$IN>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $IN)) 0 0 0
328 0 print $fh $_;
329 }
330 0 close($fh);
331 0 (undef, undef, $tempfile) = File::Spec->splitpath($tempfile);
332 0 $infilename = $tempfile;
333 0 $type = 'S';
334 }
335  
336 0 close($IN);
337 0 return ($infilename,$type);
338 } elsif (ref($input) =~ /ARRAY/i ) {
339 # $input may be an array of BioSeq objects...
340 # Open temporary file for both reading & writing of array
341 0 ($tfh,$infilename) = $self->io->tempfile(-dir => cwd());
342 0 (undef, undef, $infilename) = File::Spec->splitpath($infilename);
343 0 ▶ if( ! ref($input->[0]) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not ref $input->[0]) { } 0 0 0
elsif ($input->[0]->isa('Bio::PrimarySeqI')) { } 0 0 0
elsif ($input->[0]->isa('Bio::Align::AlignI')) { } 0 0 0
344 0 $self->warn("passed an array ref which did not contain objects to _setinput");
345 0 return undef;
346 } elsif( $input->[0]->isa('Bio::PrimarySeqI') ) {
347 0 $temp = Bio::SeqIO->new('-fh' => $tfh,
348 '-format' => 'fasta');
349 0 my $ct = 1;
350 0 foreach $seq (@$input) {
351 0 ▶ return 0 unless ( ref($seq) &&
Branch: 1 branch
BranchTrueFalseTotal
unless ref $seq and $seq->isa("Bio::PrimarySeqI") 0 0 0
Condition0%0/3
ref $seq and $seq->isa("Bio::PrimarySeqI")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $seq and $seq->isa("Bio::PrimarySeqI")
ref $seq $seq->isa("Bio::PrimarySeqI")
Truth table0%0/3
A and B
A= ref $seqB= $seq->isa("Bio::PrimarySeqI")
ABresult
0X0
100
111
352 $seq->isa("Bio::PrimarySeqI") );
353 0 ▶ if( ! defined $seq->display_id ||
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $seq->display_id or $seq->display_id =~ /^\s+$/) 0 0 0
Condition0%0/3
not defined $seq->display_id or $seq->display_id =~ /^\s+$/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $seq->display_id or $seq->display_id =~ /^\s+$/
not defined $seq->display_id $seq->display_id =~ /^\s+$/
Truth table0%0/3
not(A) or B
A= not defined $seq->display_idB= $seq->display_id =~ /^\s+$/
ABresult
1X1
011
000
354 $seq->display_id =~ /^\s+$/) {
355 0 $seq->display_id( "Seq".$ct++);
356 }
357 0 $temp->write_seq($seq);
358 }
359 0 $temp->close();
360 0 undef $temp;
361 0 close($tfh);
362 0 $tfh = undef;
363 0 $type = 'S';
364 } elsif( $input->[0]->isa('Bio::Align::AlignI' ) ) {
365 0 $temp = Bio::AlignIO->new('-fh' => $tfh,
366 '-format' => $self->aformat);
367 0 foreach my $aln (@$input) {
368 0 ▶ next unless ( ref($aln) &&
Branch: 1 branch
BranchTrueFalseTotal
unless ref $aln and $aln->isa("Bio::Align::AlignI") 0 0 0
Condition0%0/3
ref $aln and $aln->isa("Bio::Align::AlignI")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $aln and $aln->isa("Bio::Align::AlignI")
ref $aln $aln->isa("Bio::Align::AlignI")
Truth table0%0/3
A and B
A= ref $alnB= $aln->isa("Bio::Align::AlignI")
ABresult
0X0
100
111
369 $aln->isa("Bio::Align::AlignI") );
370 0 $temp->write_aln($aln);
371 }
372 0 $temp->close();
373 0 undef $temp;
374 0 close($tfh);
375 0 $tfh = undef;
376 0 $type = 'A';
377 } else {
378 0 $self->warn( "got an array ref with 1st entry ".
379 $input->[0].
380 " and don't know what to do with it\n");
381 }
382 0 return ($infilename,$type);
383 # $input may be a SimpleAlign object.
384 } elsif ( $input->isa("Bio::Align::AlignI") ) {
385 # Open temporary file for both reading & writing of SimpleAlign object
386 0 ($tfh, $infilename) = $self->io->tempfile(-dir => cwd());
387 0 (undef, undef, $infilename) = File::Spec->splitpath($infilename);
388 0 $temp = Bio::AlignIO->new(-fh=>$tfh,
389 '-format' => 'clustalw');
390 0 $temp->write_aln($input);
391 0 close($tfh);
392 0 undef $tfh;
393 0 return ($infilename,'A');
394 }
395  
396 # or $input may be a single BioSeq object (to be added to
397 # a previous alignment)
398 elsif ( $input->isa("Bio::PrimarySeqI")) {
399 # Open temporary file for both reading & writing of BioSeq object
400 0 ($tfh,$infilename) = $self->io->tempfile(-dir => cwd());
401 0 (undef, undef, $infilename) = File::Spec->splitpath($infilename);
402 0 $temp = Bio::SeqIO->new(-fh=> $tfh, '-format' =>'Fasta');
403 0 $temp->write_seq($input);
404 0 $temp->close();
405 0 close($tfh);
406 0 undef $tfh;
407 0 return ($infilename,'S');
408 } else {
409 0 $self->warn("Got $input and don't know what to do with it\n");
410 }
411 0 return 0;
412 }
413  
414  
415  
416 sub _setparams {
417 0 ▶ my ($self) = @_;
Subroutine _setparams: not called CC=11 SCAR=48.8
418 0 my ($attr, $value,$param_string);
419 0 $param_string = '';
420 0 my $laststr;
421 0 for $attr ( @TCOFFEE_PARAMS ) {
422 0 $value = $self->$attr();
423 0 ▶ next unless (defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
424 0 my $attr_key = lc $attr;
425 0 ▶ if( $attr_key =~ /matrix/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr_key =~ /matrix/) { } 0 0 0
426 0 $self->{'_in'} = [ "X".lc($value) ];
427 } else {
428 0 $attr_key = ' -'.$attr_key;
429 0 $param_string .= $attr_key .'='.$value;
430 }
431 }
432 0 for $attr ( @TCOFFEE_SWITCHES) {
433 0 $value = $self->$attr();
434 0 ▶ next unless ($value);
Branch: 1 branch
BranchTrueFalseTotal
unless $value 0 0 0
435 0 my $attr_key = lc $attr; #put switches in format expected by tcoffee
436 0 $attr_key = ' -'.$attr_key;
437 0 $param_string .= $attr_key ;
438 }
439  
440 # Set default output file if no explicit output file selected
441 0 ▶ unless ($self->outfile ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->outfile) 0 0 0
442 0 my ($tfh, $outfile) = $self->io->tempfile(-dir=>$self->tempdir());
443 0 close($tfh);
444 0 undef $tfh;
445 0 $self->outfile($outfile);
446 0 $param_string .= " -outfile=$outfile" ;
447 }
448  
449 0 ▶ if ($self->quiet() || $self->verbose < 0) { $param_string .= ' -quiet';}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->quiet or $self->verbose < 0) 0 0 0
Condition0%0/3
$self->quiet or $self->verbose < 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->quiet or $self->verbose < 0
$self->quiet $self->verbose < 0
Truth table0%0/3
A or B
A= $self->quietB= $self->verbose < 0
ABresult
1X1
011
000
450  
451 # -no_warning is required on some systems with certain versions or failure
452 # is guaranteed
453 0 ▶ if ($self->version >= 4 && $self->version < 4.7) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->version >= 4 and $self->version < "4.7") 0 0 0
Condition0%0/3
$self->version >= 4 and $self->version < "4.7"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->version >= 4 and $self->version < "4.7"
$self->version >= 4 $self->version < "4.7"
Truth table0%0/3
A and B
A= $self->version >= 4B= $self->version < "4.7"
ABresult
0X0
100
111
454 0 $param_string .= ' -no_warning';
455 }
456  
457 0 return $param_string;
458 }
459  
460  
461 sub aformat{
462 0 ▶ my $self = shift;
Subroutine aformat: not called CC=2 SCAR=17.9
Pod documented
463 0 ▶ $self->{'_aformat'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
464 0 return $self->{'_aformat'};
465 }
466  
467  
468  
469 sub methods{
470 2 ▶ my ($self) = shift;
Subroutine methods: called CC=4 SCAR=13.9
Pod documented
471  
472 2 ▶ @{$self->{'_methods'}} = @{shift || []} if @_;
Branch: 2 branches
BranchTrueFalseTotal
if @_ 1 1 2
shift() or [] 0 1 1
473 2 ▶ return @{$self->{'_methods'} || []};
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_methods"} or [] 1 1 2
474 }
475  
476  
477  
478  
479  
480  
481  
482  
483  
484  
485 2 1;
486  
487 __END__
↑ Summary Installer/TCoffee.pm »