Debian Codegraph @

lib/Bio/Tools/Run/Phylo/PAML/Yn00.pm

raw symbols SCIP
1 package Bio::Tools::Run::Phylo::PAML::Yn00scip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/;
2 $Bio::Tools::Run::Phylo::PAML::Yn00::VERSIONscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/$VERSION. = '1.7.3';
3 use utf8scip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 utf8/;
4 use strictscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 strict/;
5 use warningsscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 warnings/;
6
7 use varsscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 vars/ qw(@ISA %VALIDVALUES $MINNAMELEN $PROGRAMNAME $PROGRAM);
8 use Cwdscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Cwd/;
9 use Bio::Root::Rootscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Root/Root/;
10 use Bio::AlignIOscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/AlignIO/;
11 use Bio::TreeIOscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/TreeIO/;
12 use Bio::Tools::Run::WrapperBasescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/WrapperBase/;
13 use Bio::Tools::Phylo::PAMLscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Phylo/PAML/;
14
15 @ISAscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`@ISA`. = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
16
17 # ABSTRACT: Wrapper aroud the PAML program yn00
18 # AUTHOR: Jason Stajich <[email protected]>
19 # OWNER: Jason Stajich <[email protected]>
20 # LICENSE: Perl_5
21
22
23
24 BEGIN {
25
26 $MINNAMELENscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/$MINNAMELEN. = 25;
27 $PROGRAMNAMEscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/$PROGRAMNAME. = 'yn00' . ($^Oscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`$^O`. =~ /mswin/i ?'.exe':'');
28 if( definedscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/defined(). $ENVscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`%ENV`.{'PAMLDIR'} ) {
29 $PROGRAMscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/$PROGRAM. = Bio::Root::IO->catfilescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Root/IO/catfile().($ENVscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`%ENV`.{'PAMLDIR'},$PROGRAMNAMEscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/$PROGRAMNAME.);
30 }
31 # valid values for parameters, the default one is always
32 # the first one in the array
33 # much of the documentation here is lifted directly from the codeml.ctl
34 # example file provided with the package
35 %VALIDVALUESscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`%VALIDVALUES`. = (
36 'noisy' => [ 0..3,9],
37 'verbose' => [ 0,1,2], # 0:concise, 1:detailed, 2:too much
38
39 'weighting' => [0,1], # weighting pathways between codons
40 'commonf3x4' => [0,1], # use same f3x4 for all sites
41
42 # (icode) genetic code
43 # 0:universal code
44 # 1:mamalian mt
45 # 2:yeast mt
46 # 3:mold mt,
47 # 4:invertebrate mt
48 # 5:ciliate nuclear
49 # 6:echinoderm mt
50 # 7:euplotid mt
51 # 8:alternative yeast nu.
52 # 9:ascidian mt
53 #10:blepharisma nu
54 # these correspond to 1-11 in the genbank transl table
55
56 'icode' => [ 0..10],
57 'ndata' => [1..10],
58 );
59 }
60
61
62
63 sub program_namescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/program_name(). {
64 return $PROGRAMNAMEscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/$PROGRAMNAME.;
65 }
66
67
68 sub program_dirscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/program_dir(). {
69 return Bio::Root::IO->catfilescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Root/IO/catfile().($ENVscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`%ENV`.{PAMLDIR}) if $ENVscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`%ENV`.{PAMLDIR};
70 }
71
72
73 sub newscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/new(). {
74 my($class,@args) = @_scip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`@_`.;
75
76 my $self = $class->SUPER::newscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`SUPER::new`().(@args);
77 my ($aln,$st) = $self->_rearrangescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/_rearrange().([qw(ALIGNMENT SAVE_TEMPFILES)],
78 @args);
79 definedscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/defined(). $aln && $self->alignmentscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/alignment().($aln);
80 definedscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/defined(). $st && $self->save_tempfilesscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/save_tempfiles().($st);
81
82 $self->set_default_parametersscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/set_default_parameters().();
83 return $self;
84 }
85
86
87 sub runscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/run().{
88 my ($self,$aln) = @_scip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`@_`.;
89 ($aln) ||= $self->alignmentscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/alignment().();
90 if( ! $aln ) {
91 $self->warnscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/warn().("must have supplied a valid alignment file in order to run yn00");
92 return 0;
93 }
94 my ($tmpdir) = $self->tempdirscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/tempdir().();
95 my ($tempseqFH,$tempseqfile);
96 if( ! refscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/ref().($aln) && -e $aln ) {
97 $tempseqfile = $aln;
98 } else {
99 ($tempseqFH,$tempseqfile) = $self->ioscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/io().->tempfilescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/tempfile().
100 ('-dir' => $tmpdir,
101 UNLINK => ($self->save_tempfilesscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/save_tempfiles(). ? 0 : 1));
102 my $alnout = Bio::AlignIO->newscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/AlignIO/new().('-format' => 'phylip',
103 '-fh' => $tempseqFH,
104 '-interleaved' => 0,
105 '-idlength' => $MINNAMELENscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/$MINNAMELEN. > $aln->maxdisplayname_lengthscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/maxdisplayname_length().() ? $MINNAMELENscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/$MINNAMELEN. : $aln->maxdisplayname_lengthscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/maxdisplayname_length().() +1);
106
107 $alnout->write_alnscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/AlignIO/write_aln().($aln);
108 $alnout->closescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/AlignIO/close().();
109 undefscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/undef(). $alnout;
110 closescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/close().($tempseqFH);
111 undefscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/undef(). $tempseqFH;
112 }
113 # now let's print the yn.ctl file.
114 # many of the these programs are finicky about what the filename is
115 # and won't even run without the properly named file. Ack
116
117 my $yn_ctl = "$tmpdir/yn00.ctl";
118 openscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/open().(YN, ">$yn_ctl") or $self->throwscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/throw().("cannot open $yn_ctl for writing");
119 print YN "seqfile = $tempseqfile\n";
120
121 my $outfile = $self->outfile_namescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/outfile_name().;
122
123 print YN "outfile = $outfile\n";
124 my %params = $self->get_parametersscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/get_parameters().;
125 while( my ($param,$val) = eachscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/each(). %params ) {
126 print YN "$param = $val\n";
127 }
128 closescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/close().(YN);
129 my ($rc,$parser) = (1);
130 {
131 my $cwd = cwdscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/cwd().();
132 my $exit_status;
133 chdirscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/chdir().($tmpdir);
134 my $ynexe = $self->executablescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/executable().();
135 $self->throwscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/throw().("unable to find executable for 'yn'") unless $ynexe;
136 openscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/open().(RUN, "$ynexe |");
137 my @output = <RUN>;
138 $exit_status = closescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/close().(RUN);
139 $self->error_stringscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/error_string().(joinscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/join().('',@output));
140 if( (grepscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/grep(). { /\berr(or)?: /io } @output) || !$exit_status ) {
141 $self->warnscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/warn().("There was an error - see error_string for the program output");
142 $rc = 0;
143 }
144 eval {
145 $parser = Bio::Tools::Phylo::PAML->newscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Phylo/PAML/new().(-file => "$tmpdir/mlc",
146 -dir => "$tmpdir");
147
148 };
149 if( $@scip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`$@`. ) {
150 $self->warnscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/warn().($self->error_stringscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/error_string().);
151 }
152 chdirscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/chdir().($cwd);
153 }
154 if( $self->verbosescip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/verbose(). > 0 ) {
155 openscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/open().(IN, "$tmpdir/mlc");
156 while(<IN>) {
157 $self->debugscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/debug().($_scip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/$_.);
158 }
159 }
160
161 unless ( $self->save_tempfilesscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/save_tempfiles(). ) {
162 unlinkscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/unlink().("$yn_ctl");
163 $self->cleanupscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/cleanup().();
164 }
165 return ($rc,$parser);
166 }
167
168
169 sub error_stringscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/error_string().{
170 my ($self,$value) = @_scip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`@_`.;
171 if( definedscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/defined(). $value) {
172 $self->{'error_string'} = $value;
173 }
174 return $self->{'error_string'};
175
176 }
177
178
179 sub alignmentscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/alignment().{
180 my ($self,$aln) = @_scip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`@_`.;
181 if( definedscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/defined(). $aln ) {
182 if( !refscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/ref().($aln) || ! $aln->isascip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/isa().('Bio::Align::AlignI') ) {
183 $self->warnscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/warn().("Must specify a valid Bio::Align::AlignI object to the alignment function");
184 return undef;
185 }
186 $self->{'_alignment'} = $aln;
187 }
188 return $self->{'_alignment'};
189 }
190
191
192 sub get_parametersscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/get_parameters().{
193 my ($self) = @_scip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`@_`.;
194 # we're returning a copy of this
195 return %{ $self->{'_codemlparams'} };
196 }
197
198
199
200 sub set_parameterscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/set_parameter().{
201 my ($self,$param,$value) = @_scip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`@_`.;
202 if( ! definedscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/defined(). $VALIDVALUESscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`%VALIDVALUES`.{$param} ) {
203 $self->warnscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/warn().("unknown parameter $param will not set unless you force by setting no_param_checks to true");
204 return 0;
205 }
206 if( refscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/ref().( $VALIDVALUESscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`%VALIDVALUES`.{$param}) =~ /ARRAY/i &&
207 scalarscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/scalar(). @{$VALIDVALUESscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`%VALIDVALUES`.{$param}} > 0 ) {
208
209 unless ( grepscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/grep(). {$value} @{ $VALIDVALUESscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`%VALIDVALUES`.{$param} } ) {
210 $self->warnscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/warn().("parameter $param specified value $value is not recognized, please see the documentation and the code for this module or set the no_param_checks to a true value");
211 return 0;
212 }
213 }
214 $self->{'_codemlparams'}->{$param} = $value;
215 return 1;
216 }
217
218
219 sub set_default_parametersscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/set_default_parameters().{
220 my ($self,$keepold) = @_scip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`@_`.;
221 $keepold = 0 unless definedscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/defined(). $keepold;
222
223 while( my ($param,$val) = eachscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/each(). %VALIDVALUESscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/`%VALIDVALUES`. ) {
224 # skip if we want to keep old values and it is already set
225 next if( definedscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/defined(). $self->{'_codemlparams'}->{$param} && $keepold);
226 if(refscip-perl cpan Bio-Tools-Phylo-PAML 1.7.3 Bio/Tools/Run/Phylo/PAML/Yn00/ref().($val)=~/ARRAY/i ) {
227 $self->{'_codemlparams'}->{$param} = $val->[0];
228 } else {
229 $self->{'_codemlparams'}->{$param} = $val;
230 }
231 }
232 }
233
234
235
236
237
238
239
240
241
242
243 1;
244
245 __END__
246
247 =pod
248
249 =encoding UTF-8
250
251 =head1 NAME
252
253 Bio::Tools::Run::Phylo::PAML::Yn00 - Wrapper aroud the PAML program yn00
254
255 =head1 VERSION
256
257 version 1.7.3
258
259 =head1 SYNOPSIS
260
261 use Bio::Tools::Run::Phylo::PAML::Yn00;
262 use Bio::AlignIO;
263 my $alignio = Bio::AlignIO->new(-format => 'phylip',
264 -file => 't/data/gf-s85.phylip');
265 my $aln = $alignio->next_aln;
266
267 my $yn = Bio::Tools::Run::Phylo::PAML::Yn00->new();
268 $yn->alignment($aln);
269 my ($rc,$parser) = $yn->run();
270 while( my $result = $parser->next_result ) {
271 my @otus = $result->get_seqs();
272 my $MLmatrix = $result->get_MLmatrix();
273 # 0 and 1 correspond to the 1st and 2nd entry in the @otus array
274 my $dN = $MLmatrix->[0]->[1]->{dN};
275 my $dS = $MLmatrix->[0]->[1]->{dS};
276 my $kaks =$MLmatrix->[0]->[1]->{omega};
277 print "Ka = $dN Ks = $dS Ka/Ks = $kaks\n";
278 }
279
280 =head1 DESCRIPTION
281
282 This is a wrapper around the yn00 (method of Yang and Nielsen, 2000)
283 program of PAML (Phylogenetic Analysis by Maximum Likelihood) package
284 of Ziheng Yang. See http://abacus.gene.ucl.ac.uk/software/paml.html
285 for more information.
286
287 This module will generate a proper yn00.ctl file and will run the
288 program in a separate temporary directory to avoid creating temp files
289 all over the place and will cleanup after itself.
290
291 =head2 Default Values
292
293 See the L<Bio::Tools::Run::Phylo::PAML::Codeml> module for
294 documentation of the default values.
295
296 =head1 ATTRIBUTES
297
298 =head2 program_name
299
300 Title : program_name
301 Usage : $yn00->program_name()
302 Function: holds the program name
303 Returns: string
304 Args : None
305
306 =head2 program_dir
307
308 Title : program_dir
309 Usage : $yn00->program_dir()
310 Function: returns the program directory, obtained from ENV variable.
311 Returns: string
312 Args :
313
314 =head2 error_string
315
316 Title : error_string
317 Usage : $obj->error_string($newval)
318 Function: Where the output from the last analysus run is stored.
319 Returns : value of error_string
320 Args : newvalue (optional)
321
322 =head2 alignment
323
324 Title : alignment
325 Usage : $codeml->align($aln);
326 Function: Get/Set the L<Bio::Align::AlignI> object
327 Returns : L<Bio::Align::AlignI> object
328 Args : [optional] L<Bio::Align::AlignI>
329 Comment : We could potentially add support for running directly on a file
330 but we shall keep it simple
331 See also: L<Bio::SimpleAlign>
332
333 =head2 no_param_checks
334
335 Title : no_param_checks
336 Usage : $obj->no_param_checks($newval)
337 Function: Boolean flag as to whether or not we should
338 trust the sanity checks for parameter values
339 Returns : value of no_param_checks
340 Args : newvalue (optional)
341
342 =head2 save_tempfiles
343
344 Title : save_tempfiles
345 Usage : $obj->save_tempfiles($newval)
346 Function:
347 Returns : value of save_tempfiles
348 Args : newvalue (optional)
349
350 =head2 outfile_name
351
352 Title : outfile_name
353 Usage : my $outfile = $codeml->outfile_name();
354 Function: Get/Set the name of the output file for this run
355 (if you wanted to do something special)
356 Returns : string
357 Args : [optional] string to set value to
358
359 =head2 tempdir
360
361 Title : tempdir
362 Usage : my $tmpdir = $self->tempdir();
363 Function: Retrieve a temporary directory name (which is created)
364 Returns : string which is the name of the temporary directory
365 Args : none
366
367 =head1 METHODS
368
369 =head2 new
370
371 Title : new
372 Usage : my $obj = Bio::Tools::Run::Phylo::PAML::Yn00->new();
373 Function: Builds a new Bio::Tools::Run::Phylo::PAML::Yn00 object
374 Returns : Bio::Tools::Run::Phylo::PAML::Yn00
375 Args : -alignment => the L<Bio::Align::AlignI> object
376 -save_tempfiles => boolean to save the generated tempfiles and
377 NOT cleanup after onesself (default FALSE)
378
379 =head2 run
380
381 Title : run
382 Usage : $yn->run();
383 Function: run the yn00 analysis using the default or updated parameters
384 the alignment parameter must have been set
385 Returns : 3 values,
386 $rc = 1 for success, 0 for errors
387 hash reference of the Yang calculated Ka/Ks values
388 this is a set of pairwise observations keyed as
389 sequencenameA->sequencenameB->datatype
390 hash reference same as the previous one except it for the
391 Nei and Gojobori calculated Ka,Ks,omega values
392 Args : none
393
394 =head2 get_parameters
395
396 Title : get_parameters
397 Usage : my %params = $self->get_parameters();
398 Function: returns the list of parameters as a hash
399 Returns : associative array keyed on parameter names
400 Args : none
401
402 =head2 set_parameter
403
404 Title : set_parameter
405 Usage : $codeml->set_parameter($param,$val);
406 Function: Sets a codeml parameter, will be validated against
407 the valid values as set in the %VALIDVALUES class variable.
408 The checks can be ignored if on turns of param checks like this:
409 $codeml->no_param_checks(1)
410 Returns : boolean if set was success, if verbose is set to -1
411 then no warning will be reported
412 Args : $paramname => name of the parameter
413 $value => value to set the parameter to
414 See also: L<no_param_checks()>
415
416 =head2 set_default_parameters
417
418 Title : set_default_parameters
419 Usage : $codeml->set_default_parameters(0);
420 Function: (Re)set the default parameters from the defaults
421 (the first value in each array in the
422 %VALIDVALUES class variable)
423 Returns : none
424 Args : boolean: keep existing parameter values
425
426 =head2 cleanup
427
428 Title : cleanup
429 Usage : $codeml->cleanup();
430 Function: Will cleanup the tempdir directory after a PAML run
431 Returns : none
432 Args : none
433
434 =head2 io
435
436 Title : io
437 Usage : $obj->io($newval)
438 Function: Gets a L<Bio::Root::IO> object
439 Returns : L<Bio::Root::IO>
440 Args : none
441
442 =head1 Bio::Tools::Run::Wrapper methods
443
444 =head1 FEEDBACK
445
446 =head2 Mailing lists
447
448 User feedback is an integral part of the evolution of this and other
449 Bioperl modules. Send your comments and suggestions preferably to
450 the Bioperl mailing list. Your participation is much appreciated.
451
452 [email protected] - General discussion
453 http://bioperl.org/Support.html - About the mailing lists
454
455 =head2 Support
456
457 Please direct usage questions or support issues to the mailing list:
458 I<[email protected]>
459
460 rather than to the module maintainer directly. Many experienced and
461 reponsive experts will be able look at the problem and quickly
462 address it. Please include a thorough description of the problem
463 with code and data examples if at all possible.
464
465 =head2 Reporting bugs
466
467 Report bugs to the Bioperl bug tracking system to help us keep track
468 of the bugs and their resolution. Bug reports can be submitted via the
469 web:
470
471 https://github.com/bioperl/bio-tools-phylo-paml/issues
472
473 =head1 AUTHOR
474
475 Jason Stajich <[email protected]>
476
477 =head1 COPYRIGHT
478
479 This software is copyright (c) by Jason Stajich <[email protected]>.
480
481 This software is available under the same terms as the perl 5 programming language system itself.
482
483 =cut