Bio::EnsEMBL::Analysis::Runnable
Funcgen
Toolbar
Summary
Bio::EnsEMBL::Analysis::Runnable::Fungen
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
Description
This module is the base class for Fungen Runnables.
Methods
Methods description
Arg [1] : Bio::EnsEMBL::Analysis::Runnable::Funcgen Description : parse analysis parameters Returntype : hash ref with parameter names as keys Exceptions : none Example : |
Arg [1] : Bio::EnsEMBL::Analysis::Runnable::Funcgen Arg [2] : filename (string) Description : will hold a given filename or if one is requested but none defined it will use the create_filename method to create a filename Returntype : string, filename Exceptions : none Example : |
Arg : Usage : my $runnable = Bio::EnsEMBL::Analysis::Runnable::Funcgen->new() Description : Instantiates new Chipotle runnable Returns : Bio::EnsEMBL::Analysis::Runnable::Funcgen::Nessie object Exceptions : none |
Arg [1] : Bio::EnsEMBL::Analysis::RunnableDB Arg [2] : arrayref of output fields Description : container for outout fields Returntype : arrayref Exceptions : throws if no output field container is defined Example : |
Arg [1] : Bio::EnsEMBL::Analysis::Runnable::Funcgen Arg [2] : filename (string) Decription : open and parse resultsfile Returntype : none Exceptions : throws Example : |
Arg [1] : Bio::EnsEMBL::Analysis::Runnable::Funcgen Arg [2] : arrayref of result features Description : container for result features Returntype : arrayref Exceptions : throws if no probe feature container is defined Example : |
Arg [1] : Bio::EnsEMBL::Analysis::Runnable::Funcgen Arg [2] : string, directory Description : Class specific run method. This checks the directory specifed to run it, write the data to file (tab-delimited), marks the query infile and results file for deletion, runs the analysis, parses the results and deletes any files Returntype : 1 Exceptions : throws if no query sequence is specified Example : |
Methods code
sub get_parameters
{
my ($self) = @_;
my %parameters = ();
throw ("Object needs to be a Bio::EnsEMBL::Analysis::Runnable::Funcgen")
if (! $self->isa("Bio::EnsEMBL::Analysis::Runnable::Funcgen"));
my @parameters = split(/\s+/, $self->analysis->parameters());
map { throw("Parameter $_ has not the correct format.")
if (! m/^(.+)=(.+)/); $parameters{$1} = $2; } @parameters;
return\% parameters; } |
sub infile
{
my ($self, $filename) = @_;
if($filename){
$self->{'infile'} = $filename;
}
if(!$self->{'infile'}){
$self->{'infile'} = $self->create_filename
($self->analysis->module.'/'.$self->analysis->module, 'dat');
(my $dir = $self->{'infile'}) =~ s,/[^/]+$,,;
system("mkdir -p $dir") unless ( -d $dir );
}
return $self->{'infile'}; } |
sub new
{
print "Analysis::Runnable::Funcgen::new\n";
my ($class,@args) = @_;
my $self = $class->SUPER::new(@args);
my ($result_features, $options, $workdir) = rearrange
(['RESULT_FEATURES', 'OPTIONS', 'WORKDIR'], @args);
$self->result_features($result_features);
$self->workdir($workdir);
$self->checkdir();
warn("workdir ".$self->workdir()." OK!");
return $self; } |
sub output_fields
{ my ($self, $array) = @_;
if($array){
$self->{'outfile_fields'} = $array;
}
throw("No outfile field string set in Runnable.")
if (!$self->{'outfile_fields'});
return $self->{'outfile_fields'}; } |
sub parse_results
{ my ($self, $resultsfile) = @_;
if (! defined $resultsfile) {
$resultsfile = $self->resultsfile;
}
throw ('No resultsfile defined in instance!')
if(! defined $resultsfile);
throw("parse_results: results file ".$resultsfile." does not exist.")
if (! -e $resultsfile);
warn('Resultsfile: '.$resultsfile);
throw("parse_results: can't open file ".$resultsfile.": ". $!)
unless (open(F, $resultsfile));
my @output = ();
while (<F>) {
s/\"//g;
s/^chr//;
next unless (/^[0-9XYM]+\s/);
chomp;
my @ft = split;
push(@output, [ @ft[@{$self->output_fields()}] ]);
}
$self->output(\@output);
throw("parse_results: can't close file ".$resultsfile.".")
unless (close(F)); } |
sub query
{
my ($self, $query) = @_;
if ( $query ) {
throw("Must pass RunnableDB:Funcgen:query a array ref not a ".
ref($query)) unless (ref($query) eq 'ARRAY');
map {
throw($_->name . " is not a Bio::EnsEMBL::Slice")
unless ($_->isa("Bio::EnsEMBL::Slice"));
} @$query;
$self->{'query'} = $query;
}
return $self->{'query'};
}
1; } |
sub result_features
{ my ($self, $features) = @_;
if($features){
$self->{'result_features'} = $features;
}
return $self->{'result_features'}; } |
sub run
{
print "Bio::EnsEMBL::Analysis::Runnable::Funcgen::run\n";
my ($self, $dir) = @_;
$self->write_infile();
warn("infile: ".$self->infile);
throw("Input file ".$self->infile." is empty.") if (-z $self->infile);
$self->files_to_delete($self->infile);
$self->run_analysis();
$self->parse_results();
return 1; } |
General documentation
Stefan Graf, Ensembl Functional Genomics -