Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.Restriction.Restriction.FormattedSeq Class Reference

List of all members.

Public Member Functions

def __init__
def __len__
def __repr__
def __eq__
def circularise
def linearise
def to_linear
def to_circular
def is_linear
def finditer
def __getitem__

Public Attributes

 lower
 data
 linear
 klass
 alphabet

Detailed Description

FormattedSeq(seq, [linear=True])-> new FormattedSeq.

Translate a Bio.Seq into a formatted sequence to be used with Restriction.

Roughly:
    remove anything which is not IUPAC alphabet and then add a space
    in front of the sequence to get a biological index instead of a
    python index (i.e. index of the first base is 1 not 0).

    Retains information about the shape of the molecule linear (default)
    or circular. Restriction sites are search over the edges of circular
    sequence.

Definition at line 126 of file Restriction.py.


Constructor & Destructor Documentation

def Bio.Restriction.Restriction.FormattedSeq.__init__ (   self,
  seq,
  linear = True 
)
FormattedSeq(seq, [linear=True])-> new FormattedSeq.

seq is either a Bio.Seq, Bio.MutableSeq or a FormattedSeq.
if seq is a FormattedSeq, linear will have no effect on the
shape of the sequence.

Definition at line 140 of file Restriction.py.

00140 
00141     def __init__(self, seq, linear = True):
00142         """FormattedSeq(seq, [linear=True])-> new FormattedSeq.
00143 
00144         seq is either a Bio.Seq, Bio.MutableSeq or a FormattedSeq.
00145         if seq is a FormattedSeq, linear will have no effect on the
00146         shape of the sequence."""
00147         if isinstance(seq, Seq) or isinstance(seq, MutableSeq):
00148             stringy       = seq.tostring()
00149             self.lower    = stringy.islower()
00150             #Note this adds a leading space to the sequence (!)
00151             self.data     = _check_bases(stringy)
00152             self.linear   = linear
00153             self.klass    = seq.__class__
00154             self.alphabet = seq.alphabet
00155         elif isinstance(seq, FormattedSeq):
00156             self.lower    = seq.lower
00157             self.data     = seq.data
00158             self.linear   = seq.linear
00159             self.alphabet = seq.alphabet
00160             self.klass    = seq.klass   
00161         else:
00162             raise TypeError('expected Seq or MutableSeq, got %s' % type(seq))


Member Function Documentation

Definition at line 169 of file Restriction.py.

00169 
00170     def __eq__(self, other):
00171         if isinstance(other, FormattedSeq):
00172             if repr(self) == repr(other):
00173                 return True
00174             else:
00175                 return False
00176         return False
    

Definition at line 220 of file Restriction.py.

00220 
00221     def __getitem__(self, i):
00222         if self.lower:
00223             return self.klass((self.data[i]).lower(), self.alphabet)
00224         return self.klass(self.data[i], self.alphabet)
00225     

Here is the caller graph for this function:

Definition at line 163 of file Restriction.py.

00163 
00164     def __len__(self):
00165         return len(self.data) - 1

Definition at line 166 of file Restriction.py.

00166 
00167     def __repr__(self):
00168         return 'FormattedSeq(%s, linear=%s)' %(repr(self[1:]), repr(self.linear))

FS.circularise() -> circularise FS

Definition at line 177 of file Restriction.py.

00177 
00178     def circularise(self):
00179         """FS.circularise() -> circularise FS"""
00180         self.linear = False
00181         return

def Bio.Restriction.Restriction.FormattedSeq.finditer (   self,
  pattern,
  size 
)
FS.finditer(pattern, size) -> list.

return a list of pattern into the sequence.
the list is made of tuple (location, pattern.group).
the latter is used with non palindromic sites.
pattern is the regular expression pattern corresponding to the
enzyme restriction site.
size is the size of the restriction enzyme recognition-site size.

Definition at line 205 of file Restriction.py.

00205 
00206     def finditer(self, pattern, size):
00207         """FS.finditer(pattern, size) -> list.
00208 
00209         return a list of pattern into the sequence.
00210         the list is made of tuple (location, pattern.group).
00211         the latter is used with non palindromic sites.
00212         pattern is the regular expression pattern corresponding to the
00213         enzyme restriction site.
00214         size is the size of the restriction enzyme recognition-site size."""
00215         if self.is_linear():
00216             data = self.data
00217         else:
00218             data = self.data + self.data[1:size]
00219         return [(i.start(), i.group) for i in re.finditer(pattern, data)]

Here is the call graph for this function:

FS.is_linear() -> bool.

True if the sequence will analysed as a linear sequence.

Definition at line 199 of file Restriction.py.

00199 
00200     def is_linear(self):
00201         """FS.is_linear() -> bool.
00202 
00203         True if the sequence will analysed as a linear sequence."""
00204         return self.linear

Here is the caller graph for this function:

FS.linearise() -> linearise FS

Definition at line 182 of file Restriction.py.

00182 
00183     def linearise(self):
00184         """FS.linearise() -> linearise FS"""
00185         self.linear = True
00186         return

FS.to_circular() -> new circular FS instance

Definition at line 193 of file Restriction.py.

00193 
00194     def to_circular(self):
00195         """FS.to_circular() -> new circular FS instance"""
00196         new = self.__class__(self)
00197         new.linear = False
00198         return new

FS.to_linear() -> new linear FS instance

Definition at line 187 of file Restriction.py.

00187 
00188     def to_linear(self):
00189         """FS.to_linear() -> new linear FS instance"""
00190         new = self.__class__(self)
00191         new.linear = True
00192         return new


Member Data Documentation

Definition at line 153 of file Restriction.py.

Definition at line 150 of file Restriction.py.

Definition at line 152 of file Restriction.py.

Definition at line 151 of file Restriction.py.

Definition at line 148 of file Restriction.py.


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