Bio::DB::GFF Segment
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::DB::GFF::Segment -- Simple DNA segment object
Package variables
No package variables defined.
Included modules
Bio::Annotation::Collection
Bio::Das::SegmentI
Bio::RangeI
Bio::Root::Root
Bio::SeqI
Inherit
Bio::Das::SegmentI Bio::RangeI Bio::Root::Root Bio::SeqI
Synopsis
See Bio::DB::GFF.
Description
Bio::DB::GFF::Segment provides the basic representation of a range of
DNA contained in a GFF database. It is the base class from which the
Bio::DB::GFF::RelSegment and Bio::DB::GFF::Feature classes are
derived.
Generally, you will not create or manipulate Bio::DB::GFF::Segment
objects directly, but use those that are returned by the Bio::DB::GFF
module.
Methods
newDescriptionCode
factoryDescriptionCode
startDescriptionCode
endDescriptionCode
lengthDescriptionCode
strandDescriptionCode
lowDescriptionCode
highDescriptionCode
sourceseqDescriptionCode
classDescriptionCode
subseqDescriptionCode
seqDescriptionCode
primary_seqDescriptionCode
typeDescriptionCode
equalsDescriptionCode
asStringDescriptionCode
cloneDescriptionCode
errorDescriptionCode
abs_strandDescriptionCode
refDescriptionCode
seq_idDescriptionCode
truncatedDescriptionCode
overlaps
No description
Code
contains
No description
Code
intersection
No description
Code
union
No description
Code
overlap_extent
No description
Code
primary_idDescriptionCode
display_nameDescriptionCode
accession_numberDescriptionCode
alphabetDescriptionCode
descDescriptionCode
speciesDescriptionCode
annotationDescriptionCode
is_circularDescriptionCode
Methods description
newcode    nextTop
 Title   : new
 Usage   : $s = Bio::DB::GFF::Segment->new(@args)
 Function: create a new segment
 Returns : a new Bio::DB::GFF::Segment object
 Args    : see below
 Status  : Public
This method creates a new Bio::DB::GFF::Segment object. Generally
this is called automatically by the Bio::DB::GFF module and
derivatives.
There are five positional arguments:
 $factory      a Bio::DB::GFF::Adaptor to use for database access
 $sourceseq    ID of the source sequence
 $sourceclass  class of the source sequence
 $start        start of the desired segment relative to source sequence
 $stop         stop of the desired segment relative to source sequence
factorycodeprevnextTop
 Title   : factory
 Usage   : $s->factory
 Function: get the factory object
 Returns : a Bio::DB::GFF::Adaptor
 Args    : none
 Status  : Public
This is a read-only accessor for the Bio::DB::GFF::Adaptor object used
to create the segment.
startcodeprevnextTop
 Title   : start
 Usage   : $s->start
 Function: start of segment
 Returns : integer
 Args    : none
 Status  : Public
This is a read-only accessor for the start of the segment.
endcodeprevnextTop
 Title   : end
 Usage   : $s->end
 Function: end of segment
 Returns : integer
 Args    : none
 Status  : Public
This is a read-only accessor for the end of the segment.
lengthcodeprevnextTop
 Title   : length
 Usage   : $s->length
 Function: length of segment
 Returns : integer
 Args    : none
 Status  : Public
Returns the length of the segment. Always a positive number.
strandcodeprevnextTop
 Title   : strand
 Usage   : $s->strand
 Function: strand of segment
 Returns : +1,0,-1
 Args    : none
 Status  : Public
Returns the strand on which the segment resides, either +1, 0 or -1.
lowcodeprevnextTop
 Title   : low
 Usage   : $s->low
 Function: return lower coordinate
 Returns : lower coordinate
 Args    : none
 Status  : Public
Returns the lower coordinate, either start or end.
highcodeprevnextTop
 Title   : high
 Usage   : $s->high
 Function: return higher coordinate
 Returns : higher coordinate
 Args    : none
 Status  : Public
Returns the higher coordinate, either start or end.
sourceseqcodeprevnextTop
 Title   : sourceseq
 Usage   : $s->sourceseq
 Function: get the segment source
 Returns : a string
 Args    : none
 Status  : Public
Returns the name of the source sequence for this segment.
classcodeprevnextTop
 Title   : class
 Usage   : $s->class([$newclass])
 Function: get the source sequence class
 Returns : a string
 Args    : new class (optional)
 Status  : Public
Gets or sets the class for the source sequence for this segment.
subseqcodeprevnextTop
 Title   : subseq
 Usage   : $s->subseq($start,$stop)
 Function: generate a subsequence
 Returns : a Bio::DB::GFF::Segment object
 Args    : start and end of subsequence
 Status  : Public
This method generates a new segment from the start and end positions
given in the arguments. If stop < start, then the strand is reversed.
seqcodeprevnextTop
 Title   : seq
 Usage   : $s->seq
 Function: get the sequence string for this segment
 Returns : a string
 Args    : none
 Status  : Public
Returns the sequence for this segment as a simple string. (-) strand
segments are automatically reverse complemented
This method is also called dna() and protein() for backward
compatibility with AceDB.
primary_seqcodeprevnextTop
 Title   : primary_seq
 Usage   : $s->primary_seq
 Function: returns a Bio::PrimarySeqI compatible object
 Returns : a Bio::PrimarySeqI object
 Args    : none
 Status  : Public
This is for compatibility with BioPerl's separation of SeqI
from PrimarySeqI. It just returns itself.
typecodeprevnextTop
 Title   : type
 Usage   : $s->type
 Function: return the string "feature"
 Returns : the string "feature"
 Args    : none
 Status  : Public
This is for future sequence ontology-compatibility and
represents the default type of a feature on the genome
equalscodeprevnextTop
 Title   : equals
 Usage   : $s->equals($d)
 Function: segment equality
 Returns : true, if two segments are equal
 Args    : another segment
 Status  : Public
Returns true if the two segments have the same source sequence, start and stop.
asStringcodeprevnextTop
 Title   : asString
 Usage   : $s->asString
 Function: human-readable string for segment
 Returns : a string
 Args    : none
 Status  : Public
Returns a human-readable string representing this sequence. Format
is:
   sourceseq/start,stop
clonecodeprevnextTop
 Title   : clone
 Usage   : $copy = $s->clone
 Function: make a copy of this segment
 Returns : a Bio::DB::GFF::Segment object
 Args    : none
 Status  : Public
This method creates a copy of the segment and returns it.
errorcodeprevnextTop
 Title   : error
 Usage   : $error = $s->error([$new_error])
 Function: get or set the last error
 Returns : a string
 Args    : an error message (optional)
 Status  : Public
In case of a fault, this method can be used to obtain the last error
message. Internally it is called to set the error message.
abs_strandcodeprevnextTop
 Title   : abs_strand
 Usage   : $s->abs_strand
 Function: the absolute strand of the segment
 Returns : +1,0,-1
 Args    : none
 Status  : Public
This is an alias to strand(), and provided for API compatibility with
Bio::DB::GFF::RelSegment.
refcodeprevnextTop
 Title   : ref
 Usage   : $s->refseq
 Function: get or set the reference sequence
 Returns : a string
 Args    : none
 Status  : Public
An alias for refseq()
seq_idcodeprevnextTop
 Title   : seq_id
 Usage   : $ref = $s->seq_id
 Function: get the reference sequence in a LocationI-compatible way
 Returns : a string
 Args    : none
 Status  : Public
An alias for refseq() but only allows reading.
truncatedcodeprevnextTop
 Title   : truncated
 Usage   : $truncated = $s->truncated
 Function: Flag indicating that the segment was truncated during creation
 Returns : A boolean flag
 Args    : none
 Status  : Public
This indicates that the sequence was truncated during creation. The
returned flag is undef if no truncation occured. If truncation did
occur, the flag is actually an array ref in which the first element is
true if truncation occurred on the left, and the second element
occurred if truncation occurred on the right.
primary_idcodeprevnextTop
 Title   : primary_id
 Usage   : $unique_implementation_key = $obj->primary_id;
 Function: Returns the unique id for this object in this
           implementation. This allows implementations to manage their
           own object ids in a way the implementaiton can control
           clients can expect one id to map to one object.

           For sequences with no accession number, this method should
           return a stringified memory location.

 Returns : A string
 Args    : None
 Status  : Virtual
display_namecodeprevnextTop
 Title   : display_name
 Usage   : $id = $obj->display_name or $obj->display_name($newid);
 Function: Gets or sets the display id, also known as the common name of
           the Seq object.

           The semantics of this is that it is the most likely string
           to be used as an identifier of the sequence, and likely to
           have "human" readability.  The id is equivalent to the LOCUS
           field of the GenBank/EMBL databanks and the ID field of the
           Swissprot/sptrembl database. In fasta format, the >(\S+) is
           presumed to be the id, though some people overload the id
           to embed other information. Bioperl does not use any
           embedded information in the ID field, and people are
           encouraged to use other mechanisms (accession field for
           example, or extending the sequence object) to solve this.

           Notice that $seq->id() maps to this function, mainly for
           legacy/convenience issues.
 Returns : A string
 Args    : None or a new id
Note, this used to be called display_id(), and this name is preserved for
backward compatibility. The default is to return the seq_id().
accession_numbercodeprevnextTop
 Title   : accession_number
 Usage   : $unique_biological_key = $obj->accession_number;
 Function: Returns the unique biological id for a sequence, commonly
           called the accession_number. For sequences from established
           databases, the implementors should try to use the correct
           accession number. Notice that primary_id() provides the
           unique id for the implemetation, allowing multiple objects
           to have the same accession number in a particular implementation.

           For sequences with no accession number, this method should return
           "unknown".
 Returns : A string
 Args    : None
alphabetcodeprevnextTop
 Title   : alphabet
 Usage   : if( $obj->alphabet eq 'dna' ) { /Do Something/ }
 Function: Returns the type of sequence being one of
           'dna', 'rna' or 'protein'. This is case sensitive.

           This is not called  because this would cause
           upgrade problems from the 0.5 and earlier Seq objects.

 Returns : a string either 'dna','rna','protein'. NB - the object must
           make a call of the type - if there is no type specified it
           has to guess.
 Args    : none
 Status  : Virtual
desccodeprevnextTop
 Title   : desc
 Usage   : $seqobj->desc($string) or $seqobj->desc()
 Function: Sets or gets the description of the sequence
 Example :
 Returns : The description
 Args    : The description or none
speciescodeprevnextTop
 Title   : species
 Usage   : $species = $seq->species() or $seq->species($species)
 Function: Gets or sets the species
 Example :
 Returns : Bio::Species object
 Args    : None or Bio::Species object
See Bio::Species for more information
annotationcodeprevnextTop
 Title   : annotation
 Usage   : $ann = $seq->annotation or $seq->annotation($annotation)
 Function: Gets or sets the annotation
 Example :
 Returns : Bio::Annotation object
 Args    : None or Bio::Annotation object
See Bio::Annotation for more information
is_circularcodeprevnextTop
 Title   : is_circular
 Usage   : if( $obj->is_circular) { /Do Something/ }
 Function: Returns true if the molecule is circular
 Returns : Boolean value
 Args    : none
Methods code
newdescriptionprevnextTop
sub new {
  my $class = shift;
  my ($factory,$segclass,$segname,$start,$stop) = @_;
  $segclass = $segname->class if ref($segname) && $segname->can('class');
  $segclass ||= 'Sequence';

  $factory or $class->throw("->new(): provide a factory argument");
  $class = ref $class if ref $class;
  return bless { factory   => $factory,
		 sourceseq => $segname,
		 class     => $segclass,
		 start     => $start,
		 stop      => $stop,
		 strand    => 0,
	       },$class;
}
factorydescriptionprevnextTop
sub factory {
 shift->{factory}
}
startdescriptionprevnextTop
sub start {
 shift->{start}
}
enddescriptionprevnextTop
sub end {
 shift->{stop}
}
lengthdescriptionprevnextTop
sub length {
 abs($_[0]->{start} - $_[0]->{stop})+1
}
stranddescriptionprevnextTop
sub strand {
  my $self = shift;
  0;
}
lowdescriptionprevnextTop
sub low {
  my $self = shift;
  my ($start,$stop) = ($self->start,$self->stop);
  return $start < $stop ? $start : $stop;
}
highdescriptionprevnextTop
sub high {
  my $self = shift;
  my ($start,$stop) = ($self->start,$self->stop);
  return $start > $stop ? $start : $stop;
}
sourceseqdescriptionprevnextTop
sub sourceseq {
 shift->{sourceseq}
}
classdescriptionprevnextTop
sub class {
   my $self = shift;
  my $d = $self->{class};
  $self->{class} = shift if @_;
  $d;
}
subseqdescriptionprevnextTop
sub subseq {
  my $self = shift;
  my ($newstart,$newstop) = @_;
  my ($refseq,$start,$stop,$class) = ($self->{sourceseq},
				      $self->{start},$self->{stop},
				      $self->class);

  # We deliberately force subseq to return objects of type RelSegment
# Otherwise, when we get a subsequence from a Feature object,
# its method and source go along for the ride, which is incorrect.
my $new = $self->new_from_segment($self); if ($start <= $stop) { @{$new}{qw(start stop)} = ($start + $newstart - 1, $start + $newstop - 1); } else { @{$new}{qw(start stop)} = ($start - ($newstart - 1), $start - ($newstop - 1)), } $new;
}
seqdescriptionprevnextTop
sub seq {
  my $self = shift;
  my ($ref,$class,$start,$stop,$strand) 
    = @{$self}{qw(sourceseq class start stop strand)};
#  ($start,$stop) = ($stop,$start) if $strand eq '-';
$self->factory->dna($ref,$start,$stop,$class);
}
primary_seqdescriptionprevnextTop
sub primary_seq {
 shift
}
typedescriptionprevnextTop
sub type {
 "feature"
}
equalsdescriptionprevnextTop
sub equals {
  my $self = shift;
  my $peer = shift;
  return unless defined $peer;
  return $self->asString eq $peer unless ref($peer) && $peer->isa('Bio::DB::GFF::Segment');
  return $self->{start} eq $peer->{start}
         && $self->{stop}  eq $peer->{stop}
         && $self->{sourceseq} eq $peer->{sourceseq};
}
asStringdescriptionprevnextTop
sub asString {
  my $self = shift;
  my $label = $self->refseq;
  my $start = $self->start;
  my $stop  = $self->stop;
  return "$label:$start,$stop";
}
clonedescriptionprevnextTop
sub clone {
  my $self = shift;
  my %h = %$self;
  return bless\% h,ref($self);
}
errordescriptionprevnextTop
sub error {
  my $self = shift;
  my $g = $self->{error};
  $self->{error} = shift if @_;
  $g;
}
abs_stranddescriptionprevnextTop
sub abs_strand {
  my $self = shift;
  return $self->abs_end <=> $self->abs_start;
}
refdescriptionprevnextTop
sub ref {
 shift->refseq(@_)
}
seq_iddescriptionprevnextTop
sub seq_id {
 shift->refseq
}
truncateddescriptionprevnextTop
sub truncated {
  my $self = shift;
  my $hash = $self->{truncated} or return;
  CORE::ref($hash) eq 'HASH' or return [1,1];  # paranoia -- not that this would ever happen ;-)
return [$hash->{start},$hash->{stop}];
}
overlapsdescriptionprevnextTop
sub overlaps {
  my $self  = shift;
  my($other,$so) = @_;
  if ($other->isa('Bio::DB::GFF::RelSegment')) {
    return if $self->abs_ref ne $other->abs_ref;
  }
  $self->SUPER::overlaps(@_);
}
containsdescriptionprevnextTop
sub contains {
  my $self  = shift;
  my($other,$so) = @_;
  if ($other->isa('Bio::DB::GFF::RelSegment')) {
    return if $self->abs_ref ne $other->abs_ref;
  }
  $self->SUPER::contains(@_);
}
intersectiondescriptionprevnextTop
sub intersection {
  my $self  = shift;
  my($other,$so) = @_;
  if ($other->isa('Bio::DB::GFF::RelSegment')) {
    return if $self->abs_ref ne $other->abs_ref;
  }
  $self->SUPER::intersection(@_);
}
uniondescriptionprevnextTop
sub union {
  my $self  = shift;
  my($other) = @_;
  if ($other->isa('Bio::DB::GFF::RelSegment')) {
    return if $self->abs_ref ne $other->abs_ref;
  }
  $self->SUPER::union(@_);
}
overlap_extentdescriptionprevnextTop
sub overlap_extent {
  my $self  = shift;
  my($other) = @_;
  if ($other->isa('Bio::DB::GFF::RelSegment')) {
    return if $self->abs_ref ne $other->abs_ref;
  }
  $self->SUPER::overlap_extent(@_);
}
primary_iddescriptionprevnextTop
sub primary_id {
   my ($obj,$value) = @_;

   if( defined $value) {
      $obj->{'primary_id'} = $value;
    }
   if( ! exists $obj->{'primary_id'} ) {
       return "$obj";
   }
   return $obj->{'primary_id'};
}
display_namedescriptionprevnextTop
sub display_name {
 shift->seq_id
}
accession_numberdescriptionprevnextTop
sub accession_number {
    return 'unknown';
}
alphabetdescriptionprevnextTop
sub alphabet {
    return 'dna'; # no way this will be anything other than dna!
}
descdescriptionprevnextTop
sub desc {
 shift->asString
}
speciesdescriptionprevnextTop
sub species {
    my ($self, $species) = @_;
    if ($species) {
        $self->{'species'} = $species;
    } else {
        return $self->{'species'};
    }
}
annotationdescriptionprevnextTop
sub annotation {
   my ($obj,$value) = @_;
   if( defined $value || ! defined $obj->{'annotation'} ) {
       $value = new Bio::Annotation::Collection() unless defined $value;
      $obj->{'annotation'} = $value;
    }
    return $obj->{'annotation'};
}
is_circulardescriptionprevnextTop
sub is_circular {
    return 0;
}
General documentation
APITop
The remainder of this document describes the API for
Bio::DB::GFF::Segment.
stopTop
 Title   : stop
 Usage   : $s->stop
 Function: stop of segment
 Returns : integer
 Args    : none
 Status  : Public
This is an alias for end(), provided for AcePerl compatibility.
Relative Addressing MethodsTop
The following methods are provided for compatibility with
Bio::DB::GFF::RelSegment, which provides relative addressing
functions.
abs_startTop
 Title   : abs_start
 Usage   : $s->abs_start
 Function: the absolute start of the segment
 Returns : an integer
 Args    : none
 Status  : Public
This is an alias to start(), and provided for API compatibility with
Bio::DB::GFF::RelSegment.
abs_endTop
 Title   : abs_end
 Usage   : $s->abs_end
 Function: the absolute stop of the segment
 Returns : an integer
 Args    : none
 Status  : Public
This is an alias to stop(), and provided for API compatibility with
Bio::DB::GFF::RelSegment.
abs_refTop
 Title   : abs_ref
 Usage   : $s->abs_ref
 Function: the reference sequence for this segment
 Returns : a string
 Args    : none
 Status  : Public
This is an alias to sourceseq(), and is here to provide API
compatibility with Bio::DB::GFF::RelSegment.
refseqTop
 Title   : refseq
 Usage   : $s->refseq
 Function: get or set the reference sequence
 Returns : a string
 Args    : none
 Status  : Public
Examine or change the reference sequence. This is an alias to
sourceseq(), provided here for API compatibility with
Bio::DB::GFF::RelSegment.
Bio::RangeI MethodsTop
The following Bio::RangeI methods are supported:
overlaps(), contains(), equals(),intersection(),union(),overlap_extent()
Bio::SeqI implementationTop
BUGSTop
Report them please.
SEE ALSOTop
bioperl
AUTHORTop
Lincoln Stein <lstein@cshl.org>.
Copyright (c) 2001 Cold Spring Harbor Laboratory.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
CONTRIBUTORSTop
Jason Stajich <jason@bioperl.org>.