Bio-FeatureIO
view release on metacpan or search on metacpan
lib/Bio/SeqFeature/Annotated.pm view on Meta::CPAN
an exception if not.
If EXPAND is used, the parent''s start/end/strand will
be adjusted so that it grows to accommodate the new
subFeature
Example :
Returns : nothing
Args : a Bio::SeqFeatureI object
=cut
sub add_SeqFeature {
my ($self,$val, $expand) = @_;
return unless $val;
if ((!ref($val)) || !$val->isa('Bio::SeqFeatureI') ) {
$self->throw((ref($val) ? ref($val) : $val)
." does not implement Bio::SeqFeatureI.");
}
if($expand && ($expand eq 'EXPAND')) {
$self->_expand_region($val);
} else {
if ( !$self->contains($val) ) {
$self->warn("$val is not contained within parent feature, and expansion is not valid, ignoring.");
return;
}
}
push(@{$self->{'sub_array'}},$val);
}
=head2 remove_SeqFeatures()
Usage : $obj->remove_SeqFeatures
Function: Removes all sub SeqFeatures. If you want to remove only a subset,
remove that subset from the returned array, and add back the rest.
Returns : The array of Bio::SeqFeatureI implementing sub-features that was
deleted from this feature.
Args : none
=cut
sub remove_SeqFeatures {
my ($self) = @_;
my @subfeats = @{$self->{'sub_array'} || []};
$self->{'sub_array'} = []; # zap the array.
return @subfeats;
}
############################################################
=head1 INTERFACE METHODS FOR Bio::AnnotatableI
=cut
=head2 annotation()
Usage : $obj->annotation($annot_obj)
Function: Get/set the annotation collection object for annotating this
feature.
Returns : A Bio::AnnotationCollectionI object
Args : newvalue (optional)
=cut
sub annotation {
my ($obj,$value) = @_;
# we are smart if someone references the object and there hasn't been
# one set yet
if(defined $value || ! defined $obj->{'annotation'} ) {
$value = Bio::Annotation::Collection->new() unless ( defined $value );
$obj->{'annotation'} = $value;
}
return $obj->{'annotation'};
}
############################################################
=head2 location()
Usage : my $location = $seqfeature->location()
Function: returns a location object suitable for identifying location
of feature on sequence or parent feature
Returns : Bio::LocationI object
Args : [optional] Bio::LocationI object to set the value to.
=cut
sub location {
my($self, $value ) = @_;
if (defined($value)) {
unless (ref($value) and $value->isa('Bio::LocationI')) {
$self->throw("object $value pretends to be a location but ".
"does not implement Bio::LocationI");
}
$self->{'location'} = $value;
}
elsif (! $self->{'location'}) {
# guarantees a real location object is returned every time
$self->{'location'} = Bio::Location::Simple->new();
}
return $self->{'location'};
}
=head2 add_target()
Usage : $seqfeature->add_target(Bio::LocatableSeq->new(...));
Function: adds a target location on another reference sequence for this feature
Returns : true on success
Args : a Bio::LocatableSeq object
=cut
sub add_target {
my ($self,$seq) = @_;
$self->throw("$seq is not a Bio::LocatableSeq, bailing out") unless ref($seq) and seq->isa('Bio::LocatableSeq');
( run in 0.365 second using v1.01-cache-2.11-cpan-df04353d9ac )