Bio::EnsEMBL::Pipeline::SeqFetcher Getseqs
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
  Bio::EnsEMBL::Pipeline::SeqFetcher::Getseqs
Package variables
No package variables defined.
Included modules
Bio::DB::RandomAccessI
Bio::EnsEMBL::Root
Bio::Seq
Inherit
Bio::DB::RandomAccessI Bio::EnsEMBL::Root
Synopsis
    my $obj = Bio::EnsEMBL::Pipeline::SeqFetcher::Getseqs->new(
-executable => $exe,
-db => $db
);
my $seq = $obj->get_Seq_by_acc($acc);
Description
  Object to retrieve sequences as Bio::Seq, using getseqs by James Cuff. Sequences are fetched from a 
database previously formatted with makeindex
Methods
dbDescriptionCode
executableDescriptionCode
get_Seq_by_acc
No description
Code
get_Seq_by_id
No description
Code
new
No description
Code
Methods description
dbcode    nextTop
  Title   : db
Usage : $self->db('/data/blastdb/dbname');
Function: Get/set for dbs to be searched. Checks that the database
appropriate files are present, but nothing else.
Returns : string
Args : string
executablecodeprevnextTop
  Title   : executable
Usage : $self->executable('/path/to/executable');
Function: Get/set for the path to the executable being used by the module. If not set, the executable is looked for in $PATH.
Returns : string
Args : string
Methods code
dbdescriptionprevnextTop
sub db {
  my ($self, $dbs) = @_;
  if (!defined($self->{'_db'})) {
    $self->{'_db'} = [];
  }
  if (defined $dbs){
    if (ref($dbs) eq 'ARRAY') {
      foreach my $db(@$dbs){
	$self->throw("are you sure that $db has been formatted with makeindex?\n") 
	  unless ( -e "$db.jidx");
	push (@{$self->{'_db'}},$db);
      }
    }
  }
  return (@{$self->{'_db'}});
}
executabledescriptionprevnextTop
sub executable {
  my ($self, $exe) = @_;
  if ($exe)
    {
      $self->{'_exe'} = $exe;
    }
  return $self->{'_exe'};
}
get_Seq_by_accdescriptionprevnextTop
sub get_Seq_by_acc {
  my ($self, $acc) = @_;

  if (!defined($acc)) {
    $self->throw("No accession input");
  }  
  
  my $seqstr;
  my $seq;
  my $getseqs = $self->executable;
  my @seqdb  = $self->db;
  
 SEQDB:
  while(scalar(@seqdb) && !(defined $seq)){
    my $database = pop(@seqdb);

    last SEQDB unless defined $database;
    my $cmd = "$getseqs '$acc' $database";
    
    open(IN,"$cmd 2>/dev/null |") or $self->throw("Error forking getseqs for accession [$acc]: getseqs");
    my $seqstr;
    while(<IN>){
      chomp;
      $seqstr .= $_;
    }

    close IN or $self->throw("Error running getseqs for $acc: $!\n");

    if(defined $seqstr && !($seqstr=~/Sorry/)) {
    chomp($seqstr);
    $seq = new Bio::Seq('-seq'               => $seqstr,
			'-accession_number'  => $acc,
			'-desc'              => "",
			'-display_id'        => $acc);
    
    }
  }
  $self->throw("Could not getseqs sequence for [$acc]\n") unless defined $seq;    
  return $seq;
}
get_Seq_by_iddescriptionprevnextTop
sub get_Seq_by_id {
  my $self = @_;
  return undef;
}

1;
}
newdescriptionprevnextTop
sub new {
  my ($class, @args) = @_;
  my $self = bless {}, $class;

  my ($exe, $db) = $self->_rearrange(['EXECUTABLE', 'DB'], @args);

  if (!defined $exe) {
    $exe = 'getseqs';
  }
  $self->executable($exe);

  # expect an array of dbs
$self->throw("Expected a reference to an array of db\n") unless ref($db) eq 'ARRAY'; if (defined $db) { $self->db($db); } return $self; # success - we hope!
}
General documentation
CONTACTTop
Describe contact details here
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
get_Seq_byaccTop
  Title   : get_Seq_by_acc
Usage : $self->get_Seq_by_acc($accession);
Function: Does the sequence retrieval via getseqs
Returns : Bio::Seq
Args :