Back to index

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

List of all members.

Public Member Functions

def is_defined
def is_ambiguous
def is_unknown
def elucidate
def search
def all_suppliers
def is_equischizomer
def is_neoschizomer
def is_isoschizomer
def equischizomers
def neoschizomers
def isoschizomers
def frequency
def __add__
def __div__
def __rdiv__
def __truediv__
def __rtruediv__
def __floordiv__
def __rfloordiv__
def __str__
def __repr__
def __len__
def __hash__
def __eq__
def __ne__
def __rshift__
def __mod__
def __ge__
def __gt__
def __le__
def __lt__

Public Attributes

 results

Private Member Functions

def _drop
def _mod2

Detailed Description

Implement the methods specific to the enzymes for which the overhang
and the cut are not variable.

Typical example : EcoRI -> G^AATT_C
                  The overhang will always be AATT
Notes:
    Blunt enzymes are always defined. even if there site is GGATCCNNN^_N
    There overhang is always the same : blunt!

Internal use only. Not meant to be instantiated.

Definition at line 1330 of file Restriction.py.


Member Function Documentation

def Bio.Restriction.Restriction.RestrictionType.__add__ (   cls,
  other 
) [inherited]
RE.__add__(other) -> RestrictionBatch().

if other is an enzyme returns a batch of the two enzymes.
if other is already a RestrictionBatch add enzyme to it.

Definition at line 250 of file Restriction.py.

00250 
00251     def __add__(cls, other):
00252         """RE.__add__(other) -> RestrictionBatch().
00253 
00254         if other is an enzyme returns a batch of the two enzymes.
00255         if other is already a RestrictionBatch add enzyme to it."""
00256         if isinstance(other, RestrictionType):
00257             return RestrictionBatch([cls, other])    
00258         elif isinstance(other, RestrictionBatch):
00259             return other.add_nocheck(cls)
00260         else:
00261             raise TypeError
        
def Bio.Restriction.Restriction.RestrictionType.__div__ (   cls,
  other 
) [inherited]
RE.__div__(other) -> list.

RE/other
returns RE.search(other).

Definition at line 262 of file Restriction.py.

00262 
00263     def __div__(cls, other):
00264         """RE.__div__(other) -> list.
00265 
00266         RE/other
00267         returns RE.search(other)."""
00268         return cls.search(other)
    
def Bio.Restriction.Restriction.RestrictionType.__eq__ (   cls,
  other 
) [inherited]
RE == other -> bool

True if RE and other are the same enzyme.

Specifically this checks they are the same Python object.

Definition at line 327 of file Restriction.py.

00327 
00328     def __eq__(cls, other):
00329         """RE == other -> bool
00330 
00331         True if RE and other are the same enzyme.
00332         
00333         Specifically this checks they are the same Python object.
00334         """
00335         #assert (id(cls)==id(other)) == (other is cls) == (cls is other)
00336         return id(cls)==id(other)

def Bio.Restriction.Restriction.RestrictionType.__floordiv__ (   cls,
  other 
) [inherited]
RE.__floordiv__(other) -> list.

RE//other
returns RE.catalyse(other).

Definition at line 290 of file Restriction.py.

00290 
00291     def __floordiv__(cls, other):
00292         """RE.__floordiv__(other) -> list.
00293 
00294         RE//other
00295         returns RE.catalyse(other)."""
00296         return cls.catalyse(other)
    
def Bio.Restriction.Restriction.RestrictionType.__ge__ (   cls,
  other 
) [inherited]
a >= b -> bool.

a is greater or equal than b if the a site is longer than b site.
if their site have the same length sort by alphabetical order of their
names.

Definition at line 373 of file Restriction.py.

00373 
00374     def __ge__(cls, other):
00375         """a >= b -> bool.
00376 
00377         a is greater or equal than b if the a site is longer than b site.
00378         if their site have the same length sort by alphabetical order of their
00379         names."""
00380         if not isinstance(other, RestrictionType):
00381             raise NotImplementedError
00382         if len(cls) > len(other):
00383             return True
00384         elif cls.size == len(other) and cls.__name__ >= other.__name__:
00385             return True
00386         else:
00387             return False

def Bio.Restriction.Restriction.RestrictionType.__gt__ (   cls,
  other 
) [inherited]
a > b -> bool.

sorting order:
    1. size of the recognition site.
    2. if equal size, alphabetical order of the names.

Definition at line 388 of file Restriction.py.

00388 
00389     def __gt__(cls, other):
00390         """a > b -> bool.
00391 
00392         sorting order:
00393                     1. size of the recognition site.
00394                     2. if equal size, alphabetical order of the names."""
00395         if not isinstance(other, RestrictionType):
00396             raise NotImplementedError
00397         if len(cls) > len(other):
00398             return True
00399         elif cls.size == len(other) and cls.__name__ > other.__name__:
00400             return True
00401         else:
00402             return False

Definition at line 322 of file Restriction.py.

00322 
00323     def __hash__(cls):
00324         #Python default is to use id(...)
00325         #This is consistent with the __eq__ implementation
00326         return id(cls)
    
def Bio.Restriction.Restriction.RestrictionType.__le__ (   cls,
  other 
) [inherited]
a <= b -> bool.

sorting order:
    1. size of the recognition site.
    2. if equal size, alphabetical order of the names.

Definition at line 403 of file Restriction.py.

00403 
00404     def __le__(cls, other):
00405         """a <= b -> bool.
00406 
00407         sorting order:
00408                     1. size of the recognition site.
00409                     2. if equal size, alphabetical order of the names."""
00410         if not isinstance(other, RestrictionType):
00411             raise NotImplementedError
00412         elif len(cls) < len(other):
00413             return True
00414         elif len(cls) == len(other) and cls.__name__ <= other.__name__:
00415             return True
00416         else:
00417             return False

RE.__len__() -> int.

length of the recognition site.

Definition at line 316 of file Restriction.py.

00316 
00317     def __len__(cls):
00318         """RE.__len__() -> int.
00319 
00320         length of the recognition site."""
00321         return cls.size
    
def Bio.Restriction.Restriction.RestrictionType.__lt__ (   cls,
  other 
) [inherited]
a < b -> bool.

sorting order:
    1. size of the recognition site.
    2. if equal size, alphabetical order of the names.

Definition at line 418 of file Restriction.py.

00418 
00419     def __lt__(cls, other):
00420         """a < b -> bool.
00421 
00422         sorting order:
00423                     1. size of the recognition site.
00424                     2. if equal size, alphabetical order of the names."""
00425         if not isinstance(other, RestrictionType):
00426             raise NotImplementedError
00427         elif len(cls) < len(other):
00428             return True
00429         elif len(cls) == len(other) and cls.__name__ < other.__name__:
00430             return True
00431         else:
00432             return False
    
def Bio.Restriction.Restriction.RestrictionType.__mod__ (   cls,
  other 
) [inherited]
a % b -> bool.

Test compatibility of the overhang of a and b.
True if a and b have compatible overhang.

Definition at line 363 of file Restriction.py.

00363 
00364     def __mod__(cls, other):
00365         """a % b -> bool.
00366 
00367         Test compatibility of the overhang of a and b.
00368         True if a and b have compatible overhang."""
00369         if not isinstance(other, RestrictionType):
00370             raise TypeError( \
00371                   'expected RestrictionType, got %s instead' % type(other))
00372         return cls._mod1(other)
        
def Bio.Restriction.Restriction.RestrictionType.__ne__ (   cls,
  other 
) [inherited]
RE != other -> bool.
isoschizomer strict, same recognition site, same restriction -> False
all the other-> True

WARNING - This is not the inverse of the __eq__ method.

Definition at line 337 of file Restriction.py.

00337 
00338     def __ne__(cls, other):
00339         """RE != other -> bool.
00340         isoschizomer strict, same recognition site, same restriction -> False
00341         all the other-> True
00342         
00343         WARNING - This is not the inverse of the __eq__ method.
00344         """
00345         if not isinstance(other, RestrictionType):
00346             return True
00347         elif cls.charac == other.charac:
00348             return False
00349         else:
00350             return True

def Bio.Restriction.Restriction.RestrictionType.__rdiv__ (   cls,
  other 
) [inherited]
RE.__rdiv__(other) -> list.

other/RE
returns RE.search(other).

Definition at line 269 of file Restriction.py.

00269 
00270     def __rdiv__(cls, other):
00271         """RE.__rdiv__(other) -> list.
00272 
00273         other/RE
00274         returns RE.search(other)."""
00275         return cls.search(other)
    
RE.__repr__() -> str.

used with eval or exec will instantiate the enzyme.

Definition at line 310 of file Restriction.py.

00310 
00311     def __repr__(cls):
00312         """RE.__repr__() -> str.
00313 
00314         used with eval or exec will instantiate the enzyme."""
00315         return "%s" % cls.__name__
    
def Bio.Restriction.Restriction.RestrictionType.__rfloordiv__ (   cls,
  other 
) [inherited]
RE.__rfloordiv__(other) -> list.

other//RE
returns RE.catalyse(other).

Definition at line 297 of file Restriction.py.

00297 
00298     def __rfloordiv__(cls, other):
00299         """RE.__rfloordiv__(other) -> list.
00300 
00301         other//RE
00302         returns RE.catalyse(other)."""
00303         return cls.catalyse(other)
    
def Bio.Restriction.Restriction.RestrictionType.__rshift__ (   cls,
  other 
) [inherited]
RE >> other -> bool.

neoschizomer : same recognition site, different restriction. -> True
all the others :                                             -> False

Definition at line 351 of file Restriction.py.

00351 
00352     def __rshift__(cls, other):
00353         """RE >> other -> bool.
00354         
00355         neoschizomer : same recognition site, different restriction. -> True
00356         all the others :                                             -> False"""
00357         if not isinstance(other, RestrictionType):
00358             return False
00359         elif cls.site == other.site and cls.charac != other.charac:
00360             return True
00361         else:
00362             return False

def Bio.Restriction.Restriction.RestrictionType.__rtruediv__ (   cls,
  other 
) [inherited]
RE.__rtruediv__(other) -> list.

other/RE
returns RE.search(other).

Definition at line 283 of file Restriction.py.

00283 
00284     def __rtruediv__(cls, other):
00285         """RE.__rtruediv__(other) -> list.
00286 
00287         other/RE
00288         returns RE.search(other)."""
00289         return cls.search(other)
    
RE.__str__() -> str.

return the name of the enzyme.

Definition at line 304 of file Restriction.py.

00304 
00305     def __str__(cls):
00306         """RE.__str__() -> str.
00307 
00308         return the name of the enzyme."""
00309         return cls.__name__
    
def Bio.Restriction.Restriction.RestrictionType.__truediv__ (   cls,
  other 
) [inherited]
RE.__truediv__(other) -> list.

RE/other
returns RE.search(other).

Definition at line 276 of file Restriction.py.

00276 
00277     def __truediv__(cls, other):
00278         """RE.__truediv__(other) -> list.
00279 
00280         RE/other
00281         returns RE.search(other)."""
00282         return cls.search(other)
    
RE._drop() -> list.

for internal use only.

drop the site that are situated outside the sequence in linear sequence.
modify the index for site in circular sequences.

Definition at line 1343 of file Restriction.py.

01343 
01344     def _drop(self):
01345         """RE._drop() -> list.
01346 
01347         for internal use only.
01348 
01349         drop the site that are situated outside the sequence in linear sequence.
01350         modify the index for site in circular sequences."""
01351         #
01352         #   remove or modify the results that are outside the sequence.
01353         #   This is necessary since after finding the site we add the distance
01354         #   from the site to the cut with the _modify and _rev_modify methods.
01355         #   For linear we will remove these sites altogether.
01356         #   For circular sequence, we modify the result rather than _drop it
01357         #   since the site is in the sequence.
01358         # 
01359         length = len(self.dna)
01360         drop = itertools.dropwhile
01361         take = itertools.takewhile
01362         if self.dna.is_linear():
01363             self.results = [x for x in drop(lambda x:x<1, self.results)]
01364             self.results = [x for x in take(lambda x:x<length, self.results)]
01365         else:
01366             for index, location in enumerate(self.results):
01367                 if location < 1:
01368                     self.results[index] += length
01369                 else:
01370                     break
01371             for index, location in enumerate(self.results[::-1]):
01372                 if location > length:
01373                     self.results[-(index+1)] -= length
01374                 else:
01375                     break
01376         return

def Bio.Restriction.Restriction.Defined._mod2 (   self,
  other 
) [private]
RE._mod2(other) -> bool.

for internal use only

test for the compatibility of restriction ending of RE and other.

Definition at line 1448 of file Restriction.py.

01448 
01449     def _mod2(self, other):
01450         """RE._mod2(other) -> bool.
01451 
01452         for internal use only
01453         
01454         test for the compatibility of restriction ending of RE and other."""
01455         #
01456         #   called by RE._mod1(other) when the one of the enzyme is ambiguous
01457         #
01458         if other.ovhgseq == self.ovhgseq:
01459             return True
01460         elif issubclass(other, Ambiguous):
01461             return other._mod2(self)
01462         else:
01463             return False

Here is the caller graph for this function:

RE.all_suppliers -> print all the suppliers of R

Definition at line 470 of file Restriction.py.

00470 
00471     def all_suppliers(self):
00472         """RE.all_suppliers -> print all the suppliers of R"""
00473         supply = [x[0] for x in suppliers_dict.itervalues()]
00474         supply.sort()
00475         print ",\n".join(supply)
00476         return

RE.elucidate() -> str

return a representation of the site with the cut on the (+) strand
represented as '^' and the cut on the (-) strand as '_'.
ie:
>>> EcoRI.elucidate()   # 5' overhang
'G^AATT_C'
>>> KpnI.elucidate()    # 3' overhang
'G_GTAC^C'
>>> EcoRV.elucidate()   # blunt
'GAT^_ATC'
>>> SnaI.elucidate()     # NotDefined, cut profile unknown.
'? GTATAC ?'
>>>

Definition at line 1416 of file Restriction.py.

01416 
01417     def elucidate(self):
01418         """RE.elucidate() -> str
01419 
01420         return a representation of the site with the cut on the (+) strand
01421         represented as '^' and the cut on the (-) strand as '_'.
01422         ie:
01423         >>> EcoRI.elucidate()   # 5' overhang
01424         'G^AATT_C'
01425         >>> KpnI.elucidate()    # 3' overhang
01426         'G_GTAC^C'
01427         >>> EcoRV.elucidate()   # blunt
01428         'GAT^_ATC'
01429         >>> SnaI.elucidate()     # NotDefined, cut profile unknown.
01430         '? GTATAC ?'
01431         >>>
01432         """
01433         f5 = self.fst5
01434         f3 = self.fst3
01435         site = self.site
01436         if self.cut_twice() : re =  'cut twice, not yet implemented sorry.'
01437         elif self.is_5overhang():
01438             if f5 == f3 == 0 : re = 'N^'+ self.site + '_N'
01439             elif f3 == 0 : re = site[:f5] + '^' + site[f5:] + '_N'
01440             else : re = site[:f5] + '^' + site[f5:f3] + '_' + site[f3:]
01441         elif self.is_blunt():
01442             re =  site[:f5] + '^_' + site[f5:]
01443         else:
01444             if f5 == f3 == 0 : re = 'N_'+  site + '^N'
01445             else : re = site[:f3] + '_' + site[f3:f5] +'^'+ site[f5:]
01446         return re

Here is the call graph for this function:

def Bio.Restriction.Restriction.AbstractCut.equischizomers (   self,
  batch = None 
) [inherited]
RE.equischizomers([batch]) -> list.

return a tuple of all the isoschizomers of RE.
if batch is supplied it is used instead of the default AllEnzymes.

equischizomer <=> same site, same position of restriction.

Definition at line 508 of file Restriction.py.

00508 
00509     def equischizomers(self, batch=None):
00510         """RE.equischizomers([batch]) -> list.
00511 
00512         return a tuple of all the isoschizomers of RE.
00513         if batch is supplied it is used instead of the default AllEnzymes.
00514 
00515         equischizomer <=> same site, same position of restriction."""
00516         if not batch : batch = AllEnzymes
00517         r = [x for x in batch if not self != x]
00518         i = r.index(self)
00519         del r[i]
00520         r.sort()
00521         return r

RE.frequency() -> int.

frequency of the site.

Definition at line 549 of file Restriction.py.

00549 
00550     def frequency(self):
00551         """RE.frequency() -> int.
00552 
00553         frequency of the site."""
00554         return self.freq
00555 

RE.is_ambiguous() -> bool.

True if the sequence recognised and cut is ambiguous,
i.e. the recognition site is degenerated AND/OR the enzyme cut outside
the site.

see also:
    RE.is_defined()
    RE.is_unknown()

Definition at line 1391 of file Restriction.py.

01391 
01392     def is_ambiguous(self):
01393         """RE.is_ambiguous() -> bool.
01394 
01395         True if the sequence recognised and cut is ambiguous,
01396         i.e. the recognition site is degenerated AND/OR the enzyme cut outside
01397         the site.
01398 
01399         see also:
01400             RE.is_defined()
01401             RE.is_unknown()"""
01402         return False

RE.is_defined() -> bool.

True if the sequence recognised and cut is constant,
i.e. the recognition site is not degenerated AND the enzyme cut inside
the site.

see also:
    RE.is_ambiguous()
    RE.is_unknown()

Definition at line 1378 of file Restriction.py.

01378 
01379     def is_defined(self):
01380         """RE.is_defined() -> bool.
01381 
01382         True if the sequence recognised and cut is constant,
01383         i.e. the recognition site is not degenerated AND the enzyme cut inside
01384         the site.
01385 
01386         see also:
01387             RE.is_ambiguous()
01388             RE.is_unknown()"""
01389         return True

def Bio.Restriction.Restriction.AbstractCut.is_equischizomer (   self,
  other 
) [inherited]
RE.is_equischizomers(other) -> bool.

True if other is an isoschizomer of RE.
False else.

equischizomer <=> same site, same position of restriction.

Definition at line 478 of file Restriction.py.

00478 
00479     def is_equischizomer(self, other):
00480         """RE.is_equischizomers(other) -> bool.
00481 
00482         True if other is an isoschizomer of RE.
00483         False else.
00484 
00485         equischizomer <=> same site, same position of restriction."""
00486         return not self != other

def Bio.Restriction.Restriction.AbstractCut.is_isoschizomer (   self,
  other 
) [inherited]
RE.is_isoschizomers(other) -> bool.

True if other is an isoschizomer of RE.
False else.

isoschizomer <=> same site.

Definition at line 498 of file Restriction.py.

00498 
00499     def is_isoschizomer(self, other):
00500         """RE.is_isoschizomers(other) -> bool.
00501 
00502         True if other is an isoschizomer of RE.
00503         False else.
00504 
00505         isoschizomer <=> same site."""
00506         return (not self != other) or self >> other

def Bio.Restriction.Restriction.AbstractCut.is_neoschizomer (   self,
  other 
) [inherited]
RE.is_neoschizomers(other) -> bool.

True if other is an isoschizomer of RE.
False else.

neoschizomer <=> same site, different position of restriction.

Definition at line 488 of file Restriction.py.

00488 
00489     def is_neoschizomer(self, other):
00490         """RE.is_neoschizomers(other) -> bool.
00491 
00492         True if other is an isoschizomer of RE.
00493         False else.
00494 
00495         neoschizomer <=> same site, different position of restriction."""
00496         return self >> other

RE.is_unknown() -> bool.

True if the sequence is unknown,
i.e. the recognition site has not been characterised yet.

see also:
    RE.is_defined()
    RE.is_ambiguous()

Definition at line 1404 of file Restriction.py.

01404 
01405     def is_unknown(self):
01406         """RE.is_unknown() -> bool.
01407 
01408         True if the sequence is unknown,
01409         i.e. the recognition site has not been characterised yet.
01410 
01411         see also:
01412             RE.is_defined()
01413             RE.is_ambiguous()"""
01414         return False

def Bio.Restriction.Restriction.AbstractCut.isoschizomers (   self,
  batch = None 
) [inherited]
RE.isoschizomers([batch]) -> list.

return a tuple of all the equischizomers and neoschizomers of RE.
if batch is supplied it is used instead of the default AllEnzymes.

Definition at line 536 of file Restriction.py.

00536 
00537     def isoschizomers(self, batch=None):
00538         """RE.isoschizomers([batch]) -> list.
00539 
00540         return a tuple of all the equischizomers and neoschizomers of RE.
00541         if batch is supplied it is used instead of the default AllEnzymes."""
00542         if not batch : batch = AllEnzymes 
00543         r = [x for x in batch if (self >> x) or (not self != x)]
00544         i = r.index(self)
00545         del r[i]
00546         r.sort()
00547         return r

def Bio.Restriction.Restriction.AbstractCut.neoschizomers (   self,
  batch = None 
) [inherited]
RE.neoschizomers([batch]) -> list.

return a tuple of all the neoschizomers of RE.
if batch is supplied it is used instead of the default AllEnzymes.

neoschizomer <=> same site, different position of restriction.

Definition at line 523 of file Restriction.py.

00523 
00524     def neoschizomers(self, batch=None):
00525         """RE.neoschizomers([batch]) -> list.
00526 
00527         return a tuple of all the neoschizomers of RE.
00528         if batch is supplied it is used instead of the default AllEnzymes.
00529 
00530         neoschizomer <=> same site, different position of restriction."""
00531         if not batch : batch = AllEnzymes              
00532         r = [x for x in batch if self >> x]
00533         r.sort()
00534         return r

def Bio.Restriction.Restriction.AbstractCut.search (   cls,
  dna,
  linear = True 
) [inherited]
RE.search(dna, linear=True) -> list.

return a list of all the site of RE in dna. Compensate for circular
sequences and so on.

dna must be a Bio.Seq.Seq instance or a Bio.Seq.MutableSeq instance.

if linear is False, the restriction sites than span over the boundaries
will be included.

The positions are the first base of the 3' fragment,
i.e. the first base after the position the enzyme will cut. 

Definition at line 442 of file Restriction.py.

00442 
00443     def search(cls, dna, linear=True):
00444         """RE.search(dna, linear=True) -> list.
00445 
00446         return a list of all the site of RE in dna. Compensate for circular
00447         sequences and so on.
00448 
00449         dna must be a Bio.Seq.Seq instance or a Bio.Seq.MutableSeq instance.
00450         
00451         if linear is False, the restriction sites than span over the boundaries
00452         will be included.
00453 
00454         The positions are the first base of the 3' fragment,
00455         i.e. the first base after the position the enzyme will cut. """
00456         #
00457         #   Separating search from _search allow a (very limited) optimisation
00458         #   of the search when using a batch of restriction enzymes.
00459         #   in this case the DNA is tested once by the class which implements
00460         #   the batch instead of being tested by each enzyme single.
00461         #   see RestrictionBatch.search() for example.
00462         #
00463         if isinstance(dna, FormattedSeq):
00464             cls.dna = dna
00465             return cls._search()
00466         else :  
00467             cls.dna = FormattedSeq(dna, linear)
00468             return cls._search()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 1362 of file Restriction.py.


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