Tools/Run/Phylo/Hyphy/FEL.pm

filter: Statementstmt 37.9% 22 / 58 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 63.6% 7 / 11 Podpod 100% 4 / 4 totaltotal 35.4% 33 / 93 CC 12 SCAR 32.4
CC
12
Cov
28%
new
56.0
run
30.0
valid_values
6.0
CRAP 25.6
« Tools/Run/Mdust.pm ↑ Summary Tools/Run/Phylo/Hyphy/SLAC.pm »
1 # $Id$
2 #
3 # BioPerl module for Bio::Tools::Run::Phylo::Hyphy::FEL
4 #
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 #
7 # Cared for by Albert Vilella <avilella-at-gmail-dot-com>
8 #
9 # Copyright Albert Vilella
10 #
11 # You may distribute this module under the same terms as perl itself
12  
13 # POD documentation - main docs before the code
14  
15 =head1 NAME
16  
17 Bio::Tools::Run::Phylo::Hyphy::FEL - Wrapper around the Hyphy FEL analysis
18  
19 =head1 SYNOPSIS
20  
21 use Bio::Tools::Run::Phylo::Hyphy::FEL;
22 use Bio::AlignIO;
23 use Bio::TreeIO;
24  
25 my $alignio = Bio::AlignIO->new(-format => 'fasta',
26 -file => 't/data/hyphy1.fasta');
27  
28 my $aln = $alignio->next_aln;
29  
30 my $treeio = Bio::TreeIO->new(
31 -format => 'newick', -file => 't/data/hyphy1.tree');
32  
33 my $fel = Bio::Tools::Run::Phylo::Hyphy::FEL->new();
34 $fel->alignment($aln);
35 $fel->tree($tree);
36 my ($rc,$results) = $fel->run();
37  
38 =head1 DESCRIPTION
39  
40 This is a wrapper around the FEL analysis of HyPhy ([Hy]pothesis
41 Testing Using [Phy]logenies) package of Sergei Kosakowsky Pond,
42 Spencer V. Muse, Simon D.W. Frost and Art Poon. See
43 http://www.hyphy.org for more information.
44  
45 This module will generate the correct list of options for interfacing
46 with TemplateBatchFiles/Ghostrides/Wrapper.bf.
47  
48 =head1 FEEDBACK
49  
50 =head2 Mailing Lists
51  
52 User feedback is an integral part of the evolution of this and other
53 Bioperl modules. Send your comments and suggestions preferably to
54 the Bioperl mailing list. Your participation is much appreciated.
55  
56 bioperl-l@bioperl.org - General discussion
57 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
58  
59 =head2 Support
60  
61 Please direct usage questions or support issues to the mailing list:
62  
63 I<bioperl-l@bioperl.org>
64  
65 rather than to the module maintainer directly. Many experienced and
66 reponsive experts will be able look at the problem and quickly
67 address it. Please include a thorough description of the problem
68 with code and data examples if at all possible.
69  
70 =head2 Reporting Bugs
71  
72 Report bugs to the Bioperl bug tracking system to help us keep track
73 of the bugs and their resolution. Bug reports can be submitted via the
74 web:
75  
76 http://redmine.open-bio.org/projects/bioperl/
77  
78 =head1 AUTHOR - Albert Vilella
79  
80 Email avilella-at-gmail-dot-com
81  
82 =head1 CONTRIBUTORS
83  
84 Additional contributors names and emails here
85  
86 =head1 APPENDIX
87  
88 The rest of the documentation details each of the object methods.
89 Internal methods are usually preceded with a _
90  
91 =cut
92  
93  
94 # Let the code begin...
95  
96  
97 package Bio::Tools::Run::Phylo::Hyphy::FEL;
98 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
99 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
100 1 ▶use Bio::AlignIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
101 1 ▶use Bio::TreeIO;
Subroutine BEGIN: called CC=1 SCAR=0.0
102 1 ▶use Bio::Tools::Run::Phylo::Hyphy::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 1 ▶use Bio::Tools::Run::WrapperBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
104  
105 1 ▶use base qw(Bio::Root::Root Bio::Tools::Run::Phylo::Hyphy::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
106  
107 =head2 Default Values
108  
109 Valid and default values for FEL are listed below. The default
110 values are always the first one listed. These descriptions are
111 essentially lifted from the python wrapper or provided by the author.
112  
113 INCOMPLETE DOCUMENTATION OF ALL METHODS
114  
115 =cut
116  
117 =head2 valid_values
118  
119 Title : valid_values
120 Usage : $factory->valid_values()
121 Function: returns the possible parameters
122 Returns: an array holding all possible parameters. The default
123 values are always the first one listed. These descriptions are
124 essentially lifted from the python wrapper or provided by the author.
125 Args : None
126  
127 =cut
128  
129  
130 0 ▶sub valid_values {
Subroutine valid_values: not called CC=2 SCAR=17.9
Pod documented
131 0 ▶ my $null = ($^O =~ m/mswin/i) ? 'NUL' : '/dev/null';
Branch: 1 branch
BranchTrueFalseTotal
$^O =~ /mswin/i ? : 0 0 0
132 return
133 (
134 0 {'geneticCode' => [ "Universal","VertebratemtDNA","YeastmtDNA","Mold/ProtozoanmtDNA",
135 "InvertebratemtDNA","CiliateNuclear","EchinodermmtDNA","EuplotidNuclear",
136 "Alt.YeastNuclear","AscidianmtDNA","FlatwormmtDNA","BlepharismaNuclear"]},
137 {'New/Restore' => [ "New Analysis", "Restore"]},
138 {'tempalnfile' => undef }, # aln file goes here
139 {'Model Options' => [ { "Custom" => '010010' },
140 { "Default" => undef } ]
141 },
142 {'temptreefile' => undef }, # tree file goes here
143 {'Model Fit Results' => [ $null] }, # Windows have NUL instead of /dev/null
144 {'dN/dS bias parameter' => [ { "Estimate dN/dS only" => undef },
145 { "Neutral" => undef },
146 { "Estimate" => undef },
147 { "Estimate + CI" => undef },
148 { "User" => '3' } ] },
149 {'Ancestor Counting' => [ 'Two rate FEL','Single Ancestor Counting','Weighted Ancestor Counting',
150 'Sample Ancestal States','Process Sampled Ancestal States',
151 'One rate FEL','Rate Distribution',
152 'Full site-by-site LRT','Multirate FEL'] },
153 {'Significance level' => '0.05' },
154 {'Branch Options' => ['Internal Only','All','A Subtree only','Custom subset'] },
155 {'outfile' => undef }, # outfile goes here
156 );
157 }
158  
159  
160 =head2 new
161  
162 Title : new
163 Usage : my $obj = Bio::Tools::Run::Phylo::Hyphy::FEL->new();
164 Function: Builds a new Bio::Tools::Run::Phylo::Hyphy::FEL object
165 Returns : Bio::Tools::Run::Phylo::Hyphy::FEL
166 Args : -alignment => the Bio::Align::AlignI object
167 -save_tempfiles => boolean to save the generated tempfiles and
168 NOT cleanup after onesself (default FALSE)
169 -tree => the Bio::Tree::TreeI object
170 -params => a hashref of parameters (all passed to set_parameter)
171 -executable => where the hyphy executable resides
172  
173 See also: L<Bio::Tree::TreeI>, L<Bio::Align::AlignI>
174  
175 =cut
176  
177 0 ▶sub new {
Subroutine new: not called CC=7 SCAR=40.3
Pod documented
178 0 my($class,@args) = @_;
179  
180 0 my $self = $class->SUPER::new(@args);
181 0 my ($aln, $tree, $st, $params, $exe,
182 $ubl) = $self->_rearrange([qw(ALIGNMENT TREE SAVE_TEMPFILES
183 PARAMS EXECUTABLE)],
184 @args);
185 0 ▶ defined $aln && $self->alignment($aln);
Branch: 1 branch
BranchTrueFalseTotal
defined $aln and $self->alignment($aln) 0 0 0
186 0 ▶ defined $tree && $self->tree($tree);
Branch: 1 branch
BranchTrueFalseTotal
defined $tree and $self->tree($tree) 0 0 0
187 0 ▶ defined $st && $self->save_tempfiles($st);
Branch: 1 branch
BranchTrueFalseTotal
defined $st and $self->save_tempfiles($st) 0 0 0
188 0 ▶ defined $exe && $self->executable($exe);
Branch: 1 branch
BranchTrueFalseTotal
defined $exe and $self->executable($exe) 0 0 0
189  
190 0 $self->set_default_parameters();
191 0 ▶ if( defined $params ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params) 0 0 0
192 0 ▶ if( ref($params) !~ /HASH/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref($params) =~ /HASH/i) { } 0 0 0
193 0 $self->warn("Must provide a valid hash ref for parameter -FLAGS");
194 } else {
195 0 map { $self->set_parameter($_, $$params{$_}) } keys %$params;
196 }
197 }
198 0 return $self;
199 }
200  
201  
202 =head2 run
203  
204 Title : run
205 Usage : my ($rc,$results) = $fel->run($aln);
206 Function: run the fel analysis using the default or updated parameters
207 the alignment parameter must have been set
208 Returns : Return code, Hash
209 Args : L<Bio::Align::AlignI> object,
210 L<Bio::Tree::TreeI> object [optional]
211  
212  
213 =cut
214  
215 0 ▶sub run {
Subroutine run: not called CC=5 SCAR=34.0
Pod documented
216 0 my $self = shift;
217 0 my ($rc, $run_results) = $self->SUPER::run();
218 0 my $results ={};
219 0 my $outfile = $self->outfile_name();
220 0 ▶ open(OUTFILE, "$outfile") or $self->throw("cannot open $outfile for reading");
Branch: 1 branch
BranchTrueFalseTotal
open OUTFILE, "$outfile" or $self->throw("cannot open $outfile for reading") 0 0 0
221 0 my $readed_header = 0;
222 0 my @elems;
223 0 ▶ while (<OUTFILE>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline OUTFILE)) 0 0 0
224 0 ▶ if ($readed_header) {
Branch: 1 branch
BranchTrueFalseTotal
if ($readed_header) { } 0 0 0
225 # FEL results are csv
226 0 my @values = split("\,",$_);
227 0 for my $i (0 .. (scalar(@values)-1)) {
228 0 $elems[$i] =~ s/\n//g;
229 0 push @{$results->{$elems[$i]}}, $values[$i];
230 }
231 } else {
232 0 @elems = split("\,",$_);
233 0 $readed_header = 1;
234 }
235 }
236 0 return ($rc, $results);
237 }
238  
239  
240 =head2 create_wrapper
241  
242 Title : create_wrapper
243 Usage : $self->create_wrapper
244 Function: It will create the wrapper file that interfaces with the analysis bf file
245 Example :
246 Returns :
247 Args :
248  
249  
250 =cut
251  
252 0 ▶sub create_wrapper {
Subroutine create_wrapper: not called CC=1 SCAR=6.9
Pod documented
253 0 my $self = shift;
254  
255 0 my $batchfile = "QuickSelectionDetection.bf";
256 0 $self->SUPER::create_wrapper($batchfile);
257 }
258  
259  
260 1 1;
« Tools/Run/Mdust.pm ↑ Summary Tools/Run/Phylo/Hyphy/SLAC.pm »