<commit_before>#
# You may distribute this module under the same terms as perl itself
#
# POD documentation - main docs before the code

=pod 

=head1 NAME

Bio::EnsEMBL::Pipeline::Runnable::Snap

=head1 SYNOPSIS

  #create and fill Bio::Seq object
  my $clonefile = '/nfs/disk65/mq2/temp/bA151E14.seq'; 
  my $seq = Bio::Seq->new();
  my $seqstream = Bio::SeqIO->new(-file => $clonefile, -fmt => 'Fasta');
  $seq = $seqstream->next_seq();
  #create Bio::EnsEMBL::Pipeline::Runnable::Snap object
  my $Snap = Bio::EnsEMBL::Pipeline::Runnable::Snap->new (-CLONE => $seq);
  $Snap->workdir($workdir);
  $Snap->run();
  my @genes = $snap->output();
  my @exons = $snap->output_exons();
  my $seqfeature = $snap->output_singlefeature();

=head1 DESCRIPTION

Snap takes a Bio::Seq (or Bio::PrimarySeq) object and runs Snap on it. The
resulting output is parsed to produce a set of Bio::SeqFeatures. 

snap is a gene predictor written by <NAME> (<EMAIL>) part the Zoe software library.

=head2 Methods:

=over 4

=item new($seq_obj)

=item    Snap($path_to_Snap)

=item    workdir($directory_name)

=item    run()

=item    output()

=item    output_exons()

=item    output_genes()

=back

=head1 SEE ALSO

=over 4

=item B<Bio::EnsEMBL::Pipeline::RunnableI>

=item B<Bio::EnsEMBL::Pipeline::RunnableDB::Snap> 

=back

=head1 CONTACT

Describe contact details here

=head1 APPENDIX

The rest of the documentation details each of the object methods. 
Internal methods are usually preceded with a _

=cut

package Bio::EnsEMBL::Pipeline::Runnable::Snap;

use vars qw(@ISA);
use strict;
# Object preamble - inherits from Bio::EnsEMBL::Root;

use Bio::EnsEMBL::Pipeline::RunnableI;
use Bio::EnsEMBL::SeqFeature;
use Bio::EnsEMBL::FeaturePair;
use Bio::EnsEMBL::Analysis; 
use Bio::EnsEMBL::PredictionTranscript;
use Bio::EnsEMBL::TranscriptFactory;
use Bio::EnsEMBL::PredictionExon;
use Bio::EnsEMBL::Root;


@ISA = qw(Bio::EnsEMBL::Pipeline::RunnableI);

=head2 new

    Title   :   new
    Usage   :   my obj =  Bio::EnsEMBL::Pipeline::Runnable::Snap->new (-CLONE => $seq);
    Function:   Initialises Snap object
    Returns :   a Snap Object
    Args    :   A Bio::Seq object 
                (Snap location and matrix file location optional)

=cut

sub new {
    my ($class,@args) = @_;
    my $self = $class->SUPER::new(@args);    

    $self->{'_exons'}     = [];    # an array of Bio::Seqfeatures (exons)
    $self->{'_genes'}     = [];    # an array of arrays of SeqFeatures
    $self->{'_peptides'}  = [];    # Snap predicted peptide (used for phase)
    $self->{'_snap'}   = undef; # location of Snap script
    $self->{'_workdir'}   = undef; # location of temp directory
    $self->{'_filename'}  = undef; # file to store Bio::Seq object
    $self->{'_results'}   = undef; # file to store results of Snap
    $self->{'_protected'} = [];    # a list of file suffixes protected from deletion
    $self->{'_parameters'} =undef; #location of parameters for Snap
    $self->{'_hmmfile'} = undef;

    my($query, $snap, $parameters, $matrix) = 
        $self->_rearrange([qw(QUERY SNAP PARAM HMMFILE)], @args);

    $self->workdir('/tmp') unless $self->workdir;

    $self->query($query);
#    $snap = 'snap'       unless ($snap);

    if ($snap) {
	$self->snap($snap);
    }
    else {<commit_msg>throw added if env-var $ZOE is not set (correctly)<commit_after>#
# You may distribute this module under the same terms as perl itself
#
# POD documentation - main docs before the code

=pod 

=head1 NAME

Bio::EnsEMBL::Pipeline::Runnable::Snap

=head1 SYNOPSIS

  #create and fill Bio::Seq object
  my $clonefile = '/nfs/disk65/mq2/temp/bA151E14.seq'; 
  my $seq = Bio::Seq->new();
  my $seqstream = Bio::SeqIO->new(-file => $clonefile, -fmt => 'Fasta');
  $seq = $seqstream->next_seq();
  #create Bio::EnsEMBL::Pipeline::Runnable::Snap object
  my $Snap = Bio::EnsEMBL::Pipeline::Runnable::Snap->new (-CLONE => $seq);
  $Snap->workdir($workdir);
  $Snap->run();
  my @genes = $snap->output();
  my @exons = $snap->output_exons();
  my $seqfeature = $snap->output_singlefeature();

=head1 DESCRIPTION

Snap takes a Bio::Seq (or Bio::PrimarySeq) object and runs Snap on it. The
resulting output is parsed to produce a set of Bio::SeqFeatures. 

snap is a gene predictor written by <NAME> (<EMAIL>) part the Zoe software library.

For running Snap, the environment variable $ZOE has to be set to '/usr/local/ensembl/Zoe'. 


=head2 Methods:

=over 4

=item new($seq_obj)

=item    Snap($path_to_Snap)

=item    workdir($directory_name)

=item    run()

=item    output()

=item    output_exons()

=item    output_genes()

=back

=head1 SEE ALSO

=over 4

=item B<Bio::EnsEMBL::Pipeline::RunnableI>

=item B<Bio::EnsEMBL::Pipeline::RunnableDB::Snap> 

=back

=head1 CONTACT

Describe contact details here

=head1 APPENDIX

The rest of the documentation details each of the object methods. 
Internal methods are usually preceded with a _

=cut

package Bio::EnsEMBL::Pipeline::Runnable::Snap;

use vars qw(@ISA);
use strict;
# Object preamble - inherits from Bio::EnsEMBL::Root;

use Bio::EnsEMBL::Pipeline::RunnableI;
use Bio::EnsEMBL::SeqFeature;
use Bio::EnsEMBL::FeaturePair;
use Bio::EnsEMBL::Analysis; 
use Bio::EnsEMBL::PredictionTranscript;
use Bio::EnsEMBL::TranscriptFactory;
use Bio::EnsEMBL::PredictionExon;
use Bio::EnsEMBL::Root;
use Bio::EnsEMBL::Utils::Exception ;

@ISA = qw(Bio::EnsEMBL::Pipeline::RunnableI);

=head2 new

    Title   :   new
    Usage   :   my obj =  Bio::EnsEMBL::Pipeline::Runnable::Snap->new (-CLONE => $seq);
    Function:   Initialises Snap object
    Returns :   a Snap Object
    Args    :   A Bio::Seq object 
                (Snap location and matrix file location optional)

=cut

sub new {
    my ($class,@args) = @_;
    my $self = $class->SUPER::new(@args);    

    $self->{'_exons'}     = [];    # an array of Bio::Seqfeatures (exons)
    $self->{'_genes'}     = [];    # an array of arrays of SeqFeatures
    $self->{'_peptides'}  = [];    # Snap predicted peptide (used for phase)
    $self->{'_snap'}   = undef; # location of Snap script
    $self->{'_workdir'}   = undef; # location of temp directory
    $self->{'_filename'}  = undef; # file to store Bio::Seq object
    $self->{'_results'}   = undef; # file to store results of Snap
    $self->{'_protected'} = [];    # a list of file suffixes protected from deletion
    $self->{'_parameters'} =undef; #location of parameters for Snap
    $self->{'_hmmfile'} = undef;

   my $zoe_dir = "/usr/local/ensembl/Zoe/";
   
    unless ($ENV{'ZOE'}) {
         print STDERR " There is no environment-variable \$ZOE set. \nI'll set it to $zoe_dir\n" ; 
      if(-e $zoe_dir) { 
         $ENV{'ZOE'} = $zoe_dir;  
       }else{
         warn( "ERROR ! $zoe_dir doens not exist !\n") ; 
         throw("you have to set the environment-variable \$ZOE to the dir where ./HMM/parameter.hmm lives \nYou can also modify Snap.pm (\$zoe_dir) ") ; 
       }
    }

    my($query, $snap, $parameters, $matrix) = 
        $self->_rearrange([qw(QUERY SNAP PARAM HMMFILE)], @args);

    $self->workdir('/tmp') unless $self->workdir;

    $self->query($query);
#    $snap = 'snap'       unless ($snap);

    if ($snap) {
	$self->snap($snap);
    }
    else {
{'fraction_non_alphanumeric': 0.15330384296378213, 'fraction_numerical': 0.0049764998617638926, 'mean_word_length': 3.670755326016785, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4431916', 'n_tokens_mistral': 2703, 'n_tokens_neox': 2510, 'n_words': 696}