Bio::EnsEMBL::Pipeline::SeqFetcher BPIndex
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
  Bio::EnsEMBL::Pipeline::SeqFetcher::BPIndex
Package variables
No package variables defined.
Included modules
Bio::DB::RandomAccessI
Bio::EnsEMBL::Root
Bio::Index::EMBL
Bio::Index::Fasta
Bio::Index::SwissPfam
Bio::Seq
Inherit
Bio::DB::RandomAccessI Bio::EnsEMBL::Root
Synopsis
    my $obj = Bio::EnsEMBL::Pipeline::SeqFetcher::BPIndex->new(
'-index' => $index,
'-format' => 'Fasta',
);
my $seq = $obj->get_Seq_by_acc($acc);
Description
    Object to retrieve sequences as Bio::Seq, from a bioperl index. 
The index is not made by this module; instead, the absolute path
to the bioperl index must be set using $obj->bp_index. The format
of the database must be set using bp_format.
Methods
bp_formatDescriptionCode
bp_indexDescriptionCode
get_Seq_by_accDescriptionCode
new
No description
Code
Methods description
bp_formatcode    nextTop
    Title   :   bp_format
Usage : $self->bp_format('Fasta')
Function: Get/set for a bioperl index format
Returns : String representing format. NOTE - bp_format is used in run to identify the type of Bio::Index module to make - so case is crucial. eg Fasta, EMBL, SwissPfam
Args : String representing format
bp_indexcodeprevnextTop
    Title   :   bp_index
Usage : $self->bp_index('/usr/local/ensembl/data/bp.inx')
Function: Get/set for a bioperl index
Returns : path to bioperl index
Args : path to bioperl index
get_Seq_by_acccodeprevnextTop
  Title   : get_Seq_by_acc
Usage : $self->get_Seq_by_acc($accession);
Function: Does the sequence retrieval
Returns : Bio::Seq
Args :
Methods code
bp_formatdescriptionprevnextTop
sub bp_format {
  
  my ($self, $format) = @_;
  if ($format)
    {
      $self->{'_format'} = $format;
    }
  return $self->{'_format'};
}
bp_indexdescriptionprevnextTop
sub bp_index {
  
  my ($self, $inx) = @_;
  if ($inx)
    {
      $self->{'_inx'} = $inx;
    }
  return $self->{'_inx'};
}
get_Seq_by_accdescriptionprevnextTop
sub get_Seq_by_acc {
  my ($self, $acc) = @_;
  
  my $inx    = $self->bp_index;
  my $format = $self->bp_format;
  

  if (!defined($acc)) {
    $self->throw("No accession input");
  }  

  if (!defined($inx)) {
    $self->throw("No search index specified; cannot run");
  }  

  if (!defined($format)) {
    $self->throw("No index format specified");
  }  
  
  my $type = 'Bio::Index::' . $format;
  my $index;

  eval {
    $index = $type->new($inx);
  };

  if ($@) {
    my $tmp = $@; # for some reason, warn empties out $@ ...
$self->warn("Problem opening the index [$inx] - check you have supplied the right format!"); $self->throw ("[$tmp]!"); } # get the sequence
my $seq; eval{ $seq = $index->fetch($acc); # Returns Bio::Seq object
}; $self->throw("Could not fetch sequence for [$acc]") unless defined $seq; return $seq; } 1;
}
newdescriptionprevnextTop
sub new {
  my ($class, @args) = @_;
  my $self = bless {}, $class;
  
  my($index, $format) = $self->_rearrange(['INDEX',
					   'FORMAT'], @args);
  
  if (!defined $index) {
    $self->throw("No bioperl indexfile provided to BPIndex\n");
  }
  $self->bp_index($index);
  
  
  if (!defined $format) {
    $self->throw("No bioperl index format provided to BPIndex\n");
  }
  $self->bp_format($format);


  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 _