Bio::DB::Persistent PrimarySeq
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvs
Summary
Bio::DB::Persistent::PrimarySeq - Proxy object for database PrimarySeq
representations
Package variables
No package variables defined.
Included modules
Bio::DB::Persistent::PersistentObject
Bio::PrimarySeqI
Inherit
Bio::DB::Persistent::PersistentObject
Synopsis
Give standard usage here
Description
This is a proxy object which will ferry calls to/from database for the
heavy stuff (sequence data) while it stores the simple attributes in
memory. This object is obtained from a DBAdaptor.
Methods
new
No description
Code
seqDescriptionCode
subseqDescriptionCode
seq_has_changedDescriptionCode
_seq_is_fetchedDescriptionCode
Methods description
seqcode    nextTop
 Title   : seq
Usage :
Function: Overridden from Bio::PrimarySeq::seq to allow for lazy loading.
Example :
Returns :
Args :
subseqcodeprevnextTop
 Title   : subseq
Usage :
Function: Overridden from Bio::PrimarySeq::subseq to allow for intelligent
database queries or delegation to the sequence object.
Example :
Returns :
Args :
seq_has_changedcodeprevnextTop
 Title   : seq_has_changed
Usage : $obj->seq_has_changed($newval)
Function:
Example :
Returns : TRUE or FALSE
Args : new value (TRUE or FALSE, optional)
_seq_is_fetchedcodeprevnextTop
 Title   : _seq_is_fetched
Usage : $obj->_seq_is_fetched($newval)
Function:
Example :
Returns : TRUE or FALSE
Args : new value (TRUE or FALSE, optional)
Methods code
newdescriptionprevnextTop
sub new {
    my ($class,@args) = @_;

    my $self = $class->SUPER::new(@args);

    my $has_seq = $self->obj()->seq() ? 1 : 0;
    # initially, the seq is always `dirty'
$self->seq_has_changed($has_seq); $self->_seq_is_fetched(0); # success - we hope
return $self;
}
seqdescriptionprevnextTop
sub seq {
    my $self = shift;
    my $value;

    # We do cache sequences, as fetching them is potentially quite expensive.
if(@_) { # we allow set
$value = $self->obj()->seq(@_); $self->seq_has_changed(1); # we don't need to fetch any more
$self->_seq_is_fetched(1); $self->is_dirty(1); } else { # does the object have it pre-set?
$value = $self->obj()->seq(); if((! $value) && (! $self->_seq_is_fetched()) && $self->primary_key()) { # no, but we can retrieve it from the datastore (and we
# haven't done so yet)
$value = $self->adaptor()->get_biosequence($self->primary_key()); $self->obj()->seq($value) if defined($value) || $self->alphabet(); $self->seq_has_changed(0); # we only fetch once -- if sequences change frequently in the
# datastore, this will disconnect us from that
$self->_seq_is_fetched(1); } } return $value;
}
subseqdescriptionprevnextTop
sub subseq {
    my ($self,$start,$end,$replace) = @_;

    if($self->_seq_is_fetched() ||
       defined($self->obj()->seq()) || (! $self->primary_key())) {
	# the sequence or its latest version is in the object or we don't know
# yet how to find ourselves in the database -- delegate the call
$self->seq_has_changed(1) if $replace; return $self->obj()->subseq($start,$end,$replace); } elsif(ref($start) && $start->isa("Bio::LocationI")) { # recursively call for every sublocation
my $loc = $start; $replace = $end; # do we really use this anywhere? scary. HL
my $seq = ""; foreach my $subloc ($loc->each_Location()) { my $piece = $self->subseq($subloc->start(), $subloc->end(), $replace); if($subloc->strand() < 0) { $piece = Bio::PrimarySeq->new('-seq'=>$piece)->revcom()->seq(); } $seq .= $piece; } return $seq; } else { if($replace) { $self->throw("replacing (with [$replace]) in subseq not supported". " in datastore connection"); } return $self->adaptor()->get_biosequence($self->primary_key(), $start, $end); }
}
seq_has_changeddescriptionprevnextTop
sub seq_has_changed {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'_seq_has_changed'} = $value;
    }
    return $self->{'_seq_has_changed'};
}
_seq_is_fetcheddescriptionprevnextTop
sub _seq_is_fetched {
    my ($self,$value) = @_;
    if( defined $value) {
	$self->{'_seq_is_fetched'} = $value;
    }
    return $self->{'_seq_is_fetched'};
}

1;
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to one
of the Bioperl mailing lists. Your participation is much appreciated.
  bioperl-l@bio.perl.org
Support Top
 
Please direct usage questions or support issues to the mailing list:

bioperl-l@bioperl.org

rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via email
or the web:
  bioperl-bugs@bio.perl.org
http://bugzilla.perl.org/
AUTHOR - Hilmar Lapp, Ewan BirneyTop
Email hlapp at gmx.net
Based in idea largely on Bio::DB::PrimarySeq by Ewan Birney.
Describe contact details here
APPENDIXTop
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _