In [1]:
import numpy as np
import scipy as sp
In [2]:
from Bio import Restriction as rst
from Bio.Seq import Seq
from Bio.Alphabet.IUPAC import IUPACAmbiguousDNA
In [3]:
bases = [['A','T'],['C','G']]
In [4]:
def get_genome(size, gc):
    i = 0
    genome = ""
    while i < size:
        r = np.random.randint(0,100)
        b = bases[0]
        if r < gc:
            b = bases[1]
        genome += b[np.random.random_integers(0,1)]
        i += 1
    return genome
In [5]:
def get_gc(g):
    gc = 0
    for x in genome:
        if x == "G" or x == "C":
            gc += 1.0
    return gc/len(genome)
In [6]:
genome = get_genome(1e6,60)
get_gc(genome)
Out[6]:
0.599752
In [7]:
amb = IUPACAmbiguousDNA()
In [8]:
g = Seq(genome, amb)
In [9]:
rb = rst.EcoRI + rst.MstI
In [10]:
rb
Out[10]:
RestrictionBatch(['EcoRI', 'MstI'])
In [11]:
ana = rst.Analysis(rb, g, linear=True)
In [12]:
ana.with_sites()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-12-21af6e87e288> in <module>()
----> 1 ana.with_sites()

/data7/cfriedline/anaconda/envs/conda/lib/python2.7/site-packages/IPython/core/displayhook.pyc in __call__(self, result)
    245             self.start_displayhook()
    246             self.write_output_prompt()
--> 247             format_dict, md_dict = self.compute_format_data(result)
    248             self.write_format_data(format_dict, md_dict)
    249             self.update_user_ns(result)

/data7/cfriedline/anaconda/envs/conda/lib/python2.7/site-packages/IPython/core/displayhook.pyc in compute_format_data(self, result)
    155 
    156         """
--> 157         return self.shell.display_formatter.format(result)
    158 
    159     def write_format_data(self, format_dict, md_dict=None):

/data7/cfriedline/anaconda/envs/conda/lib/python2.7/site-packages/IPython/core/formatters.pyc in format(self, obj, include, exclude)
    150             md = None
    151             try:
--> 152                 data = formatter(obj)
    153             except:
    154                 # FIXME: log the exception

/data7/cfriedline/anaconda/envs/conda/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
    479                 type_pprinters=self.type_printers,
    480                 deferred_pprinters=self.deferred_printers)
--> 481             printer.pretty(obj)
    482             printer.flush()
    483             return stream.getvalue()

/data7/cfriedline/anaconda/envs/conda/lib/python2.7/site-packages/IPython/lib/pretty.pyc in pretty(self, obj)
    345                 if cls in self.type_pprinters:
    346                     # printer registered in self.type_pprinters
--> 347                     return self.type_pprinters[cls](obj, self, cycle)
    348                 else:
    349                     # deferred printer

/data7/cfriedline/anaconda/envs/conda/lib/python2.7/site-packages/IPython/lib/pretty.pyc in inner(obj, p, cycle)
    595                 p.text(',')
    596                 p.breakable()
--> 597             p.pretty(key)
    598             p.text(': ')
    599             p.pretty(obj[key])

/data7/cfriedline/anaconda/envs/conda/lib/python2.7/site-packages/IPython/lib/pretty.pyc in pretty(self, obj)
    331         self.begin_group()
    332         try:
--> 333             obj_class = getattr(obj, '__class__', None) or type(obj)
    334             # First try to find registered singleton printers for the type.
    335             try:

/data7/cfriedline/anaconda/envs/conda/lib/python2.7/site-packages/Bio/Restriction/Restriction.pyc in __len__(cls)
    322 
    323         length of the recognition site."""
--> 324         return cls.size
    325 
    326     def __hash__(cls):

AttributeError: type object 'RestrictionType' has no attribute 'size'
In [14]:
import Bio
print Bio.__version__
1.62

In [16]:
import IPython
print IPython.__version__
1.1.0

In [17]:
import sys
print sys.version
2.7.6 |Anaconda 1.8.0 (64-bit)| (default, Nov 11 2013, 10:47:18) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)]

In [ ]: