blib/lib/Bio/Tools/Run/Alignment/StandAloneFasta.pm

filter: Statementstmt 33.3% 61 / 183 Branchbran 15.6% 15 / 96 Conditioncond 18.5% 5 / 27 MC/DCmcdc 5.5% 1 / 18 Subroutinesub 66.6% 14 / 21 Podpod 100% 8 / 8 totaltotal 29.4% 104 / 353 CC 63 SCAR 51.9
CC
63
Cov
26%
run
552.0
_setinput
132.0
library
42.0
CRAP 178.6
« blib/lib/Bio/Tools/Run/Alignment/Lagan.pm ↑ Summary blib/lib/Bio/DB/SoapEUtilities/FetchAdaptor/seq.pm »
1 # $Id$
2 #StandAloneFasta.pm v1.00 2002/11/01
3 #
4 #Bioperl module for Bio::Tools::Run::Alignment::StandAloneFasta
5 #
6 # Written by Tiequan Zhang
7 # Please direct questions and support issues to <bioperl-l@bioperl.org>
8 #
9 # Cared for by Shawn Hoon
10 # Copyright Tiequan Zhang
11 #
12 # You may distribute this module under the same terms as perl itself
13  
14 # POD documentation - main docs before the code
15  
16 =head1 NAME
17  
18 Bio::Tools::Run::Alignment::StandAloneFasta - Object for the local
19 execution of the Fasta3 programs ((t)fasta3, (t)fastx3, (t)fasty3
20 ssearch3)
21  
22 =head1 SYNOPSIS
23  
24 #!/usr/bin/perl
25 use Bio::Tools::Run::Alignment::StandAloneFasta;
26 use Bio::SeqIO;
27 use strict;
28 my @arg=(
29 'b' =>'15',
30 'O' =>'resultfile',
31 'H'=>'',
32 'program'=>'fasta34'
33 );
34  
35 my $factory=Bio::Tools::Run::Alignment::StandAloneFasta->new(@arg);
36 $factory->ktup(1);
37  
38 $factory->library('p');
39  
40 #print result file name
41 print $factory->O;
42  
43  
44 my @fastreport=$factory->run($ARGV[0]);
45  
46 foreach (@fastreport) {
47 print "Parsed fasta report:\n";
48 my $result = $_->next_result;
49 while( my $hit = $result->next_hit()) {
50 print "\thit name: ", $hit->name(), "\n";
51 while( my $hsp = $hit->next_hsp()) {
52 print "E: ", $hsp->evalue(), "frac_identical: ",
53 $hsp->frac_identical(), "\n";
54 }
55 }
56 }
57  
58 #pass in seq objects
59 my $sio = Bio::SeqIO->new(-file=>$ARGV[0],-format=>"fasta");
60 my $seq = $sio->next_seq;
61 my @fastreport=$factory->run($ARGV[0]);
62  
63 =head1 DESCRIPTION
64  
65 This wrapper works with version 3 of the FASTA program package (see
66 W. R. Pearson and D. J. Lipman (1988), "Improved Tools for Biological
67 Sequence Analysis", PNAS 85:2444-2448 (Pearson and Lipman, 1988);
68 W. R. Pearson (1996) "Effective protein sequence comparison"
69 Meth. Enzymol. 266:227-258 (Pearson, 1996); Pearson et. al. (1997)
70 Genomics 46:24-36 (Zhang et al., 1997); Pearson, (1999) Meth. in
71 Molecular Biology 132:185-219 (Pearson, 1999). Version 3 of the FASTA
72 packages contains many programs for searching DNA and protein
73 databases and one program (prss3) for evaluating statistical
74 significance from randomly shuffled sequences.
75  
76 Fasta is available at ftp://ftp.virginia.edu/pub/fasta
77  
78 =head1 FEEDBACK
79  
80 =head2 Mailing Lists
81  
82 User feedback is an integral part of the evolution of this and other
83 Bioperl modules. Send your comments and suggestions preferably to one
84 of the Bioperl mailing lists. Your participation is much appreciated.
85  
86 bioperl-l@bioperl.org - General discussion
87 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
88  
89 =head2 Support
90  
91 Please direct usage questions or support issues to the mailing list:
92  
93 I<bioperl-l@bioperl.org>
94  
95 rather than to the module maintainer directly. Many experienced and
96 reponsive experts will be able look at the problem and quickly
97 address it. Please include a thorough description of the problem
98 with code and data examples if at all possible.
99  
100 =head2 Reporting Bugs
101  
102 Report bugs to the Bioperl bug tracking system to help us keep track
103 the bugs and their resolution. Bug reports can be submitted via the
104 web:
105  
106 http://redmine.open-bio.org/projects/bioperl/
107  
108 =head1 AUTHOR - Tiequan Zhang
109  
110 Adapted for bioperl by Shawn Hoon
111 Enhanced by Jason Stajich
112  
113 Email tqzhang1973@yahoo.com
114 shawnh@fugu-sg.org
115 jason-at-bioperl.org
116  
117 =head1 Appendix
118  
119 The rest of the documendation details each of the object
120 methods. Internal methods are preceeded with a underscore
121  
122 =cut
123  
124 package Bio::Tools::Run::Alignment::StandAloneFasta;
125  
126 1 use vars qw ($AUTOLOAD @ISA $library %parameters
127 1 ▶ $ktup @FASTA_PARAMS %OK_FIELD @OTHER_PARAMS);
Subroutine BEGIN: called CC=1 SCAR=0.0
128 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
129  
130 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
131 1 ▶use Bio::Root::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
132 1 ▶use Bio::Seq;
Subroutine BEGIN: called CC=1 SCAR=0.0
133 1 ▶use Bio::SeqIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
134 1 ▶use Bio::SearchIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
135 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
136  
137 BEGIN {
138 1 ▶ @FASTA_PARAMS=qw(a A b c E d f g h H i j l L M m n O o p Q q r R s S w x y z);
Subroutine BEGIN: called CC=2 SCAR=6.9
139 1 @OTHER_PARAMS =qw(program output database);
140 1 foreach my $att (@FASTA_PARAMS, @OTHER_PARAMS) {$OK_FIELD{$att}++;}
141 1 $ktup=2;
142 1 %parameters=('H' => '',
143 'q' => '',
144 'm' =>'1', 'O' =>'');
145
146 }
147  
148 1 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
149  
150 sub new {
151 1 ▶ my ($caller,@args)=@_;
Subroutine new: called CC=4 SCAR=13.9
Pod documented
152 #chained new
153 1 my $self = $caller->SUPER::new(@args);
154 1 ▶ while(@args){
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 6 1 7
155 6 my $attr = shift @args;
156 6 my $value = shift @args;
157 6 ▶ next if ($attr=~/^-/ || ! $attr);
Branch: 1 branch
BranchTrueFalseTotal
if $attr =~ /^-/ or not $attr 1 5 6
Condition66%2/3
$attr =~ /^-/ or not $attr
l!l&&r!l&&!r
105
MC/DC50%1/2
$attr =~ /^-/ or not $attr
$attr =~ /^-/ not $attr
Truth table66%2/3
A or not(B)
A= $attr =~ /^-/B= not $attr
ABresult
1X1
011
000
158 5 $self->$attr($value);
159 }
160 1 return $self;
161 }
162  
163 sub AUTOLOAD {
164 7 ▶ my $self = shift;
Subroutine AUTOLOAD: called CC=3 SCAR=11.0
165 7 my $attr = $AUTOLOAD;
166 7 $attr =~ s/.*:://;
167 7 ▶ $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $Bio::Tools::Run::Alignment::StandAloneFasta::OK_FIELD{$attr} 0 7 7
168 7 ▶ $self->{$attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 5 2 7
169 7 return $self->{$attr};
170 }
171  
172  
173 =head2 program_name
174  
175 Title : program_name
176 Usage : $factory->program_name()
177 Function: holds the program name
178 Returns: string
179 Args : None
180  
181 =cut
182  
183 sub program_name {
184 2 ▶ my ($self) = shift;
Subroutine program_name: called CC=1 SCAR=0.0
Pod documented
185 2 return $self->program(@_);
186 }
187  
188 =head2 executable
189  
190 Title : executable
191 Usage : my $exe = $blastfactory->executable('blastall');
192 Function: Finds the full path to the 'codeml' executable
193 Returns : string representing the full path to the exe
194 Args : [optional] name of executable to set path to
195 [optional] boolean flag whether or not warn when exe is not found
196  
197  
198 =cut
199  
200 sub executable {
201 1 ▶ my ($self, $exename, $exe,$warn) = @_;
Subroutine executable: called CC=11 SCAR=29.8
Pod documented
202 1 ▶ $exename = 'fasta34' unless defined $exename;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $exename 1 0 1
203  
204 1 ▶ if( defined $exe && -x $exe ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $exe and -x $exe) 0 1 1
Condition33%1/3
defined $exe and -x $exe
!ll&&!rl&&r
100
MC/DC0%0/2
defined $exe and -x $exe
defined $exe -x $exe
Truth table33%1/3
A and B
A= defined $exeB= -x $exe
ABresult
0X0
100
111
205 0 $self->{'_pathtoexe'}->{$exename} = $exe;
206 }
207 1 ▶ unless( defined $self->{'_pathtoexe'}->{$exename} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_pathtoexe"}{$exename}) 1 0 1
208 1 my $f = $self->program_path($exename);
209 1 ▶ $exe = $self->{'_pathtoexe'}->{$exename} = $f if(-e $f && -x $f );
Branch: 1 branch
BranchTrueFalseTotal
if -e $f and -x $f 0 1 1
Condition33%1/3
-e $f and -x $f
!ll&&!rl&&r
100
MC/DC0%0/2
-e $f and -x $f
-e $f -x $f
Truth table33%1/3
A and B
A= -e $fB= -x $f
ABresult
0X0
100
111
210
211 # This is how I meant to split up these conditionals --jason
212 # if exe is null we will execute this (handle the case where
213 # PROGRAMDIR pointed to something invalid)
214 1 ▶ unless( $exe ) { # we didn't find it in that last conditional
Branch: 1 branch
BranchTrueFalseTotal
unless ($exe) 1 0 1
215 1 ▶ if( ($exe = $self->io->exists_exe($exename)) && -x $exe ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exe = $self->io->exists_exe($exename) and -x $exe) { } 0 1 1
Condition33%1/3
$exe = $self->io->exists_exe($exename) and -x $exe
!ll&&!rl&&r
100
MC/DC0%0/2
$exe = $self->io->exists_exe($exename) and -x $exe
$exe = $self->io->exists_exe($exename) -x $exe
Truth table33%1/3
A and B
A= $exe = $self->io->exists_exe($exename)B= -x $exe
ABresult
0X0
100
111
216 0 $self->{'_pathtoexe'}->{$exename} = $exe;
217 } else {
218 1 ▶ $self->warn("Cannot find executable for $exename") if $warn;
Branch: 1 branch
BranchTrueFalseTotal
if $warn 0 1 1
219 1 $self->{'_pathtoexe'}->{$exename} = undef;
220 }
221 }
222 }
223 1 return $self->{'_pathtoexe'}->{$exename};
224 }
225  
226 =head2 program_dir
227  
228 Title : program_dir
229 Usage : $factory->program_dir(@params)
230 Function: returns the program directory, obtained from ENV variable.
231 Returns: string
232 Args :
233  
234 =cut
235  
236 sub program_dir {
237 1 ▶ return Bio::Root::IO->catfile($ENV{FASTADIR}) if $ENV{FASTADIR};
Subroutine program_dir: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"FASTADIR"} 0 1 1
238 }
239  
240 =head2 run
241  
242 Title : run
243  
244 Usage : my @fasta_object = $factory->($input,$onefile);
245 where $factory is the name of executable FASTA program;
246 $input is file name containing the sequences in the format
247 of fasta or Bio::Seq object or array of Bio::Seq object;
248 $onefile is 0 if you want to save the outputs to different files
249 default: outputs are saved in one file
250  
251 Function: Attempts to run an executable FASTA program
252 and return array of fasta objects containing the fasta report
253 Returns : aray of fasta report object
254 If the user specify the output file(s),
255 the raw fasta report will be saved
256 Args : sequence object OR array reference of sequence objects
257 filename of file containing fasta formatted sequences
258  
259 =cut
260  
261  
262 sub run {
263 0 ▶ my ($self,$input,$onefile)=@_;
Subroutine run: not called CC=23 SCAR=63.1
Pod documented
264 0 local * FASTARUN;
265  
266 0 $self->io->_io_cleanup;
267 0 ▶ my $program = $self->executable($self->program_name) ||
Condition0%0/3
$self->executable($self->program_name) || $self->throw("FASTA program not found or not executable.\n")
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->executable($self->program_name) || $self->throw("FASTA program not found or not executable.\n")
$self->executable($self->program_name) $self->throw("FASTA program not found or not executable.\n")
Truth table0%0/3
A || B
A= $self->executable($self->program_name)B= $self->throw("FASTA program not found or not executable.\n")
ABresult
1X1
011
000
268 $self->throw("FASTA program not found or not executable.\n");
269 # You should specify a library file
270 0 ▶ $self->throw("You didn't choose library.\n") unless ( $library);
Branch: 1 branch
BranchTrueFalseTotal
unless $Bio::Tools::Run::Alignment::StandAloneFasta::library 0 0 0
271
272 0 my @seqs = $self->_setinput($input);
273 0 ▶ return 0 unless (@seqs);
Branch: 1 branch
BranchTrueFalseTotal
unless @seqs 0 0 0
274  
275 0 my @fastobj;
276 0 my ($fhout, $tempoutfile)=$self->io->tempfile(-dir=>$self->tempdir);
277  
278 0 my $outfile=$self->O();
279  
280 # The outputs from executable FASTA program will
281 # be saved into different files if $onefile is 0,
282 # else will be concatenated into one file
283 0 ▶ my $onfile = (!defined $onefile || $onefile =~ /^0$/);
Condition0%0/3
!defined($onefile) || $onefile =~ /^0$/
l!l&&r!l&&!r
000
MC/DC0%0/2
!defined($onefile) || $onefile =~ /^0$/
!defined($onefile) $onefile =~ /^0$/
Truth table0%0/3
not(A) || B
A= !defined($onefile)B= $onefile =~ /^0$/
ABresult
1X1
011
000
284  
285 0 ▶ unless( $onfile ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($onfile) { } 0 0 0
286 0 my $count=0;
287  
288 # do some fancy stuff here to test if we are running fasta34
289 # with mlib so we just pass in a single file rather than
290 # running fasta N times
291 # (not implemented yet)
292
293 0 foreach my $seq (@seqs){
294 0 $count++;
295 # Decide if the output will be saved into a temporary file
296 0 ▶ if( $outfile ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($outfile) 0 0 0
297 0 $self->O(sprintf("%s_%d",$outfile,$count));
298 }
299
300 0 my ($fhinput,$teminputfile)=
301 $self->io->tempfile(-dir=>$self->tempdir);
302  
303 0 my $temp = Bio::SeqIO->new(-fh=>$fhinput, '-format'=>'Fasta');
304 0 $temp->write_seq($seq);
305 0 $temp->close();
306 0 close $fhinput;
307 0 undef $fhinput;
308 0 my $para= $self->_setparams;
309  
310 0 $para .=" $teminputfile $library $ktup";
311 0 $para ="$program $para";
312 0 my $object;
313 0 ▶ unless( $outfile ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($outfile) { } 0 0 0
314 0 ▶ open(FASTARUN, "$para |") || $self->throw($@);
Branch: 1 branch
BranchTrueFalseTotal
open FASTARUN, "$para |" or $self->throw($@) 0 0 0
315 0 $object = Bio::SearchIO->new(-fh=>\*FASTARUN,
316 -format=>"fasta");
317 } else {
318 0 ▶ if ( $self->verbose() < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verbose < 0) { } 0 0 0
319 0 $para .= ' >/dev/null 2>/dev/null';
320 } else {
321 0 $self->debug("Going to execute: $para");
322 }
323 0 my $status = system($para);
324 0 ▶ $self->throw("$para crashed: $?\n" )unless ($status==0);
Branch: 1 branch
BranchTrueFalseTotal
unless $status == 0 0 0 0
325 0 $object = Bio::SearchIO->new(-file=>$self->O,
326 -format=>"fasta");
327 }
328 0 push @fastobj, $object;
329 }
330 } else {
331 0 ▶ if ($outfile){
Branch: 1 branch
BranchTrueFalseTotal
if ($outfile) 0 0 0
332 0 ▶ open (FILE, ">$outfile") or $self->throw("can't use $outfile:$!");
Branch: 1 branch
BranchTrueFalseTotal
open FILE, ">$outfile" or $self->throw("can't use ${outfile}:$!") 0 0 0
333 0 close(FILE);
334 }
335
336 0 foreach my $seq (@seqs){
337 0 my ($fhinput,$teminputfile)=$self->io->tempfile(-dir=>$self->tempdir);
338 0 my $temp=Bio::SeqIO->new(-fh=>$fhinput, '-format'=>'fasta');
339 0 $temp->write_seq($seq);
340 0 $temp->close();
341 0 close $fhinput;
342 0 undef $fhinput;
343
344 0 ▶ $self->O($tempoutfile) if( $outfile );
Branch: 1 branch
BranchTrueFalseTotal
if $outfile 0 0 0
345 0 my $para= $self->_setparams;
346 0 $para .= " $teminputfile $library $ktup";
347 0 $para ="$program $para";
348 0 my $object;
349 0 ▶ unless( $outfile ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($outfile) { } 0 0 0
350 0 ▶ open(FASTARUN, "$para |") || $self->throw($@);
Branch: 1 branch
BranchTrueFalseTotal
open FASTARUN, "$para |" or $self->throw($@) 0 0 0
351 0 $object=Bio::SearchIO->new(-fh=>\*FASTARUN,
352 -format=>"fasta");
353 } else {
354 0 ▶ if ( $self->verbose() < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verbose < 0) { } 0 0 0
355 0 $para .= ' >/dev/null 2>/dev/null';
356 } else {
357 0 $self->debug("Going to execute: $para");
358 }
359 0 my $status = system($para);
360 0 ▶ $self->throw("$para crashed: $?\n" )unless ($status==0);
Branch: 1 branch
BranchTrueFalseTotal
unless $status == 0 0 0 0
361 0 $object = Bio::SearchIO->new(-file=>$self->O,
362 -format=>"fasta");
363 }
364 0 push @fastobj, $object;
365
366 # The output in the temporary file
367 # will be saved at the end of $outfile
368 0 ▶ if($outfile){
Branch: 1 branch
BranchTrueFalseTotal
if ($outfile) 0 0 0
369 0 ▶ open (FHOUT, $tempoutfile) or die("can't open the $tempoutfile file");
Branch: 1 branch
BranchTrueFalseTotal
open FHOUT, $tempoutfile or die "can't open the $tempoutfile file" 0 0 0
370 0 ▶ open (FH, ">>$outfile") or die("can't use the $outfile file");
Branch: 1 branch
BranchTrueFalseTotal
open FH, ">>$outfile" or die "can't use the $outfile file" 0 0 0
371 0 print FH (<FHOUT>);
372 0 close (FHOUT);
373 0 close (FH);
374 }
375 }
376 }
377 0 return @fastobj;
378 }
379  
380 =head2 library
381  
382 Title : library
383 Usage : my $lb = $self->library
384 Function: Fetch or set the name of the library to search against
385 Returns : The name of the library
386 Args : No argument if user wants to fetch the name of library file;
387 A letter or a string of letter preceded by %;
388 (e.g. P or %pn, the letter is the character in the third field
389 of any line of fastlibs file ) or the name of library file
390 (if environmental variable FASTLIBS is not set);
391 if user wants to set the name of library file to search against
392  
393 =cut
394  
395 sub library {
396 0 ▶ my($self,$lb)=@_;
Subroutine library: not called CC=6 SCAR=37.4
Pod documented
397 0 ▶ return $library if (!defined($lb));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lb 0 0 0
398  
399 0 ▶ if ( ($lb =~ /^%[a-zA-Z]+$/)||($lb=~ /^[a-zA-Z]$/)){
Branch: 1 branch
BranchTrueFalseTotal
if ($lb =~ /^%[a-zA-Z]+$/ or $lb =~ /^[a-zA-Z]$/) { } 0 0 0
Condition0%0/3
$lb =~ /^%[a-zA-Z]+$/ or $lb =~ /^[a-zA-Z]$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$lb =~ /^%[a-zA-Z]+$/ or $lb =~ /^[a-zA-Z]$/
$lb =~ /^%[a-zA-Z]+$/ $lb =~ /^[a-zA-Z]$/
Truth table0%0/3
A or B
A= $lb =~ /^%[a-zA-Z]+$/B= $lb =~ /^[a-zA-Z]$/
ABresult
1X1
011
000
400 0 ▶ if(! defined $ENV{'FASTLIBS'} ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ENV{"FASTLIBS"}) 0 0 0
401 0 $self->throw("abbrv. list request but FASTLIBS undefined, cannot use $lb");
402 }
403 } else {
404 0 ▶ unless ( -e $lb){
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $lb) 0 0 0
405 0 $self->throw("cannot open $lb library");
406 }
407 }
408  
409 0 return $library=$lb;
410 }
411  
412 1 *database = \&library;
413  
414 =head2 output
415  
416 Title : output
417 Usage : $obj->output($newval)
418 Function: The output directory if we want to use this
419 Example :
420 Returns : value of output (a scalar)
421 Args : on set, new value (a scalar or undef, optional)
422  
423  
424 =cut
425  
426 sub output{
427 0 ▶ my $self = shift;
Subroutine output: not called CC=2 SCAR=17.9
Pod documented
428  
429 0 ▶ return $self->{'output'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
430 0 return $self->{'output'};
431 }
432  
433 =head2 ktup
434  
435 Title : ktup
436 Usage : my $ktup = $self->ktup
437 Function: Fetch or set the ktup value for executable FASTA programs
438 Example :
439 Returns : The value of ktup if defined, else undef is returned
440 Args : No argument if user want to fetch ktup value; A integer value between 1-6 if user want to set the
441 ktup value
442  
443 =cut
444  
445 sub ktup {
446 0 ▶ my($self,$k)=@_;
Subroutine ktup: not called CC=3 SCAR=24.8
Pod documented
447 0 ▶ if(!defined($k)){return $ktup;}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $k) 0 0 0
448 0 ▶ if ($k =~ /^[1-6]$/){
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /^[1-6]$/) { } 0 0 0
449 0 $ktup=$k;
450 0 return $ktup
451 } else {
452 0 $self->warn("You should set the ktup value between 1-6. The FASTA program will decide your default ktup value.");
453 0 return $ktup= undef;
454 }
455 }
456  
457 =head2 _setinput
458  
459 Title : _setinput
460 Usage : Internal function, not to be called directly
461 Function: Create input file(s) for Blast executable
462 Example :
463 Returns : array of Bio::Seq object reference
464 Args : Seq object reference or input file name
465  
466 =cut
467  
468 sub _setinput {
469  
470 0 ▶ my ($self, $input) = @_;
Subroutine _setinput: not called CC=11 SCAR=48.8
471  
472 0 ▶ if( ! defined $input ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $input) 0 0 0
473 0 $self->throw("Calling fasta program with no input");
474 }
475  
476 0 my @seqs;
477 0 ▶ if( ! ref $input ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not ref $input) { } 0 0 0
elsif (ref($input) =~ /ARRAY/i) { } 0 0 0
elsif ($input->isa('Bio::PrimarySeqI')) { } 0 0 0
478 0 ▶ if( -e $input ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $input) { } 0 0 0
479 0 my $seqio = Bio::SeqIO->new(-format => 'fasta', -file => $input);
480 0 ▶ while( my $seq = $seqio->next_seq ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $seq = $seqio->next_seq) 0 0 0
481 0 push @seqs, $seq;
482 }
483 } else {
484 0 $self->throw("Input $input was not a valid filename");
485 }
486 } elsif( ref($input) =~ /ARRAY/i ) {
487 0 foreach ( @$input ) {
488 0 ▶ if( ref($_) && $_->isa('Bio::PrimarySeqI') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ and $_->isa('Bio::PrimarySeqI')) { } 0 0 0
Condition0%0/3
ref $_ and $_->isa("Bio::PrimarySeqI")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ and $_->isa("Bio::PrimarySeqI")
ref $_ $_->isa("Bio::PrimarySeqI")
Truth table0%0/3
A and B
A= ref $_B= $_->isa("Bio::PrimarySeqI")
ABresult
0X0
100
111
489 0 push @seqs, $_;
490 } else {
491 0 $self->warn("Trying to add a " . ref($_) ." but expected a Bio::PrimarySeqI");
492 }
493 }
494 0 ▶ if( ! @seqs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@seqs) 0 0 0
495 0 $self->throw("Did not pass in valid input -- no sequence objects found");
496 }
497 } elsif( $input->isa('Bio::PrimarySeqI') ) {
498 0 push @seqs, $input;
499 }
500 0 return @seqs;
501 }
502  
503 =head2 _exist
504  
505 Title : _exist
506 Usage : Internal function, not to be called directly
507 Function: Determine whether a executable FASTA program can be found
508 Cf. the DESCRIPTION section of this POD for how to make sure
509 for your FASTA installation to be found. This method checks for
510 existence of the blastall executable in the path.
511 Returns : 1 if FASTA program found at expected location, 0 otherwise.
512 Args : none
513  
514 =cut
515  
516 sub _exist {
517 0 ▶ my $exe = shift @_;
Subroutine _exist: not called CC=4 SCAR=30.0
518  
519 0 ▶ return 0 unless($exe =~ /fast|ssearch/);
Branch: 1 branch
BranchTrueFalseTotal
unless $exe =~ /fast|ssearch/ 0 0 0
520  
521 0 ▶ $exe .='.exe' if ($^O =~ /mswin/i);
Branch: 1 branch
BranchTrueFalseTotal
if $^O =~ /mswin/i 0 0 0
522  
523 0 my $f;
524
525 0 ▶ return ($f=Bio::Root::IO->exists_exe($exe))&&(-x $f);
Condition0%0/3
($f = 'Bio::Root::IO'->exists_exe($exe)) && -x $f
!ll&&!rl&&r
000
MC/DC0%0/2
($f = 'Bio::Root::IO'->exists_exe($exe)) && -x $f
($f = 'Bio::Root::IO'->exists_exe($exe)) -x $f
Truth table0%0/3
A && B
A= ($f = 'Bio::Root::IO'->exists_exe($exe))B= -x $f
ABresult
0X0
100
111
526 }
527  
528 =head2 _setparams
529  
530 Title : _setparams
531 Usage : Internal function, not to be called directly
532 Function: Create parameter inputs for FASTA executable
533 Returns : part of parameter string to be passed to FASTA program
534 Args : none
535  
536 =cut
537  
538 sub _setparams {
539 0 ▶ my ($self,$attr,$value);
Subroutine _setparams: not called CC=3 SCAR=24.8
540 0 $self = shift;
541 0 my $para = "";
542 0 foreach my $attr(@FASTA_PARAMS) {
543 0 $value = $self->$attr();
544 0 ▶ next unless (defined $value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
545 0 $para .=" -$attr $value";
546 }
547 0 $para .= " -q ";
548 0 return $para;
549 }
550  
551 1 1;
552 __END__
« blib/lib/Bio/Tools/Run/Alignment/Lagan.pm ↑ Summary blib/lib/Bio/DB/SoapEUtilities/FetchAdaptor/seq.pm »