Summary | Included libraries | Package variables | Synopsis | Description | General documentation | Methods |
WebCvs | Raw content |
my $db = Bio::DB::GFF->new(-dsn => 'dbi:mysql:elegans',Now we fetch out a segment based on cosmid clone ZK909:
-adaptor=>'dbi:mysqlopt');
my $seg = $db->segment('ZK909');If we call the segment's refseq() method, we see that the base of the
print $seg->refseq;As a convenience, the "" operator is overloaded in this class, to give
=> ZK909
print $seg->start,' - ',$seg->stop; => 1 - 33782
print $seg;Internally, Bio::DB::GFF::RelSegment has looked up the absolute
=> ZK909:1,33782
print $seg->sourceseq;We can also put the segment into absolute mode, so that it behaves
=> CHROMOSOME_I
print $seg->abs_start,' - ',$seg->abs_end; => 14839545 - 14873326
$seq->absolute(1);We can change the reference sequence at any time. One way is to call
print $seg;
=> CHROMOSOME_I:14839545,14873326
$seg->refseq('ZK337');We can call the segment's features() method in order to get the list
print $seg;
=> ZK337:-33670,111
@links = $seg->features('Sequence:Link');We can now set the reference sequence to the first of these contigs like so:
$seg->refseq($links[0]);
print $seg;
=> Sequence:Link(LINK_Y95D11A):3997326,4031107
_abs2rel | Description | Code |
_process_feature_args | Description | Code |
_to_strand | No description | Code |
abs2rel | Description | Code |
abs_end | No description | Code |
abs_high | Description | Code |
abs_low | Description | Code |
abs_start | No description | Code |
absolute | Description | Code |
asString | Description | Code |
contained_features | Description | Code |
contained_in | Description | Code |
contains | No description | Code |
end | No description | Code |
features | Description | Code |
get_feature_stream | Description | Code |
intersection | No description | Code |
length | No description | Code |
new | Description | Code |
new_from_segment | Description | Code |
overlaps | No description | Code |
refseq | Description | Code |
rel2abs | Description | Code |
start | No description | Code |
strand | No description | Code |
subseq | No description | Code |
types | Description | Code |
union | No description | Code |
_abs2rel | code | next | Top |
Title : _abs2relThis is used internally to map from absolute to relative coordinates. It does not take the offset of the reference sequence into account, so please use abs2rel() instead. |
_process_feature_args | code | prev | next | Top |
Title : _process_feature_argsThis is an internal method that is used to check and format the arguments to features() before passing them on to the adaptor. |
abs2rel | code | prev | next | Top |
Title : abs2relThis function takes a list of positions in absolute coordinates and returns a list expressed in relative coordinates. |
abs_high | code | prev | next | Top |
Title : abs_highThis is for GadFly compatibility, and returns the high coordinate in absolute coordinates; |
abs_low | code | prev | next | Top |
Title : abs_lowThis is for GadFly compatibility, and returns the low coordinate in absolute coordinates; |
absolute | code | prev | next | Top |
Title : absoluteCalled with a boolean flag, this method controls whether to display relative coordinates (relative to the reference sequence) or absolute coordinates (relative to the source sequence). It will return the previous value of the setting. |
asString | code | prev | next | Top |
Title : asStringThis method will return a human-readable representation of the segment. It is the overloaded method call for the "" operator. Currently the format is: refseq:start,stop |
contained_features | code | prev | next | Top |
Title : contained_featuresThis is identical in behavior to features() except that it returns only those features that are completely contained within the segment, rather than any that overlap. |
contained_in | code | prev | next | Top |
Title : contained_inThis is identical in behavior to features() except that it returns only those features that completely contain the segment. |
features | code | prev | next | Top |
Title : featuresThis method will find all features that overlap the segment and return a list of Bio::DB::GFF::Feature objects. The features will use coordinates relative to the reference sequence in effect at the time that features() was called. The returned list can be limited to certain types of feature by filtering on their method and/or source. In addition, it is possible to obtain an iterator that will step through a large number of features sequentially. Arguments can be provided positionally or using the named arguments format. In the former case, the arguments are a list of feature types in the format "method:source". Either method or source can be omitted, in which case the missing component is treated as a wildcard. If no colon is present, then the type is treated as a method name. Multiple arguments are ORed together. Examples: @f = $s->features('exon:curated'); # all curated exonsThe named parameter form gives you control over a few options: -types an array reference to type names in the format-merge is a boolean flag that controls whether the adaptor's aggregators wll be applied to the features returned by this method. If -iterator is true, then the method returns a single scalar value consisting of a Bio::SeqIO object. You can call next_seq() repeatedly on this object to fetch each of the features in turn. If iterator is false or absent, then all the features are returned as a list. The -attributes argument is a hashref containing one or more attributes to match against: -attributes => { Gene => 'abc-1',Attribute matching is simple string matching, and multiple attributes are ANDed together. |
get_feature_stream | code | prev | next | Top |
Title : featuresThis is the same as features(), but returns a stream. Use like this: $stream = $s->get_feature_stream('exon'); |
new | code | prev | next | Top |
Title : newThis method creates a new Bio::DB::GFF::RelSegment object. Generally this is called automatically by the Bio::DB::GFF module and derivatives. This function uses a named-argument style: -factory a Bio::DB::GFF::Adaptor to use for database accessThe -seq argument accepts the ID of any landmark in the database. The stored source sequence becomes whatever the GFF file indicates is the proper sequence for this landmark. A class of "Sequence" is assumed unless otherwise specified in the -class argument. If the argument to -seq is a Bio::GFF::Featname object (such as returned by the group() method), then the class is taken from that. The optional -start and -stop arguments specify the end points for the retrieved segment. For those who do not like 1-based indexing, -offset and -length are provided. If both -start/-stop and -offset/-length are provided, the latter overrides the former. Generally it is not a good idea to mix metaphors. -ref and -refclass together indicate a sequence to be used for relative coordinates. If not provided, the source sequence indicated by -seq is used as the reference sequence. If the argument to -ref is a Bio::GFF::Featname object (such as returned by the group() method), then the class is taken from that. -force_absolute should be used if you wish to skip the lookup of the absolute position of the source sequence that ordinarily occurs when you create a relative segment. In this case, the source sequence must be a sequence that has been specified as the "source" in the GFF file. |
new_from_segment | code | prev | next | Top |
Title : new_from_segmentThis constructor is used internally by the subseq() method. It forces the new segment into the Bio::DB::GFF::RelSegment package, regardless of the package that it is called from. This causes subclass-specfic information, such as feature types, to be dropped when a subsequence is created. |
refseq | code | prev | next | Top |
Title : refseqThis method will get or set the reference sequence. Called with no arguments, it returns the current reference sequence. Called with either a sequence ID and class, a Bio::DB::GFF::Segment object (or subclass) or a Bio::DB::GFF::Featname object, it will set the current reference sequence and return the previous one. The method will generate an exception if you attempt to set the reference sequence to a sequence that isn't contained in the database, or one that has a different source sequence from the segment. |
rel2abs | code | prev | next | Top |
Title : rel2absThis function takes a list of positions in relative coordinates to the segment, and converts them into absolute coordinates. |
types | code | prev | next | Top |
Title : typesThe types() method will return a list of Bio::DB::GFF::Typename objects, each corresponding to a feature that overlaps the segment. If the optional -enumerate parameter is set to a true value, then the method will return a hash in which the keys are the type names and the values are the number of times a feature of that type is present on the segment. For example: %count = $s->types(-enumerate=>1); |
_abs2rel | description | prev | next | Top |
my $self = shift; my @result; return unless defined $_[0]; if ($self->absolute) { @result = @_; } else { my ($refstart,$refstrand) = @{$self}{qw(refstart refstrand)}; @result = defined($refstrand) && $refstrand eq '-' ? map { $refstart - $_ + 1 } @_ : map { $_ - $refstart + 1 } @_; } # if called with a single argument, caller will expect a single scalar reply}
# not the size of the returned array!
return $result[0] if @result == 1 and !wantarray; @result;
_process_feature_args | description | prev | next | Top |
my $self = shift; my ($ref,$class,$start,$stop,$strand,$whole) = @{$self}{qw(sourceseq class start stop strand whole)}; ($start,$stop) = ($stop,$start) if $strand eq '-'; my @args = (-ref=>$ref,-class=>$class); # indicating that we are fetching the whole segment allows certain}
# SQL optimizations.
push @args,(-start=>$start,-stop=>$stop) unless $whole; if (@_) { if ($_[0] =~ /^-/) { push @args,@_; } else { my @types = @_; push @args,-types=>\@types; } } push @args,-parent=>$self; @args;
_to_strand | description | prev | next | Top |
my $s = shift; return -1 if $s eq '-'; return +1 if $s eq '+'; return 0;}
abs2rel | description | prev | next | Top |
my $self = shift; my @result; if ($self->absolute) { @result = @_; } else { my ($abs_start,$abs_strand) = ($self->abs_start,$self->abs_strand); @result = $abs_strand < 0 ? map { $abs_start - $_ + 1 } @_ : map { $_ - $abs_start + 1 } @_; } # if called with a single argument, caller will expect a single scalar reply}
# not the size of the returned array!
return $result[0] if @result == 1 and !wantarray; @result;
abs_end | description | prev | next | Top |
my $self = shift; if ($self->absolute) { my ($a,$b) = ($self->SUPER::abs_start,$self->SUPER::abs_end); return ($a>$b) ? $a : $b; } else { return $self->SUPER::abs_end(@_); }}
abs_high | description | prev | next | Top |
my $self = shift; my ($a,$b) = ($self->abs_start,$self->abs_end); return ($a>$b) ? $a : $b;}
abs_low | description | prev | next | Top |
my $self = shift; my ($a,$b) = ($self->abs_start,$self->abs_end); return ($a<$b) ? $a : $b;}
abs_start | description | prev | next | Top |
my $self = shift; if ($self->absolute) { my ($a,$b) = ($self->SUPER::abs_start,$self->SUPER::abs_end); return ($a<$b) ? $a : $b; } else { return $self->SUPER::abs_start(@_); }}
absolute | description | prev | next | Top |
my $self = shift; my $g = $self->{absolute}; $self->{absolute} = shift if @_; $g;}
asString | description | prev | next | Top |
my $self = shift; return $self->SUPER::asString if $self->absolute; my $label = $self->{ref}; my $start = $self->start || ''; my $stop = $self->stop || ''; if (ref($label) && overload::StrVal($self) eq overload::StrVal($label->ref)) { $label = $self->abs_ref; $start = $self->abs_start; $stop = $self->abs_end; } return "$label:$start,$stop";}
contained_features | description | prev | next | Top |
my $self = shift; local $self->{whole} = 0; my @args = $self->_process_feature_args(@_); return $self->factory->contained_features(@args); } # *contains = \&contained_features;}
contained_in | description | prev | next | Top |
my $self = shift; local $self->{whole} = 0; my @args = $self->_process_feature_args(@_); return $self->factory->contained_in(@args);}
contains | description | prev | next | Top |
my $self = shift; my($other,$so) = @_; return $self->SUPER::overlaps(@_) unless $other->isa('Bio::DB::GFF::RelSegment'); return if $self->abs_ref ne $other->abs_ref; return unless $self->abs_low <= $other->abs_low; return unless $self->abs_high >= $other->abs_high; 1;}
end | description | prev | next | Top |
my $self = shift; return $self->strand < 0 ? $self->{start} : $self->{stop} if $self->absolute; $self->_abs2rel($self->{stop}); } *stop =\& end;}
features | description | prev | next | Top |
my $self = shift; my @args = $self->_process_feature_args(@_); return $self->factory->overlapping_features(@args);}
get_feature_stream | description | prev | next | Top |
my $self = shift; my @args = $_[0] =~ /^-/ ? (@_,-iterator=>1) : (-types=>\@_,-iterator=>1); $self->features(@args);}
intersection | description | prev | next | Top |
my $self = shift; my (@ranges) = @_; unshift @ranges,$self if ref $self; $ranges[0]->isa('Bio::DB::GFF::RelSegment') or return $self->SUPER::intersection(@_); my $ref = $ranges[0]->abs_ref; my ($low,$high); foreach (@ranges) { return unless $_->can('abs_ref'); $ref eq $_->abs_ref or return; $low = $_->abs_low if !defined($low) or $low < $_->abs_low; $high = $_->abs_high if !defined($high) or $high > $_->abs_high; } return unless $low < $high; $self->new(-factory=> $self->factory, -seq => $ref, -start => $low, -stop => $high);}
length | description | prev | next | Top |
my $self = shift; return unless defined $self->abs_end; abs($self->abs_end - $self->abs_start) + 1;}
new | description | prev | next | Top |
my $package = shift; my ($factory,$name,$start,$stop,$refseq,$class,$refclass,$offset,$length,$force_absolute,$nocheck) = rearrange([ 'FACTORY', [qw(NAME SEQ SEQUENCE SOURCESEQ)], [qw(START BEGIN)], [qw(STOP END)], [qw(REFSEQ REF REFNAME)], [qw(CLASS SEQCLASS)], qw(REFCLASS), [qw(OFFSET OFF)], [qw(LENGTH LEN)], [qw(ABSOLUTE)], [qw(NOCHECK FORCE)], ],@_); $package = ref $package if ref $package; $factory or $package->throw("new(): provide a -factory argument"); # to allow people to use segments as sources}
if (ref($name) && $name->isa('Bio::DB::GFF::Segment')) { $start = 1 unless defined $start; $stop = $name->length unless defined $stop; return $name->subseq($start,$stop); } my @object_results; # support for Featname objects
if (ref($name) && $name->can('class')) { $class = $name->class; $name = $name->name; } # if the class of the landmark is not specified then default to 'Sequence'
$class ||= eval{$factory->default_class} || 'Sequence'; # confirm that indicated sequence is actually in the database!
my @abscoords; # abscoords() will now return an array ref, each element of which is
# ($absref,$absclass,$absstart,$absstop,$absstrand)
if ($nocheck) { $force_absolute++; $start = 1; } if ($force_absolute && defined($start)) { # absolute position is given to us
@abscoords = ([$name,$class,$start,$stop,'+']); } else { my $result = $factory->abscoords($name,$class,$force_absolute ? $name : ()) or return; @abscoords = @$result; } foreach (@abscoords) { my ($absref,$absclass,$absstart,$absstop,$absstrand,$sname) = @$_; $sname = $name unless defined $sname; my ($this_start,$this_stop,$this_length) = ($start,$stop,$length); # partially fill in object
my $self = bless { factory => $factory },$package; $absstrand ||= '+'; # an explicit length overrides start and stop
if (defined $offset) { warn "new(): bad idea to call new() with both a start and an offset" if defined $this_start; $this_start = $offset+1; } if (defined $this_length) { warn "new(): bad idea to call new() with both a stop and a length" if defined $this_stop; $this_stop = $this_start + $length - 1; } # this allows a SQL optimization way down deep
$self->{whole}++ if $absref eq $sname and !defined($this_start) and !defined($this_stop); $this_start = 1 if !defined $this_start; $this_stop = $absstop-$absstart+1 if !defined $this_stop; $this_length = $this_stop - $this_start + 1; # now offset to correct subsegment based on desired start and stop
if ($force_absolute) { ($this_start,$this_stop) = ($absstart,$absstop); $self->absolute(1); } elsif ($absstrand eq '+') { $this_start = $absstart + $this_start - 1; $this_stop = $this_start + $this_length - 1; } else { $this_start = $absstop - ($this_start - 1); $this_stop = $absstop - ($this_stop - 1); } # handle truncation in either direction
# This only happens if the segment runs off the end of
# the reference sequence
if ($factory->strict_bounds_checking && (($this_start < $absstart) || ($this_stop > $absstop))) { # return empty if we are completely off the end of the ref se
next unless $this_start<=$absstop && $this_stop>=$absstart; if (my $a = $factory->abscoords($absref,'Sequence')) { my $refstart = $a->[0][2]; my $refstop = $a->[0][3]; if ($this_start < $refstart) { $this_start = $refstart; $self->{truncated}{start}++; } if ($this_stop > $refstop) { $this_stop = $absstop; $self->{truncated}{stop}++; } } } @{$self}{qw(sourceseq start stop strand class)} = ($absref,$this_start,$this_stop,$absstrand,$absclass); # handle reference sequence
if (defined $refseq) { $refclass = $refseq->class if $refseq->can('class'); $refclass ||= 'Sequence'; my ($refref,$refstart,$refstop,$refstrand) = $factory->abscoords($refseq,$refclass); unless ($refref eq $absref) { $self->error("reference sequence is on $refref but source sequence is on $absref"); return; } $refstart = $refstop if $refstrand eq '-'; @{$self}{qw(ref refstart refstrand)} = ($refseq,$refstart,$refstrand); } else { $absstart = $absstop if $absstrand eq '-'; @{$self}{qw(ref refstart refstrand)} = ($sname,$absstart,$absstrand); } push @object_results,$self; } return wantarray ? @object_results : $object_results[0]; } # overridden methods
# start, stop, length
new_from_segment | description | prev | next | Top |
my $package = shift; $package = ref $package if ref $package; my $segment = shift; my $new = {}; @{$new}{qw(factory sourceseq start stop strand class ref refstart refstrand)} = @{$segment}{qw(factory sourceseq start stop strand class ref refstart refstrand)}; return bless $new,__PACKAGE__;}
overlaps | description | prev | next | Top |
my $self = shift; my($other,$so) = @_; return $self->SUPER::overlaps(@_) unless $other->isa('Bio::DB::GFF::RelSegment'); return if $self->abs_ref ne $other->abs_ref; return if $self->abs_low > $other->abs_high; return if $self->abs_high < $other->abs_low; 1;}
refseq | description | prev | next | Top |
my $self = shift; my $g = $self->{ref}; if (@_) { my ($newref,$newclass); if (@_ == 2) { $newclass = shift; $newref = shift; } else { $newref = shift; $newclass = 'Sequence'; } defined $newref or $self->throw('refseq() called with an undef reference sequence'); # support for Featname objects}
$newclass = $newref->class if ref($newref) && $newref->can('class'); # $self->throw("Cannot define a segment's reference sequence in terms of itself!")
# if ref($newref) and overload::StrVal($newref) eq overload::StrVal($self);
my ($refsource,undef,$refstart,$refstop,$refstrand); if ($newref->isa('Bio::DB::GFF::RelSegment')) { ($refsource,undef,$refstart,$refstop,$refstrand) = ($newref->sourceseq,undef,$newref->abs_start,$newref->abs_end,$newref->abs_strand >= 0 ? '+' : '-'); } else { my $coords = $self->factory->abscoords($newref,$newclass); foreach (@$coords) { # find the appropriate one
($refsource,undef,$refstart,$refstop,$refstrand) = @$_; last if $refsource eq $self->{sourceseq}; } } $self->throw("can't set reference sequence: $newref and $self are on different sequence segments") unless $refsource eq $self->{sourceseq}; @{$self}{qw(ref refstart refstrand)} = ($newref,$refstart,$refstrand); $self->absolute(0); } return $self->absolute ? $self->sourceseq : $g;
rel2abs | description | prev | next | Top |
my $self = shift; my @result; if ($self->absolute) { @result = @_; } else { my ($abs_start,$abs_strand) = ($self->abs_start,$self->abs_strand); @result = $abs_strand < 0 ? map { $abs_start - $_ + 1 } @_ : map { $_ + $abs_start - 1 } @_; } # if called with a single argument, caller will expect a single scalar reply}
# not the size of the returned array!
return $result[0] if @result == 1 and !wantarray; @result;
start | description | prev | next | Top |
my $self = shift; return $self->strand < 0 ? $self->{stop} : $self->{start} if $self->absolute; $self->_abs2rel($self->{start});}
strand | description | prev | next | Top |
my $self = shift; if ($self->absolute) { return _to_strand($self->{strand}); } return $self->stop <=> $self->start;}
subseq | description | prev | next | Top |
my $self = shift; my $obj = $self->SUPER::subseq(@_); bless $obj,__PACKAGE__; # always bless into the generic RelSegment package}
types | description | prev | next | Top |
my $self = shift; my ($ref,$class,$start,$stop,$strand) = @{$self}{qw(sourceseq class start stop strand)}; ($start,$stop) = ($stop,$start) if $strand eq '-'; my @args; if (@_ && $_[0] !~ /^-/) { @args = (-type =>\@ _) } else { @args = @_; } $self->factory->types(-ref => $ref, -class => $class, -start=> $start, -stop => $stop, @args);}
union | description | prev | next | Top |
my $self = shift; my (@ranges) = @_; unshift @ranges,$self if ref $self; $ranges[0]->isa('Bio::DB::GFF::RelSegment') or return $self->SUPER::union(@_); my $ref = $ranges[0]->abs_ref; my ($low,$high); foreach (@ranges) { return unless $_->can('abs_ref'); $ref eq $_->abs_ref or return; $low = $_->abs_low if !defined($low) or $low > $_->abs_low; $high = $_->abs_high if !defined($high) or $high < $_->abs_high; } $self->new(-factory=> $self->factory, -seq => $ref, -start => $low, -stop => $high); } 1; __END__}
API | Top |
top_SeqFeatures | Top |
Title : top_SeqFeaturesAlias for features(). Provided for Bio::SeqI compatibility.
Usage :
Function:
Example :
Returns :
Args :
all_SeqFeatures | Top |
Title : all_SeqFeaturesAlias for features(). Provided for Bio::SeqI compatibility.
Usage :
Function:
Example :
Returns :
Args :
sub_SeqFeatures | Top |
Title : sub_SeqFeaturesAlias for features(). Provided for Bio::SeqI compatibility.
Usage :
Function:
Example :
Returns :
Args :
get_seq_stream | Top |
Title : get_seq_streamThis is the same as feature_stream(), and is provided for Bioperl
Usage : $stream = $s->get_seq_stream(@args)
Function: get a stream of features that overlap this segment
Returns : a Bio::SeqIO::Stream-compliant stream
Args : see below
Status : Public
$stream = $s->get_seq_stream('exon');
while (my $exon = $stream->next_seq) {
print $exon->start,"\n";
}
overlapping_features | Top |
Title : overlapping_featuresThis is an alias for the features() method, and takes the same
Usage : @features = $s->overlapping_features(@args)
Function: get features that overlap this segment
Returns : a list of Bio::DB::GFF::Feature objects
Args : see features()
Status : Public
Internal Methods | Top |
Bio::RangeI Methods | Top |
BUGS | Top |
SEE ALSO | Top |
AUTHOR | Top |