Bio::EnsEMBL::Analysis::Runnable::Funcgen
Splitter
Toolbar
Summary
Bio::EnsEMBL::Analysis::Runnable::Funcgen::Splitter
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
my $runnable = Bio::EnsEMBL::Analysis::Runnable::Funcgen::Splitter->new
(
-analysis => $analysis,
-query => 'slice',
-program => 'program.pl',
);
$runnable->run;
my @features = @{$runnable->output};
Description
Splitter expects to run the command line version of the Splitter program
(
http://zlab.bu.edu/splitter) and predicts features which can be stored in
the annotated_feature table in the eFG database
Methods
Methods description
Arg [1] : Bio::EnsEMBL::Analysis::Runnable::Splitter 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 [1] : Bio::EnsEMBL::Analysis::Runnable::Chipotle Arg [2] : filename (string) Decription : open and parse resultsfile Returntype : none Exceptions : throws Example : |
Arg [1] : Bio::EnsEMBL::Analysis::Runnable::Splitter Arg [2] : string, program name Usage : Description : Returns : Exceptions : |
Arg [1] : Bio::EnsEMBL::Analysis::Runnable::Splitter Arg [2] : filename Description : Returntype : Exceptions : Example : |
Methods code
sub infile
{
my ($self, $filename) = @_;
if($filename){
$self->{'infile'} = $filename;
}
if(!$self->{'infile'}){
$self->{'infile'} = $self->create_filename($self->analysis->logic_name, 'dat');
}
return $self->{'infile'}; } |
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);
throw("parse_results: can't open file ".$resultsfile.": ". $!)
unless (open(F, $resultsfile));
my @output = ();
while (<F>) {
next unless (s/^chr//);
chomp;
my @ft = split;
my $coord = shift(@ft);
my @coord = split(/[:-]/, $coord);
push(@output, [ @coord, $ft[0] ]);
}
throw("No features to annotate on slice ".$self->query->seq_region_name."!") if (scalar(@output) == 0);
$self->output(\@output);
throw("parse_results: can't close file ".$resultsfile.".")
unless (close(F));
}
1; } |
sub run_analysis
{
my ($self, $program) = @_;
if(!$program){
$program = $self->program;
}
throw($program." is not executable Splitter::run_analysis ")
unless($program && -x $program);
(my $id = $self->workdir) =~ s,^.+/,,;
my $command = $self->program."\' id=$id\'\' submit=One shot\'\' signalfile=".$self->infile."\' " .
$self->analysis->parameters;
warn("Running analysis " . $command . "\n");
eval { system( $command ) };
throw("FAILED to run $command: ", $@) if ($@);
opendir(DIR, $self->workdir())
or throw("Can't open workdir ".$self->workdir());
my @resultfiles = grep { /\.scored\.txt$/ } readdir DIR;
closedir(DIR);
throw("More than one resultfile in ".$self->workdir())
if (scalar(@resultfiles) > 1);
$self->resultsfile($self->workdir.'/'.$resultfiles[0]); } |
sub write_infile
{
my ($self, $filename) = @_;
if (! $filename) {
$filename = $self->infile();
}
(my $workdir = $filename) =~ s/\.dat$//;
eval { system("mkdir -p $workdir") };
throw ("Couldn't create directory $workdir: $@") if ($@);
$self->workdir($workdir);
$filename =~ s,.+/,,;
my $noa = scalar(keys %{$self->result_features});
warn('no. of result sets: ', $noa);
my $nof = scalar(@{(values %{$self->result_features})[0]});
warn('no. of result fts: ', $nof);
open(F, "> $workdir/$filename")
or throw("Can't open file $workdir/$filename.");
for (my $i=0; $i<$nof; $i++) {
my $coord=0;
foreach my $rset (values %{$self->result_features}) {
printf F "chr%s\t%d\t%d\t", ${$rset}[$i][0], ${$rset}[$i][1], ${$rset}[$i][2] unless ($coord);
$coord=1;
print F "\t".${$rset}[$i][3];
}
print F "\n";
}
close F;
$self->infile($workdir.'/'.$filename);
return "$workdir/$filename"; } |
General documentation
Stefan Graf, Ensembl Functional Genomics -