[Biopython] SeqRecords and multiprocessing

Peter Cock p.j.a.cock at googlemail.com
Mon Apr 25 16:50:20 UTC 2011


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