Bio::EnsEMBL::Analysis::Runnable::Funcgen Nessie
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
Bio::EnsEMBL::Analysis::Runnable::Funcgen::Nessie
Package variables
No package variables defined.
Included modules
Bio::EnsEMBL::Analysis::Runnable
Bio::EnsEMBL::Analysis::Runnable::Funcgen
Bio::EnsEMBL::Utils::Exception qw ( throw warning stack_trace_dump )
Data::Dumper
Inherit
Bio::EnsEMBL::Analysis::Runnable::Funcgen
Synopsis
  my $nessie = Bio::EnsEMBL::Analysis::Runnable::Funcgen::Nessie->new
(
-analysis => $analysis,
-query => 'slice',
-program => 'nessie',
);
$nessie->run;
my @annotated_features = @{$nessie->output};
Description
Nessie expects to run the program Nessie and predicts features which
can be stored in the predicted_feature table in the eFG database
Methods
datafilesDescriptionCode
run_analysisDescriptionCode
write_filelistDescriptionCode
write_infileDescriptionCode
Methods description
datafilescode    nextTop
  Arg [1]     : Bio::EnsEMBL::Analysis::Runnable::Nessie
Arg [2] : filename (string)
Description : will hold/add a list of filename
Returntype : listref of filenames
Exceptions : none
Example :
run_analysiscodeprevnextTop
  Arg [1]     : Bio::EnsEMBL::Analysis::Runnable::Nessie
Arg [2] : string, program name
Usage :
Description :
Returns :
Exceptions :
write_filelistcodeprevnextTop
    Arg [1]     : Bio::EnsEMBL::Analysis::Runnable::Nessie
Description : writes the nessie specific wrapper file containing a
list of replicate data file names
Returntype : none
Exceptions :
Example :
write_infilecodeprevnextTop
    Arg [1]     : Bio::EnsEMBL::Analysis::Runnable::Nessie
Arg [2] : filename
Description :
Returntype :
Exceptions :
Example :
Methods code
datafilesdescriptionprevnextTop
sub datafiles {
  my ($self, $filename) = @_;

  if(! $self->{'datafiles'}){
      $self->{'datafiles'} = [];
  }

  if($filename){
      push @{$self->{'datafiles'}}, $filename;
  }

  return\@ {$self->{'datafiles'}};
}
run_analysisdescriptionprevnextTop
sub run_analysis {
    print "Analysis::Runnable::Funcgen::Nessie::run_analysis\n";
        
    my ($self, $program) = @_;

    if(!$program){
        $program = $self->program;
    }

    throw($program." is not executable Nessie::run_analysis ") 
        unless($program && -x $program);
    
    (my $outfile = $self->infile()) =~ s/\.dat$/.out/;
    my @fields = (0..2,4);
    $self->output_fields(\@fields);

    (my $resultsfile = $self->infile()) =~ s/\.dat$/_peaks.out/;
    
    my $replicates = scalar(keys %{$self->result_features});
    if ($replicates == 1) { $replicates=2 }

    my ($nessie_parameters, $peak_parameters) = split('; ', $self->options);
    print Dumper ($nessie_parameters, $peak_parameters);
    
    my $command = $self->program.' --data="'.$self->infile().'" '.
        '--replicates='.$replicates.$nessie_parameters.' > '.$outfile;

    warn("Running analysis " . $command . "\n");
    eval { system($command) };
    throw("FAILED to run $command: ", $@) if ($@);

    my $parser = 'oligo_peaks.pl --sang --autonorm '. $peak_parameters .
        ' -l '.$outfile.' '.$self->infile.' > '.$resultsfile; 
        
    warn("Running parser " . $parser . "\n");
    eval { system($parser) };
    throw("FAILED to run $parser: ", $@) if ($@);

    throw("No peak resultfile.") if (! -e $resultsfile);
    $self->resultsfile($resultsfile);
}
write_filelistdescriptionprevnextTop
sub write_filelist {
    my ($self) = shift;

    throw("No infile found") if (! $self->infile());
    
    open(F, ">".$self->infile())
        or throw("Can't open file ".$self->infile);

    foreach my $f (@{$self->datafiles}) {
        print F $f, "\n";
    }

    # nessie hack: if there is only one replicate data set we duplicate this one ...
if (scalar(@{$self->datafiles}) == 1) { warn("Duplicating input data file."); print F ${$self->datafiles}[0], "\n"; } close F; } 1;
}
write_infiledescriptionprevnextTop
sub write_infile {
    print "Analysis::Runnable::Funcgen::Nessie::write_infile\n";

    my ($self, $filename) = @_;

    warn("workdir : ".$self->workdir);

    if (! $filename) {
        $filename = $self->infile();
    }

    warn("filename: ".$filename);

    foreach my $rset_name (sort keys %{$self->result_features})
    {

        #print Dumper $self->query->[0]->name, $rset_name, $filename;
#print $self->result_features->{$rset_name}, "\n";
my $datafile = $self->workdir.'/cache/'.$self->query->[0]->name.'.'.$rset_name.'.dat'; warn("datafile: ".$datafile); unless ( -e $datafile ) { open(F, ">".$datafile) or throw("Can't open file $datafile."); #foreach (keys %{$self->result_features}) {
# next unless ($datafile =~ m/$_/);
foreach my $ft (@{$self->result_features->{$rset_name}}) { #print join("\t", @$ft), "\n";
print F join("\t", @$ft), "\n"; } # last;
#}
close F; } $self->datafiles($datafile); } #print Dumper $self->datafiles;
$self->write_filelist(); map {$self->files_to_delete($_)} @{$self->datafiles}; return $filename;
}
General documentation
AUTHORTop
This module was created by Stefan Graf. It is part of the
Ensembl project: /
CONTACTTop
Post questions to the Ensembl development list: ensembl-dev@ebi.ac.uk