Back to index

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

List of all members.

Public Member Functions

def __init__
def __repr__
def print_that
def change
def full
def blunt
def overhang5
def overhang3
def defined
def with_sites
def without_site
def with_N_sites
def with_number_list
def with_name
def with_site_size
def only_between
def between
def show_only_between
def only_outside
def outside
def do_not_cut
def __str__
def __contains__
def __div__
def __rdiv__
def get
def lambdasplit
def add_supplier
def current_suppliers
def __iadd__
def __add__
def remove
def add
def add_nocheck
def format
def is_restriction
def split
def elements
def as_string
def suppl_codes
def show_codes
def search
def make_format
def print_as

Public Attributes

 rb
 sequence
 linear
 Cmodulo
 PrefWidth
 mapping
 already_mapped
 make_format

Static Public Attributes

 ConsoleWidth = RanaConf.ConsoleWidth
 NameWidth = RanaConf.NameWidth
 MaxSize = RanaConf.MaxSize
 Indent = RanaConf.Indent
 linesize = PrefWidth-NameWidth

Private Member Functions

def _sub_set
def _boundaries
def _test_normal
def _test_reverse

Detailed Description

Definition at line 2054 of file Restriction.py.


Constructor & Destructor Documentation

def Bio.Restriction.Restriction.Analysis.__init__ (   self,
  restrictionbatch = RestrictionBatch(),
  sequence = DNA(''),
  linear = True 
)
Analysis([restrictionbatch [, sequence] linear=True]) -> New Analysis class.

For most of the method of this class if a dictionary is given it will
be used as the base to calculate the results. 
If no dictionary is given a new analysis using the Restriction Batch
which has been given when the Analysis class has been instantiated.

Definition at line 2057 of file Restriction.py.

02057 
02058                  linear=True):
02059         """Analysis([restrictionbatch [, sequence] linear=True]) -> New Analysis class.
02060 
02061         For most of the method of this class if a dictionary is given it will
02062         be used as the base to calculate the results. 
02063         If no dictionary is given a new analysis using the Restriction Batch
02064         which has been given when the Analysis class has been instantiated."""
02065         RestrictionBatch.__init__(self, restrictionbatch)
02066         self.rb = restrictionbatch
02067         self.sequence = sequence
02068         self.linear = linear
02069         if self.sequence:
02070             self.search(self.sequence, self.linear)


Member Function Documentation

def Bio.Restriction.Restriction.RestrictionBatch.__add__ (   self,
  other 
) [inherited]
b + other -> new RestrictionBatch.

Definition at line 1909 of file Restriction.py.

01909 
01910     def __add__(self, other):
01911         """ b + other -> new RestrictionBatch."""
01912         new = self.__class__(self)
01913         new.add(other)
01914         return new

def Bio.Restriction.Restriction.RestrictionBatch.__contains__ (   self,
  other 
) [inherited]

Definition at line 1842 of file Restriction.py.

01842 
01843     def __contains__(self, other):
01844         try:
01845             other = self.format(other)
01846         except ValueError : # other is not a restriction enzyme
01847             return False
01848         return set.__contains__(self, other)
    

Here is the call graph for this function:

def Bio.Restriction.Restriction.RestrictionBatch.__div__ (   self,
  other 
) [inherited]

Definition at line 1849 of file Restriction.py.

01849 
01850     def __div__(self, other):
01851         return self.search(other)
    

Here is the call graph for this function:

def Bio.Restriction.Restriction.RestrictionBatch.__iadd__ (   self,
  other 
) [inherited]
b += other -> add other to b, check the type of other.

Definition at line 1904 of file Restriction.py.

01904 
01905     def __iadd__(self, other):
01906         """ b += other -> add other to b, check the type of other."""
01907         self.add(other)
01908         return self

Here is the call graph for this function:

def Bio.Restriction.Restriction.RestrictionBatch.__rdiv__ (   self,
  other 
) [inherited]

Definition at line 1852 of file Restriction.py.

01852 
01853     def __rdiv__(self, other):
01854         return self.search(other)

Here is the call graph for this function:

Reimplemented from Bio.Restriction.Restriction.RestrictionBatch.

Definition at line 2071 of file Restriction.py.

02071 
02072     def __repr__(self):
02073         return 'Analysis(%s,%s,%s)'%\
02074                (repr(self.rb),repr(self.sequence),self.linear)

Definition at line 1832 of file Restriction.py.

01832 
01833     def __str__(self):
01834         if len(self) < 5:
01835             return '+'.join(self.elements())
01836         else:
01837             return '...'.join(('+'.join(self.elements()[:2]),\
01838                                '+'.join(self.elements()[-2:])))

Here is the call graph for this function:

def Bio.Restriction.Restriction.Analysis._boundaries (   self,
  start,
  end 
) [private]
A._boundaries(start, end) -> tuple.

Format the boundaries for use with the methods that limit the
search to only part of the sequence given to analyse.

Definition at line 2085 of file Restriction.py.

02085 
02086     def _boundaries(self, start, end):
02087         """A._boundaries(start, end) -> tuple.
02088 
02089         Format the boundaries for use with the methods that limit the
02090         search to only part of the sequence given to analyse.
02091         """
02092         if not isinstance(start, int):
02093             raise TypeError('expected int, got %s instead' % type(start))
02094         if not isinstance(end, int):
02095             raise TypeError('expected int, got %s instead' % type(end))
02096         if start < 1:
02097             start += len(self.sequence)
02098         if end < 1:
02099             end += len(self.sequence)
02100         if start < end:
02101             pass
02102         else:
02103             start, end == end, start
02104         if start < 1:
02105             start == 1
02106         if start < end:
02107             return start, end, self._test_normal
02108         else:
02109             return start, end, self._test_reverse

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Restriction.Restriction.Analysis._sub_set (   self,
  wanted 
) [private]
A._sub_set(other_set) -> dict.

Internal use only.

screen the results through wanted set.
Keep only the results for which the enzymes is in wanted set.

Definition at line 2075 of file Restriction.py.

02075 
02076     def _sub_set(self, wanted):
02077         """A._sub_set(other_set) -> dict.
02078 
02079         Internal use only.
02080         
02081         screen the results through wanted set.
02082         Keep only the results for which the enzymes is in wanted set.
02083         """
02084         return dict([(k,v) for k,v in self.mapping.iteritems() if k in wanted])
    
def Bio.Restriction.Restriction.Analysis._test_normal (   self,
  start,
  end,
  site 
) [private]
A._test_normal(start, end, site) -> bool.

Internal use only
Test if site is in between start and end.

Definition at line 2110 of file Restriction.py.

02110 
02111     def _test_normal(self, start, end, site):
02112         """A._test_normal(start, end, site) -> bool.
02113 
02114         Internal use only
02115         Test if site is in between start and end.
02116         """
02117         return start <= site < end 

Here is the caller graph for this function:

def Bio.Restriction.Restriction.Analysis._test_reverse (   self,
  start,
  end,
  site 
) [private]
A._test_reverse(start, end, site) -> bool.

Internal use only
Test if site is in between end and start (for circular sequences).

Definition at line 2118 of file Restriction.py.

02118 
02119     def _test_reverse(self, start, end, site):
02120         """A._test_reverse(start, end, site) -> bool.
02121 
02122         Internal use only
02123         Test if site is in between end and start (for circular sequences).
02124         """
02125         return start <= site <= len(self.sequence) or 1 <= site < end

Here is the caller graph for this function:

def Bio.Restriction.Restriction.RestrictionBatch.add (   self,
  other 
) [inherited]
B.add(other) -> add other to B if other is a RestrictionType.

Safe set.add method. Verify that other is a RestrictionType or can be
evaluated to a RestrictionType.
raise a ValueError if other can not be evaluated to a RestrictionType.

Definition at line 1924 of file Restriction.py.

01924 
01925     def add(self, other):
01926         """B.add(other) -> add other to B if other is a RestrictionType.
01927 
01928         Safe set.add method. Verify that other is a RestrictionType or can be
01929         evaluated to a RestrictionType.
01930         raise a ValueError if other can not be evaluated to a RestrictionType.
01931         """
01932         return set.add(self, self.format(other))

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Restriction.Restriction.RestrictionBatch.add_nocheck (   self,
  other 
) [inherited]
B.add_nocheck(other) -> add other to B. don't check type of other.

Definition at line 1933 of file Restriction.py.

01933 
01934     def add_nocheck(self, other):
01935         """B.add_nocheck(other) -> add other to B. don't check type of other.
01936         """
01937         return set.add(self, other)
        

Here is the caller graph for this function:

def Bio.Restriction.Restriction.RestrictionBatch.add_supplier (   self,
  letter 
) [inherited]
B.add_supplier(letter) -> add a new set of enzyme to B.

letter represents the suppliers as defined in the dictionary
RestrictionDictionary.suppliers
return None.
raise a KeyError if letter is not a supplier code.

Definition at line 1882 of file Restriction.py.

01882 
01883     def add_supplier(self, letter):
01884         """B.add_supplier(letter) -> add a new set of enzyme to B.
01885 
01886         letter represents the suppliers as defined in the dictionary
01887         RestrictionDictionary.suppliers
01888         return None.
01889         raise a KeyError if letter is not a supplier code."""
01890         supplier = suppliers_dict[letter]
01891         self.suppliers.append(letter)
01892         for x in supplier[1]:
01893             self.add_nocheck(eval(x))
01894         return

Here is the call graph for this function:

B.as_string() -> list.

return a list of the name of the elements of B.

Definition at line 1995 of file Restriction.py.

01995 
01996     def as_string(self):
01997         """B.as_string() -> list.
01998 
01999         return a list of the name of the elements of B."""
02000         return [str(e) for e in self]

def Bio.Restriction.Restriction.Analysis.between (   self,
  start,
  end,
  dct = None 
)
A.between(start, end [, dct]) -> dict.

Enzymes that cut the sequence at least in between start and end.
They may cut outside as well.

Definition at line 2281 of file Restriction.py.

02281 
02282     def between(self, start, end, dct=None):
02283         """A.between(start, end [, dct]) -> dict.
02284 
02285         Enzymes that cut the sequence at least in between start and end.
02286         They may cut outside as well."""
02287         start, end, test = self._boundaries(start, end)
02288         d = {}
02289         if not dct:
02290             dct = self.mapping
02291         for key, sites in dct.iteritems():
02292             for site in sites:
02293                 if test(start, end, site):
02294                     d[key] = sites
02295                     break
02296                 continue
02297         return d
    

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Restriction.Restriction.Analysis.blunt (   self,
  dct = None 
)
A.blunt([dct]) -> dict.

Only the enzymes which have a 3'overhang restriction site.

Definition at line 2177 of file Restriction.py.

02177 
02178     def blunt(self, dct = None):
02179         """A.blunt([dct]) -> dict.
02180         
02181         Only the enzymes which have a 3'overhang restriction site."""
02182         if not dct:
02183             dct = self.mapping
02184         return dict([(k,v) for k,v in dct.iteritems() if k.is_blunt()])
        
def Bio.Restriction.Restriction.Analysis.change (   self,
  what 
)
A.change(**attribute_name) -> Change attribute of Analysis.

It is possible to change the width of the shell by setting
self.ConsoleWidth to what you want.
self.NameWidth refer to the maximal length of the enzyme name.

Changing one of these parameters here might not give the results
you expect. In which case, you can settle back to a 80 columns shell
or try to change self.Cmodulo and self.PrefWidth in PrintFormat until
you get it right.

Definition at line 2136 of file Restriction.py.

02136 
02137     def change(self, **what):
02138         """A.change(**attribute_name) -> Change attribute of Analysis.
02139 
02140         It is possible to change the width of the shell by setting
02141         self.ConsoleWidth to what you want.
02142         self.NameWidth refer to the maximal length of the enzyme name.
02143 
02144         Changing one of these parameters here might not give the results
02145         you expect. In which case, you can settle back to a 80 columns shell
02146         or try to change self.Cmodulo and self.PrefWidth in PrintFormat until
02147         you get it right."""
02148         for k,v in what.iteritems():
02149             if k in ('NameWidth', 'ConsoleWidth'):
02150                 setattr(self, k, v)
02151                 self.Cmodulo    = self.ConsoleWidth % self.NameWidth
02152                 self.PrefWidth  = self.ConsoleWidth - self.Cmodulo
02153             elif k is 'sequence':
02154                 setattr(self, 'sequence', v) 
02155                 self.search(self.sequence, self.linear)
02156             elif k is 'rb':
02157                 self = Analysis.__init__(self, v, self.sequence, self.linear)
02158             elif k is 'linear':
02159                 setattr(self, 'linear', v)
02160                 self.search(self.sequence, v)
02161             elif k in ('Indent', 'Maxsize'):
02162                 setattr(self, k, v)
02163             elif k in ('Cmodulo', 'PrefWidth'):
02164                 raise AttributeError( \
02165                     'To change %s, change NameWidth and/or ConsoleWidth' \
02166                     % name)
02167             else:
02168                 raise AttributeError( \
02169                     'Analysis has no attribute %s' % name)
02170         return

B.current_suppliers() -> add a new set of enzyme to B.

return a sorted list of the suppliers which have been used to
create the batch.

Definition at line 1895 of file Restriction.py.

01895 
01896     def current_suppliers(self):
01897         """B.current_suppliers() -> add a new set of enzyme to B.
01898 
01899         return a sorted list of the suppliers which have been used to
01900         create the batch."""
01901         suppl_list = [suppliers_dict[x][0] for x in self.suppliers]
01902         suppl_list.sort()
01903         return suppl_list

Here is the call graph for this function:

def Bio.Restriction.Restriction.Analysis.defined (   self,
  dct = None 
)
A.defined([dct]) -> dict.

Only the enzymes that have a defined restriction site in Rebase.

Definition at line 2203 of file Restriction.py.

02203 
02204     def defined(self, dct=None):
02205         """A.defined([dct]) -> dict.
02206         
02207         Only the enzymes that have a defined restriction site in Rebase."""
02208         if not dct:
02209             dct = self.mapping
02210         return dict([(k,v) for k,v in dct.iteritems() if k.is_defined()])
        
def Bio.Restriction.Restriction.Analysis.do_not_cut (   self,
  start,
  end,
  dct = None 
)
A.do_not_cut(start, end [, dct]) -> dict.

Enzymes that do not cut the region in between start and end.

Definition at line 2351 of file Restriction.py.

02351 
02352     def do_not_cut(self, start, end, dct = None):
02353         """A.do_not_cut(start, end [, dct]) -> dict.
02354 
02355         Enzymes that do not cut the region in between start and end."""
02356         if not dct:
02357             dct = self.mapping
02358         d = self.without_site()
02359         d.update(self.only_outside(start, end, dct))   
02360         return d
02361     
02362 #
02363 #   The restriction enzyme classes are created dynamically when the module is
02364 #   imported. Here is the magic which allow the creation of the
02365 #   restriction-enzyme classes.
02366 #
02367 #   The reason for the two dictionaries in Restriction_Dictionary
02368 #   one for the types (which will be called pseudo-type as they really
02369 #   correspond to the values that instances of RestrictionType can take)
02370 #   and one for the enzymes is efficiency as the bases are evaluated
02371 #   once per pseudo-type.
02372 #
02373 #   However Restriction is still a very inefficient module at import. But
02374 #   remember that around 660 classes (which is more or less the size of Rebase)
02375 #   have to be created dynamically. However, this processing take place only
02376 #   once.
02377 #   This inefficiency is however largely compensated by the use of metaclass
02378 #   which provide a very efficient layout for the class themselves mostly
02379 #   alleviating the need of if/else loops in the class methods.
02380 #
02381 #   It is essential to run Restriction with doc string optimisation (-OO switch)
02382 #   as the doc string of 660 classes take a lot of processing.
#

Here is the call graph for this function:

B.elements() -> tuple.

give all the names of the enzymes in B sorted alphabetically.

Definition at line 1987 of file Restriction.py.

01987 
01988     def elements(self):
01989         """B.elements() -> tuple.
01990 
01991         give all the names of the enzymes in B sorted alphabetically."""
01992         l = [str(e) for e in self]
01993         l.sort()
01994         return l

Here is the caller graph for this function:

def Bio.Restriction.Restriction.RestrictionBatch.format (   self,
  y 
) [inherited]
B.format(y) -> RestrictionType or raise ValueError.

if y is a RestrictionType return y
if y can be evaluated to a RestrictionType return eval(y)
raise a Value Error in all other case.

Definition at line 1938 of file Restriction.py.

01938 
01939     def format(self, y):
01940         """B.format(y) -> RestrictionType or raise ValueError.
01941 
01942         if y is a RestrictionType return y
01943         if y can be evaluated to a RestrictionType return eval(y)
01944         raise a Value Error in all other case."""
01945         try:
01946             if isinstance(y, RestrictionType):
01947                 return y
01948             elif isinstance(eval(str(y)), RestrictionType):
01949                 return eval(y)
01950             
01951             else:
01952                 pass
01953         except (NameError, SyntaxError):
01954             pass
01955         raise ValueError('%s is not a RestrictionType' % y.__class__)
01956         

Here is the caller graph for this function:

def Bio.Restriction.Restriction.Analysis.full (   self,
  linear = True 
)
A.full() -> dict.

Full Restriction Map of the sequence.

Definition at line 2171 of file Restriction.py.

02171 
02172     def full(self, linear=True):
02173         """A.full() -> dict.
02174         
02175         Full Restriction Map of the sequence."""
02176         return self.mapping

def Bio.Restriction.Restriction.RestrictionBatch.get (   self,
  enzyme,
  add = False 
) [inherited]
B.get(enzyme[, add]) -> enzyme class.

if add is True and enzyme is not in B add enzyme to B.
if add is False (which is the default) only return enzyme.
if enzyme is not a RestrictionType or can not be evaluated to
a RestrictionType, raise a ValueError.

Definition at line 1855 of file Restriction.py.

01855 
01856     def get(self, enzyme, add=False):
01857         """B.get(enzyme[, add]) -> enzyme class.
01858 
01859         if add is True and enzyme is not in B add enzyme to B.
01860         if add is False (which is the default) only return enzyme.
01861         if enzyme is not a RestrictionType or can not be evaluated to
01862         a RestrictionType, raise a ValueError."""
01863         e = self.format(enzyme)
01864         if e in self:
01865             return e
01866         elif add:
01867             self.add(e)
01868             return e
01869         else:
01870             raise ValueError('enzyme %s is not in RestrictionBatch' \
01871                              % e.__name__)

Here is the call graph for this function:

B.is_restriction(y) -> bool.

True is y or eval(y) is a RestrictionType.

Definition at line 1957 of file Restriction.py.

01957 
01958     def is_restriction(self, y):
01959         """B.is_restriction(y) -> bool.
01960 
01961         True is y or eval(y) is a RestrictionType.""" 
01962         return isinstance(y, RestrictionType) or \
01963                isinstance(eval(str(y)), RestrictionType)
    
def Bio.Restriction.Restriction.RestrictionBatch.lambdasplit (   self,
  func 
) [inherited]
B.lambdasplit(func) -> RestrictionBatch .

the new batch will contains only the enzymes for which
func return True.

Definition at line 1872 of file Restriction.py.

01872 
01873     def lambdasplit(self, func):
01874         """B.lambdasplit(func) -> RestrictionBatch .
01875 
01876         the new batch will contains only the enzymes for which
01877         func return True."""
01878         d = [x for x in itertools.ifilter(func, self)]
01879         new = RestrictionBatch()
01880         new._data = dict(zip(d, [True]*len(d)))
01881         return new

def Bio.Restriction.PrintFormat.PrintFormat.make_format (   self,
  cut = [],
  title = '',
  nc = [],
  s1 = '' 
) [inherited]
PF.make_format(cut, nc, title, s) -> string

Virtual method.
Here to be pointed to one of the _make_* methods.
You can as well create a new method and point make_format to it.

Definition at line 122 of file PrintFormat.py.

00122 
00123     def make_format(self, cut=[], title='', nc=[], s1=''):
00124         """PF.make_format(cut, nc, title, s) -> string
00125 
00126         Virtual method.
00127         Here to be pointed to one of the _make_* methods.
00128         You can as well create a new method and point make_format to it."""
00129         return self._make_list(cut,title, nc,s1)

Here is the call graph for this function:

def Bio.Restriction.Restriction.Analysis.only_between (   self,
  start,
  end,
  dct = None 
)
A.only_between(start, end[, dct]) -> dict.

Enzymes that cut the sequence only in between start and end.

Definition at line 2261 of file Restriction.py.

02261 
02262     def only_between(self, start, end, dct=None):
02263         """A.only_between(start, end[, dct]) -> dict.
02264 
02265         Enzymes that cut the sequence only in between start and end."""
02266         start, end, test = self._boundaries(start, end)
02267         if not dct:
02268             dct = self.mapping
02269         d = dict(dct)
02270         for key, sites in dct.iteritems():
02271             if not sites:
02272                 del d[key]
02273                 continue
02274             for site in sites:
02275                 if test(start, end, site):
02276                     continue
02277                 else:
02278                     del d[key]
02279                     break
02280         return d
        

Here is the call graph for this function:

def Bio.Restriction.Restriction.Analysis.only_outside (   self,
  start,
  end,
  dct = None 
)
A.only_outside(start, end [, dct]) -> dict.

Enzymes that cut the sequence outside of the region
in between start and end but do not cut inside.

Definition at line 2312 of file Restriction.py.

02312 
02313     def only_outside(self, start, end, dct = None):
02314         """A.only_outside(start, end [, dct]) -> dict.
02315 
02316         Enzymes that cut the sequence outside of the region
02317         in between start and end but do not cut inside.""" 
02318         start, end, test = self._boundaries(start, end)
02319         if not dct : dct = self.mapping
02320         d = dict(dct)
02321         for key, sites in dct.iteritems():
02322             if not sites:
02323                 del d[key]
02324                 continue
02325             for site in sites:
02326                 if test(start, end, site):
02327                     del d[key]
02328                     break
02329                 else:
02330                     continue
02331         return d

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Restriction.Restriction.Analysis.outside (   self,
  start,
  end,
  dct = None 
)
A.outside((start, end [, dct]) -> dict.

Enzymes that cut outside the region in between start and end.
No test is made to know if they cut or not inside this region.

Definition at line 2332 of file Restriction.py.

02332 
02333     def outside(self, start, end, dct=None):
02334         """A.outside((start, end [, dct]) -> dict.
02335 
02336         Enzymes that cut outside the region in between start and end.
02337         No test is made to know if they cut or not inside this region."""
02338         start, end, test = self._boundaries(start, end)
02339         if not dct:
02340             dct = self.mapping
02341         d = {}
02342         for key, sites in dct.iteritems():
02343             for site in sites:
02344                 if test(start, end, site):
02345                     continue
02346                 else:
02347                     d[key] = sites 
02348                     break      
02349         return d
02350    

Here is the call graph for this function:

def Bio.Restriction.Restriction.Analysis.overhang3 (   self,
  dct = None 
)
A.Overhang3([dct]) -> dict.

Only the enzymes which have a 3'overhang restriction site.

Definition at line 2194 of file Restriction.py.

02194 
02195     def overhang3(self, dct=None):
02196         """A.Overhang3([dct]) -> dict.
02197         
02198         Only the enzymes which have a 3'overhang restriction site."""
02199         if not dct:
02200             dct = self.mapping
02201         return dict([(k,v) for k,v in dct.iteritems() if k.is_3overhang()])
02202         
        
def Bio.Restriction.Restriction.Analysis.overhang5 (   self,
  dct = None 
)
A.overhang5([dct]) -> dict.

Only the enzymes which have a 5' overhang restriction site.

Definition at line 2185 of file Restriction.py.

02185 
02186     def overhang5(self, dct=None):
02187         """A.overhang5([dct]) -> dict.
02188         
02189         Only the enzymes which have a 5' overhang restriction site."""
02190         if not dct:
02191             dct = self.mapping
02192         return dict([(k,v) for k,v in dct.iteritems() if k.is_5overhang()])
02193         

def Bio.Restriction.PrintFormat.PrintFormat.print_as (   self,
  what = 'list' 
) [inherited]
PF.print_as([what='list']) -> print the results as specified.

Valid format are:
    'list'      -> alphabetical order
    'number'    -> number of sites in the sequence
    'map'       -> a map representation of the sequence with the sites.

If you want more flexibility over-ride the virtual method make_format.

Definition at line 78 of file PrintFormat.py.

00078 
00079     def print_as(self, what='list'):
00080         """PF.print_as([what='list']) -> print the results as specified.
00081 
00082         Valid format are:
00083             'list'      -> alphabetical order
00084             'number'    -> number of sites in the sequence
00085             'map'       -> a map representation of the sequence with the sites.
00086 
00087         If you want more flexibility over-ride the virtual method make_format.
00088         """
00089         if what == 'map':
00090             self.make_format = self._make_map
00091         elif what == 'number':
00092             self.make_format = self._make_number
00093         else:
00094             self.make_format = self._make_list
00095             
00096         return
00097             

def Bio.Restriction.Restriction.Analysis.print_that (   self,
  dct = None,
  title = '',
  s1 = '' 
)
A.print_that([dct[, title[, s1]]]) -> print the results from dct.

If dct is not given the full dictionary is used.

Reimplemented from Bio.Restriction.PrintFormat.PrintFormat.

Definition at line 2126 of file Restriction.py.

02126 
02127     def print_that(self, dct=None, title='', s1=''):
02128         """A.print_that([dct[, title[, s1]]]) -> print the results from dct.
02129 
02130         If dct is not given the full dictionary is used.
02131         """
02132         if not dct:
02133             dct = self.mapping
02134         print
02135         return PrintFormat.print_that(self, dct, title, s1)
        
def Bio.Restriction.Restriction.RestrictionBatch.remove (   self,
  other 
) [inherited]
B.remove(other) -> remove other from B if other is a RestrictionType.

Safe set.remove method. Verify that other is a RestrictionType or can be
evaluated to a RestrictionType.
raise a ValueError if other can not be evaluated to a RestrictionType.
raise a KeyError if other is not in B.

Definition at line 1915 of file Restriction.py.

01915 
01916     def remove(self, other):
01917         """B.remove(other) -> remove other from B if other is a RestrictionType.
01918 
01919         Safe set.remove method. Verify that other is a RestrictionType or can be
01920         evaluated to a RestrictionType.
01921         raise a ValueError if other can not be evaluated to a RestrictionType.
01922         raise a KeyError if other is not in B."""
01923         return set.remove(self, self.format(other))

Here is the call graph for this function:

def Bio.Restriction.Restriction.RestrictionBatch.search (   self,
  dna,
  linear = True 
) [inherited]
B.search(dna) -> dict.

Definition at line 2016 of file Restriction.py.

02016 
02017     def search(self, dna, linear=True):
02018         """B.search(dna) -> dict."""
02019         #
02020         #   here we replace the search method of the individual enzymes
02021         #   with one unique testing method.
02022         #
02023         if not hasattr(self, "already_mapped") :
02024             #TODO - Why does this happen!
02025             #Try the "doctest" at the start of PrintFormat.py
02026             self.already_mapped = None
02027         if isinstance(dna, DNA):
02028             # For the searching, we just care about the sequence as a string,
02029             # if that is the same we can use the cached search results.
02030             # At the time of writing, Seq == method isn't implemented,
02031             # and therefore does object identity which is stricter.
02032             if (str(dna), linear) == self.already_mapped:
02033                 return self.mapping
02034             else:
02035                 self.already_mapped = str(dna), linear
02036                 fseq = FormattedSeq(dna, linear)
02037                 self.mapping = dict([(x, x.search(fseq)) for x in self])
02038                 return self.mapping
02039         elif isinstance(dna, FormattedSeq):
02040             if (str(dna), dna.linear) == self.already_mapped:
02041                 return self.mapping
02042             else:
02043                 self.already_mapped = str(dna), dna.linear
02044                 self.mapping = dict([(x, x.search(dna)) for x in self])
02045                 return self.mapping
02046         raise TypeError("Expected Seq or MutableSeq instance, got %s instead"\
02047                         %type(dna))

Here is the caller graph for this function:

Definition at line 2010 of file Restriction.py.

02010 
02011     def show_codes(self):
02012         "B.show_codes() -> letter codes for the suppliers"""
02013         supply = [' = '.join(i) for i in self.suppl_codes().iteritems()]
02014         print '\n'.join(supply)
02015         return

def Bio.Restriction.Restriction.Analysis.show_only_between (   self,
  start,
  end,
  dct = None 
)
A.show_only_between(start, end [, dct]) -> dict.

Enzymes that cut the sequence outside of the region
in between start and end but do not cut inside.

Definition at line 2298 of file Restriction.py.

02298 
02299     def show_only_between(self, start, end, dct=None):
02300         """A.show_only_between(start, end [, dct]) -> dict.
02301 
02302         Enzymes that cut the sequence outside of the region
02303         in between start and end but do not cut inside."""
02304         d = []
02305         if start <= end:
02306             d = [(k, [vv for vv in v if start<=vv<=end])
02307                  for v in self.between(start, end, dct)]
02308         else:
02309             d = [(k, [vv for vv in v if start<=vv or vv <= end])
02310                  for v in self.between(start, end, dct)]
02311         return dict(d)
        

Here is the call graph for this function:

def Bio.Restriction.Restriction.RestrictionBatch.split (   self,
  classes,
  bool 
) [inherited]
B.split(class, [class.__name__ = True]) -> new RestrictionBatch.

it works but it is slow, so it has really an interest when splitting
over multiple conditions.

Definition at line 1964 of file Restriction.py.

01964 
01965     def split(self, *classes, **bool):
01966         """B.split(class, [class.__name__ = True]) -> new RestrictionBatch.
01967 
01968         it works but it is slow, so it has really an interest when splitting
01969         over multiple conditions."""
01970         def splittest(element):
01971             for klass in classes:
01972                 b = bool.get(klass.__name__, True)
01973                 if issubclass(element, klass):
01974                     if b:
01975                         continue
01976                     else:
01977                         return False
01978                 elif b:
01979                     return False
01980                 else:
01981                     continue
01982             return True
01983         d = [k for k in itertools.ifilter(splittest, self)]
01984         new = RestrictionBatch()
01985         new._data = dict(zip(d, [True]*len(d)))
01986         return new
      
B.suppl_codes() -> dict

letter code for the suppliers

Definition at line 2002 of file Restriction.py.

02002 
02003     def suppl_codes(self):
02004         """B.suppl_codes() -> dict
02005 
02006         letter code for the suppliers"""
02007         supply = dict([(k,v[0]) for k,v in suppliers_dict.iteritems()]) 
02008         return supply

def Bio.Restriction.Restriction.Analysis.with_N_sites (   self,
  N,
  dct = None 
)
A.With_N_Sites(N [, dct]) -> dict.

Enzymes which cut N times the sequence.

Definition at line 2227 of file Restriction.py.

02227 
02228     def with_N_sites(self, N, dct=None):
02229         """A.With_N_Sites(N [, dct]) -> dict.
02230         
02231         Enzymes which cut N times the sequence."""
02232         if not dct:
02233             dct = self.mapping
02234         return dict([(k,v) for k,v in dct.iteritems()if len(v) == N])

def Bio.Restriction.Restriction.Analysis.with_name (   self,
  names,
  dct = None 
)
A.with_name(list_of_names [, dct]) ->

 Limit the search to the enzymes named in list_of_names.

Definition at line 2240 of file Restriction.py.

02240 
02241     def with_name(self, names, dct=None):
02242         """A.with_name(list_of_names [, dct]) ->
02243         
02244          Limit the search to the enzymes named in list_of_names."""
02245         for i, enzyme in enumerate(names):
02246             if not enzyme in AllEnzymes:
02247                 print "no datas for the enzyme:", str(name)
02248                 del names[i]       
02249         if not dct:
02250             return RestrictionBatch(names).search(self.sequence)
02251         return dict([(n, dct[n]) for n in names if n in dct])

Here is the call graph for this function:

def Bio.Restriction.Restriction.Analysis.with_number_list (   self,
  list,
  dct = None 
)

Definition at line 2235 of file Restriction.py.

02235 
02236     def with_number_list(self, list, dct= None):
02237         if not dct:
02238             dct = self.mapping
02239         return dict([(k,v) for k,v in dct.iteritems() if len(v) in list])
                             
def Bio.Restriction.Restriction.Analysis.with_site_size (   self,
  site_size,
  dct = None 
)
A.with_site_size(site_size [, dct]) ->

 Limit the search to the enzymes whose site is of size <site_size>.

Definition at line 2252 of file Restriction.py.

02252 
02253     def with_site_size(self, site_size, dct=None):
02254         """A.with_site_size(site_size [, dct]) ->
02255         
02256          Limit the search to the enzymes whose site is of size <site_size>."""
02257         sites = [name for name in self if name.size == site_size]
02258         if not dct:
02259             return RestrictionBatch(sites).search(self.sequence)
02260         return dict([(k,v) for k,v in dct.iteritems() if k in site_size])  
    

Here is the call graph for this function:

def Bio.Restriction.Restriction.Analysis.with_sites (   self,
  dct = None 
)
A.with_sites([dct]) -> dict.

Enzymes which have at least one site in the sequence.

Definition at line 2211 of file Restriction.py.

02211 
02212     def with_sites(self, dct=None):
02213         """A.with_sites([dct]) -> dict.
02214         
02215         Enzymes which have at least one site in the sequence."""
02216         if not dct:
02217             dct = self.mapping
02218         return dict([(k,v) for k,v in dct.iteritems() if v])

def Bio.Restriction.Restriction.Analysis.without_site (   self,
  dct = None 
)
A.without_site([dct]) -> dict.

Enzymes which have no site in the sequence.

Definition at line 2219 of file Restriction.py.

02219 
02220     def without_site(self, dct=None):
02221         """A.without_site([dct]) -> dict.
02222         
02223         Enzymes which have no site in the sequence."""
02224         if not dct:
02225             dct = self.mapping
02226         return dict([(k,v) for k,v in dct.iteritems() if not v])

Here is the caller graph for this function:


Member Data Documentation

Definition at line 1830 of file Restriction.py.

Reimplemented from Bio.Restriction.PrintFormat.PrintFormat.

Definition at line 2150 of file Restriction.py.

Bio.Restriction.PrintFormat.PrintFormat.ConsoleWidth = RanaConf.ConsoleWidth [static, inherited]

Definition at line 66 of file PrintFormat.py.

Bio.Restriction.PrintFormat.PrintFormat.Indent = RanaConf.Indent [static, inherited]

Definition at line 71 of file PrintFormat.py.

Definition at line 2067 of file Restriction.py.

Definition at line 72 of file PrintFormat.py.

Definition at line 89 of file PrintFormat.py.

Definition at line 1829 of file Restriction.py.

Bio.Restriction.PrintFormat.PrintFormat.MaxSize = RanaConf.MaxSize [static, inherited]

Definition at line 68 of file PrintFormat.py.

Bio.Restriction.PrintFormat.PrintFormat.NameWidth = RanaConf.NameWidth [static, inherited]

Definition at line 67 of file PrintFormat.py.

Reimplemented from Bio.Restriction.PrintFormat.PrintFormat.

Definition at line 2151 of file Restriction.py.

Definition at line 2065 of file Restriction.py.

Definition at line 2066 of file Restriction.py.


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