[Biopython] SeqRecords and multiprocessing

McCoy, Connor O cmccoy at fhcrc.org
Mon Apr 25 17:14:37 UTC 2011


Hi Peter,

Thanks so much for looking into this - I wouldn't have guessed that a lower pickle version would solve the problem.

Everything works fine with the commit you specify below.

Thanks,
Connor

----- Original Message -----
From: "Peter Cock" <p.j.a.cock at googlemail.com>
To: "Connor O McCoy" <cmccoy at fhcrc.org>
Cc: biopython at biopython.org
Sent: Monday, April 25, 2011 9:50:20 AM
Subject: Re: [Biopython] SeqRecords and multiprocessing

On Fri, Apr 22, 2011 at 6:25 PM, Peter Cock <p.j.a.cock at googlemail.com> wrote:
> On Fri, Apr 22, 2011 at 6:03 PM, Peter Cock <p.j.a.cock at googlemail.com> wrote:
>>
>> Is the problem that _RestrictedDict isn't pickle-able?
>>
>
> This seems to work fine:
>
>>>> from Bio.SeqRecord import _RestrictedDict as RD
>>>> import pickle
>>>> x = RD(5)
>>>> x["test"] = "hello"
>>>> x
> {'test': 'hello'}
>>>> y = pickle.loads(pickle.dumps(x))
>>>> y
> {'test': 'hello'}
>>>> y._length
> 5
>
> I guessed it was down to the protocol...
>
>>>> y = pickle.loads(pickle.dumps(x,0))
>>>> y
> {'test': 'hello'}
>
>>>> y = pickle.loads(pickle.dumps(x,1))
>>>> y
> {'test': 'hello'}
>
> And suddenly:
>
>>>> y = pickle.loads(pickle.dumps(x,2))
> Traceback (most recent call last):
> ...
> AttributeError: '_RestrictedDict' object has no attribute '_length'
>
> Progress.
>
> Peter

Connor, could you try out the latest code on github please?
Specifically this changeset,

https://github.com/biopython/biopython/commit/967aadc1a82bf2f102608a73b0b8a874facf6c79

There is probably a better way to fix this, but this should do for now.

Thanks,

Peter



More information about the Biopython mailing list