Back to index

python-biopython  1.60
Public Member Functions | Private Member Functions
Bio.SeqFeature.BetweenPosition Class Reference
Inheritance diagram for Bio.SeqFeature.BetweenPosition:
Inheritance graph
[legend]
Collaboration diagram for Bio.SeqFeature.BetweenPosition:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __new__
def __repr__
def __str__
def position
def extension

Private Member Functions

def _shift
def _flip

Detailed Description

Specify the position of a boundary between two coordinates (OBSOLETE?).

Arguments:
o position - The default integer position
o left - The start (left) position of the boundary
o right - The end (right) position of the boundary

This allows dealing with a position like 123^456. This                                                  
indicates that the start of the sequence is somewhere between
123 and 456. It is up to the parser to set the position argument
to either boundary point (depending on if this is being used as
a start or end of the feature). For example as a feature end:

>>> p = BetweenPosition(456, 123, 456)
>>> p
BetweenPosition(456, left=123, right=456)
>>> print p
(123^456)
>>> int(p)
456

Integer equality and comparison use the given position,

>>> p == 456
True
>>> p in [455, 456, 457]
True
>>> p > 300
True

The old legacy properties of position and extension give the
starting/lower/left position as an integer, and the distance
to the ending/higher/right position as an integer. Note that
the position object will act like either the left or the right
end-point depending on how it was created:

>>> p2 = BetweenPosition(123, left=123, right=456)
>>> p.position == p2.position == 123
True
>>> p.extension
333
>>> p2.extension
333
>>> p.extension == p2.extension == 333
True
>>> int(p) == int(p2)
False
>>> p == 456
True
>>> p2 == 123
True

Note this potentially surprising behaviour:

>>> BetweenPosition(123, left=123, right=456) == ExactPosition(123)
True
>>> BetweenPosition(123, left=123, right=456) == BeforePosition(123)
True
>>> BetweenPosition(123, left=123, right=456) == AfterPosition(123)
True

i.e. For equality (and sorting) the position objects behave like
integers.

Definition at line 998 of file SeqFeature.py.


Member Function Documentation

def Bio.SeqFeature.BetweenPosition.__new__ (   cls,
  position,
  left,
  right 
)

Definition at line 1063 of file SeqFeature.py.

01063 
01064     def __new__(cls, position, left, right):
01065         assert position==left or position==right
01066         obj = int.__new__(cls, position)
01067         obj._left = left
01068         obj._right = right
01069         return obj

String representation of the WithinPosition location for debugging.

Reimplemented from Bio.SeqFeature.AbstractPosition.

Definition at line 1070 of file SeqFeature.py.

01070 
01071     def __repr__(self):
01072         """String representation of the WithinPosition location for debugging."""
01073         return "%s(%i, left=%i, right=%i)" \
01074                % (self.__class__.__name__, int(self),
01075                   self._left, self._right)

Definition at line 1076 of file SeqFeature.py.

01076 
01077     def __str__(self):
01078         return "(%s^%s)" % (self._left, self._right)

def Bio.SeqFeature.BetweenPosition._flip (   self,
  length 
) [private]

Definition at line 1094 of file SeqFeature.py.

01094 
01095     def _flip(self, length):
01096         return self.__class__(length - int(self),
01097                               length - self._right,
01098                               length - self._left)

def Bio.SeqFeature.BetweenPosition._shift (   self,
  offset 
) [private]

Definition at line 1089 of file SeqFeature.py.

01089 
01090     def _shift(self, offset):
01091         return self.__class__(int(self) + offset,
01092                               self._left + offset,
01093                               self._right + offset)

Legacy attribute to get extension (from left to right) as an integer (OBSOLETE).

Definition at line 1085 of file SeqFeature.py.

01085 
01086     def extension(self):
01087         """Legacy attribute to get extension (from left to right) as an integer (OBSOLETE)."""
01088         return self._right - self._left

Legacy attribute to get (left) position as integer (OBSOLETE).

Definition at line 1080 of file SeqFeature.py.

01080 
01081     def position(self):
01082         """Legacy attribute to get (left) position as integer (OBSOLETE)."""
01083         return self._left

Here is the caller graph for this function:


The documentation for this class was generated from the following file: