Back to index

python-biopython  1.60
Public Member Functions
Bio.Restriction.Restriction.RestrictionType Class Reference
Inheritance diagram for Bio.Restriction.Restriction.RestrictionType:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
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__

Detailed Description

RestrictionType. Type from which derives all enzyme classes.

Implement the operator methods.

Definition at line 226 of file Restriction.py.


Constructor & Destructor Documentation

def Bio.Restriction.Restriction.RestrictionType.__init__ (   cls,
  name = '',
  bases = (),
  dct = {} 
)
RE(name, bases, dct) -> RestrictionType instance.

Not intended to be used in normal operation. The enzymes are
instantiated when importing the module.

see below.

Definition at line 231 of file Restriction.py.

00231 
00232     def __init__(cls, name='', bases=(), dct={}):
00233         """RE(name, bases, dct) -> RestrictionType instance.
00234 
00235         Not intended to be used in normal operation. The enzymes are
00236         instantiated when importing the module.
00237         
00238         see below."""
00239         if "-" in name :
00240             raise ValueError("Problem with hyphen in %s as enzyme name" \
00241                              % repr(name))
00242         # 2011/11/26 - Nobody knows what this call was supposed to accomplish,
00243         # but all unit tests seem to pass without it. 
00244         # super(RestrictionType, cls).__init__(cls, name, bases, dct)
00245         try :
00246             cls.compsite = re.compile(cls.compsite)
00247         except Exception, err :
00248             raise ValueError("Problem with regular expression, re.compiled(%s)" \
00249                              % repr(cls.compsite))
        

Member Function Documentation

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
        
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)
    
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)

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)
    
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

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)
    
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
    
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
    
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)
        
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

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__
    
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)
    
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

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__
    
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)
    

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