[Biopython] type object 'RestrictionType' has no attribute 'size'

Peter Cock p.j.a.cock at googlemail.com
Wed Dec 4 23:38:08 UTC 2013


On Wed, Dec 4, 2013 at 4:48 PM, Christopher J Friedline
<cfriedline at vcu.edu> wrote:
> Hi everyone,
>
> I ran into this problem today, and wanted to bring it up to see if anyone
> else has seen it.  Searching the archives didn't get me anywhere.  I'm
> running a simple restriction analysis (on a random genome), and getting
> this error. If I look for cut sites with the enzymes individually, it works
> for each. However, when I put them into a RestrictionBatch, I get an error
> on the class.
>
> type object 'RestrictionType' has no attribute 'size'
>
> I put an IPython notebook describing this here:
>
> http://nbviewer.ipython.org/gist/cfriedline/7790932
>
> Bio (1.6.2), IPython (1.1.0), Python (2.7.6/Anaconda 1.8)
>
> Any help is appreciated,
>
> Thanks,
> Chris

Hi Chris,

Unfortunately when I tried it with a random genome like your
example it didn't fail... can you replace your random genome
with something fixed and still get the exception from the .with_site()
call? i.e. Can we eliminate the randomness as a factor?

Here's a cut down example which works for me (64 bit Linux,
Python 2.7.3, latest Biopython from git):

>>> from Bio.Restriction import *
>>> from Bio.Seq import Seq
>>> g = Seq(EcoRI.site + "ACGT" + MstI.site + "ACGT" + EcoRI.site)
>>> rb = RestrictionBatch(['EcoRI', 'MstI'])
>>> ana = Analysis(rb, g, linear=True)
>>> ana.with_sites()
{EcoRI: [2, 22], MstI: [14]}

This rings a couple of bells (oddities with the .size property),
http://lists.open-bio.org/pipermail/biopython-dev/2013-October/010935.html

Also a much older thread where RestrictionBatch gave trouble,
which it appears was never properly resolved
http://lists.open-bio.org/pipermail/biopython/2009-December/006004.html
http://lists.open-bio.org/pipermail/biopython/2009-December/006005.html

That example fails today, with hindsight one of us should
have filed a bug rather than just forgetting about it once
the original poster's problem was solved. It looks like it
could be down to the version of Python...

Again using Biopython from git,

$ python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Bio.Restriction import *
>>> EcoRI.size == len(EcoRI) == 6
True
>>> rb = RestrictionBatch(first=[], suppliers=['F','R'])
>>> len(rb) #varies depending on version of REBASE
235
>>> len([x for x in rb if x.size == 6])
125
>>> len(rb.lambdasplit(lambda x: x.size == 6)) #same?
0
>>> len(rb.lambdasplit(lambda x: len(x) == 6)) #same?
0

(This is probably a separate issue to yours though.)

Peter



More information about the Biopython mailing list