[Biopython] question about RestrictionBatch.lambdasplit
Frédéric Sohm
sohm at inaf.cnrs-gif.fr
Sat Dec 19 17:53:35 UTC 2009
Hi Björn, Peter,
The code is working for me.
I can't reproduce the bug.
>>> from Bio.Restriction import *
>>> rb = RestrictionBatch(first=[], suppliers=['F','R'])
>>> len(rb)
228
>>> len([x for x in rb if x.size == 6])
128
>>> rb2 = rb.lambdasplit(lambda x : x.size == 6)
>>> len(rb2)
128
>>> len([x for x in rb if len(x) == 6])
128
>>> rb3 = rb.lambdasplit(lambda x : len(x) == 6)
>>> len(rb3)
128
>>> rb2 == rb3
True
>>> EcoRI in rb
True
>>> EcoRI in rb2 and EcoRI in rb3
True
>>> EcoRI.size == len(EcoRI) == 6
True
>>>
I am a bit puzzled there, Peter's code should work (and is effectively
working on my machine) ...
My setup is :
Debian Lenny
python 2.5.2 or python 2.4.6 (both tested)
Biopython : 1.45
What about yours ?
Best regards
Fred
Peter wrote:
> 2009/12/19 Björn Johansson <bjorn_johansson at bio.uminho.pt>:
>> Hi,
>>
>> I am trying to get a restriction batch tha is limited to some enzymes with a
>> certain size.
>> I think that the lambdasplit might be used for this.
>>
>> I have not found any examples of the use of the restrictionbatch.lambdasplit
>>
>> rb = RestrictionBatch(first=[],suppliers=['F','R'])
>>
>> rb2= rb.lambdasplit(lambda x: x.size==6)
>>
>> this code does not work. Could someone give me an example on how to use
>> this?
>> I have tried to see docs on the lambda function in python, but I still could
>> not solve this.
>> grateful for any answer!
>> /bjorn
>
> Hmm, no mention of lambdasplit in this doc:
> http://biopython.org/DIST/docs/cookbook/Restriction.html
>
> Also no mention in Tests/test_Restriction.py
>
> Looking at the code, you need a function (which could
> be defined with a python lambda but need not be)
> which will be given as single argument and must
> return a boolean (or rather, something which will be
> evaluated as a boolean). You code looks fine:
>
>>>> from Bio.Restriction import *
>>>> rb = RestrictionBatch(first=[],suppliers=['F','R'])
>>>> len(rb)
> 228
>>>> len([x for x in rb if x.size==6])
> 128
>>>> rb2= rb.lambdasplit(lambda x: x.size==6)
>>>> len(rb2)
> 0
>
> Either we have both misunderstood the point of
> this function, or there is a bug in lambdasplit.
>
> Please file a bug report:
> http://bugzilla.open-bio.org/enter_bug.cgi?product=Biopython
>
> Thanks,
>
> Peter
>
> _______________________________________________
> Biopython mailing list - Biopython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython
>
--
Frédéric Sohm
GIS AMAGEN CNRS INRA
Equipe INRA U1126 "Morphogenèse du système nerveux des Chordés"
UPR 2197 DEPSN, CNRS
Institut de Neurobiologie A. Fessard
1 Avenue de la Terrasse
91 198 GIF-SUR -YVETTE
FRANCE
Phone: 33 1 69 82 34 12
Fax: 33 1 69 82 41 67
email: sohm at inaf.cnrs-gif.fr
More information about the Biopython
mailing list