Back to index

python-biopython  1.60
Public Member Functions | Private Member Functions
Bio.SeqFeature.WithinPosition Class Reference
Inheritance diagram for Bio.SeqFeature.WithinPosition:
Inheritance graph
[legend]
Collaboration diagram for Bio.SeqFeature.WithinPosition:
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 within some coordinates.

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 ((1.4)..100). This
indicates that the start of the sequence is somewhere between 1
and 4. Since this is a start coordindate, it should acts like
it is at position 1 (or in Python counting, 0).

>>> p = WithinPosition(10,10,13)
>>> p
WithinPosition(10, left=10, right=13)
>>> print p
(10.13)
>>> int(p)
10

Basic integer comparisons and operations should work as though
this were a plain integer:

>>> p == 10
True
>>> p in [9,10,11]
True
>>> p < 11
True
>>> p + 10
20

>>> isinstance(p, WithinPosition)
True
>>> isinstance(p, AbstractPosition)
True
>>> isinstance(p, int)
True

Note this also applies for comparison to other position objects,
where again the integer behaviour is used:

>>> p == 10
True
>>> p == ExactPosition(10)
True
>>> p == BeforePosition(10)
True
>>> p == AfterPosition(10)
True

If this were an end point, you would want the position to be 13:

>>> p2 = WithinPosition(13,10,13)
>>> p2
WithinPosition(13, left=10, right=13)
>>> print p2
(10.13)
>>> int(p2)
13
>>> p2 == 13
True
>>> p2 == ExactPosition(13)
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:

>>> p.position == p2.position == 10
True
>>> p.extension == p2.extension == 3
True
>>> int(p) == int(p2)
False
>>> p == 10
True
>>> p2 == 13
True

Definition at line 878 of file SeqFeature.py.


Member Function Documentation

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

Definition at line 962 of file SeqFeature.py.

00962 
00963     def __new__(cls, position, left, right):
00964         assert position==left or position==right
00965         obj = int.__new__(cls, position)
00966         obj._left = left
00967         obj._right = right
00968         return obj

String representation of the WithinPosition location for debugging.

Reimplemented from Bio.SeqFeature.AbstractPosition.

Definition at line 969 of file SeqFeature.py.

00969 
00970     def __repr__(self):
00971         """String representation of the WithinPosition location for debugging."""
00972         return "%s(%i, left=%i, right=%i)" \
00973                % (self.__class__.__name__, int(self),
00974                   self._left, self._right)

Definition at line 975 of file SeqFeature.py.

00975 
00976     def __str__(self):
00977         return "(%s.%s)" % (self._left, self._right)

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

Definition at line 993 of file SeqFeature.py.

00993 
00994     def _flip(self, length):
00995         return self.__class__(length - int(self),
00996                               length - self._right,
00997                               length - self._left)

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

Definition at line 988 of file SeqFeature.py.

00988 
00989     def _shift(self, offset):
00990         return self.__class__(int(self) + offset,
00991                               self._left + offset,
00992                               self._right + offset)

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

Definition at line 984 of file SeqFeature.py.

00984 
00985     def extension(self):
00986         """Legacy attribute to get extension (from left to right) as an integer (OBSOLETE)."""
00987         return self._right - self._left

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

Definition at line 979 of file SeqFeature.py.

00979 
00980     def position(self):
00981         """Legacy attribute to get (left) position as integer (OBSOLETE)."""
00982         return self._left

Here is the caller graph for this function:


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