BioPerl
view release on metacpan or search on metacpan
Bio/DB/SeqFeature/NormalizedFeature.pm view on Meta::CPAN
}
if (my $store = $self->object_store) {
return Bio::PrimarySeq->new(-seq => $store->fetch_sequence($self->seq_id,$start,$end) || '',
-id => $self->display_name);
} else {
return $self->SUPER::seq($self->seq_id,$start,$end);
}
}
sub subseq {
my $self = shift;
my ($newstart,$newstop) = @_;
my $store = $self->object_store or return;
my ($start,$stop) = ($self->start+$newstart-1,$self->end+$newstop-1);
if ($self->strand < 0) {
($start,$stop) = ($stop,$start);
}
my $seq = $store->fetch_sequence($self->seq_id,$start,$stop);
return Bio::PrimarySeq->new($seq);
}
=head2 add_SeqFeature
Title : add_SeqFeature
Usage : $flag = $feature->add_SeqFeature(@features)
Function: Add subfeatures to the feature
Returns : true if successful
Args : list of Bio::SeqFeatureI objects
Status : public
Add one or more subfeatures to the feature. For best results,
subfeatures should be of the same class as the parent feature
(i.e. don't try mixing Bio::DB::SeqFeature::NormalizedFeature with
other feature types).
An alias for this method is add_segment().
=cut
sub add_SeqFeature {
my $self = shift;
$self->_add_segment(1,@_);
}
=head2 update
Title : update
Usage : $flag = $feature->update()
Function: Update feature in the database
Returns : true if successful
Args : none
Status : public
After changing any fields in the feature, call update() to write it to
the database. This is not needed for add_SeqFeature() as update() is
invoked automatically.
=cut
sub update {
my $self = shift;
my $store = $self->object_store or return;
$store->store($self);
}
=head2 get_SeqFeatures
Title : get_SeqFeature
Usage : @subfeatures = $feature->get_SeqFeatures([@types])
Function: return subfeatures of this feature
Returns : list of subfeatures
Args : list of subfeature primary_tags (optional)
Status : public
This method extends the Bio::SeqFeatureI get_SeqFeatures() slightly by
allowing you to pass a list of primary_tags, in which case only
subfeatures whose primary_tag is contained on the list will be
returned. Without any types passed all subfeatures are returned.
=cut
# segments can be either normalized IDs or ordinary feature objects
sub get_SeqFeatures {
my $self = shift;
my @types = @_;
my $s = $self->{segments} or return;
my $store = $self->object_store;
my (@ordinary,@ids);
for (@$s) {
if (ref ($_)) {
push @ordinary,$_;
} else {
push @ids,$_;
}
}
my @r = grep {$_->type_match(@types)} (@ordinary,$store->fetch_many(\@ids));
for my $r (@r) {
eval {$r->object_store($store) };
}
return @r;
}
=head2 object_store
Title : object_store
Usage : $store = $feature->object_store([$new_store])
Function: get or set the database handle
Returns : current database handle
Args : new database handle (optional)
Status : public
This method will get or set the Bio::DB::SeqFeature::Store object that
is associated with the feature. After changing the store, you should
probably unset the feature's primary_id() and call update() to ensure
that the object is written into the database as a new feature.
=cut
( run in 0.506 second using v1.01-cache-2.11-cpan-39bf76dae61 )