BioPerl-Run
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Bio/Tools/Run/Phylo/Hyphy/Base.pm view on Meta::CPAN
$self->{'_params'}{$param} = $value;
return 1;
}
=head2 set_default_parameters
Title : set_default_parameters
Usage : $obj->set_default_parameters();
Function: (Re)set the default parameters from the defaults
(the first value in each array in the valid_values() array)
Returns : none
Args : none
=cut
sub set_default_parameters {
my ($self) = @_;
my @validvals = $self->valid_values();
foreach my $elem (@validvals) {
keys %$elem; #reset hash iterator
my ($param,$val) = each %$elem;
if (ref($val)=~/ARRAY/i ) {
unless (ref($val->[0])=~/HASH/i) {
push @{ $self->{'_orderedparams'} }, {$param, $val->[0]};
} else {
$val = $val->[0];
}
}
if ( ref($val) =~ /HASH/i ) {
my $prevparam;
while (defined($val)) {
last unless (ref($val) =~ /HASH/i);
last unless (defined($param));
$prevparam = $param;
($param,$val) = each %{$val};
push @{ $self->{'_orderedparams'} }, {$prevparam, $param};
push @{ $self->{'_orderedparams'} }, {$param, $val} if (defined($val));
}
} elsif (ref($val) !~ /HASH/i && ref($val) !~ /ARRAY/i) {
push @{ $self->{'_orderedparams'} }, {$param, $val};
}
}
}
=head2 update_ordered_parameters
Title : update_ordered_parameters
Usage : $hyphy->update_ordered_parameters(0);
Function: (Re)set the default parameters from the defaults
(the first value in each array in the
%VALIDVALUES class variable)
Returns : none
Args : boolean: keep existing parameter values
=cut
sub update_ordered_parameters {
my ($self) = @_;
for (my $i=0; $i < scalar(@{$self->{'_orderedparams'}}); $i++) {
my ($param,$val) = each %{$self->{'_orderedparams'}[$i]};
if (exists $self->{'_params'}{$param}) {
$self->{'_orderedparams'}[$i] = {$param, $self->{'_params'}{$param}};
} else {
$self->{'_orderedparams'}[$i] = {$param, $val};
}
}
}
=head2 outfile_name
Title : outfile_name
Usage : my $outfile = $hyphy->outfile_name();
Function: Get/Set the name of the output file for this run
(if you wanted to do something special)
Returns : string
Args : [optional] string to set value to
=cut
sub outfile_name {
my $self = shift;
if( @_ ) {
return $self->{'_params'}->{'outfile'} = shift @_;
}
return $self->{'_params'}->{'outfile'};
}
=head2 version
Title : version
Usage : $obj->version()
Function: Returns the version string from HYPHY
Returns : string
Args : none
=cut
sub version {
my $self = shift;
my $tempdir = $self->tempdir;
if (defined $self->{'_version'}) {
return $self->{'_version'};
}
# if it's not already defined, write out a small batchfile to return the version string, then clean up.
my $versionbf = "$tempdir/version.bf";
open(WRAPPER, ">", $versionbf) or $self->throw("cannot open $versionbf for writing");
print WRAPPER qq{GetString (versionString, HYPHY_VERSION, 2);\nfprintf (stdout, versionString);};
close(WRAPPER);
my $exe = $self->executable();
unless ($exe && -e $exe && -x _) {
$self->throw("unable to find or run executable for 'HYPHY'");
}
my $commandstring = $exe . " BASEPATH=" . $self->program_dir . " " . $versionbf;
open(RUN, "$commandstring |") or $self->throw("Cannot open exe $exe");
my $output = <RUN>;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 2.270 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-12c15c34b54 )