On Wed, Oct 22, 2008 at 05:47:49PM -0700, C. Titus Brown wrote:
-> 
-> -> > Traceback (most recent call last):
-> -> >   File "protest.py", line 123, in <module>
-> -> >     if do_test(sys.argv[2],sys.argv[3],sys.argv[4]):
-> -> >   File "protest.py", line 33, in do_test
-> -> >     m()
-> -> >   File "/result/pygr_megatest/src_save/pygr/tests/sequence_test.py",  
-> -> > line 88, in blast_test
-> -> >     minAlignSize=14,pIdentityMin=0.5)
-> -> >   File "pygr.cnestedlist.pyx", line 599, in  
-> -> > pygr.cnestedlist.NLMSASlice.edges
-> -> >   File "pygr.cnestedlist.pyx", line 831, in  
-> -> > pygr.cnestedlist.NLMSASlice.groupByIntervals
-> -> >   File "pygr.cnestedlist.pyx", line 882, in  
-> -> > pygr.cnestedlist.NLMSASlice.filterIvalConservation
-> -> > TypeError: 'dict' object doesn't support item deletion
-> -> 
-> -> This error message is puzzling.  The Python 2.6 docs explicitly  
-> -> support the use of del on a dict object:
-> -> "del d[key]
-> ->      Remove d[key] from d. Raises a KeyError if key is not in the map."
-> -> 
-> -> Also, it's hard to see how all the megatests could pass if such a  
-> -> basic language feature were removed in 2.6.  This message sounds like  
-> -> a bug to me... but whose bug?  My first guess is that this might be a  
-> -> Python 2.6 bug, since it's still quite new...
-> 
-> This is almost certainly due to a Pyrex version upgrade; it's the same
-> kind of error I tracked down for the seqdb cache.

OK, figured it out... this is a pyrex bug related to an optimization for
indexing maps with C integers.

The gory details follow.

--

I went through and ran the tests on each of the pyrex releases through
0.9.6.4, which was where the problem went away.

In Pyrex 0.9.7, I get this error:

File "pygr.cnestedlist.pyx", line 781, in
pygr.cnestedlist.NLMSASlice.groupByIntervals
TypeError: 'dict' object is unindexable

In Pyrex 0.9.7.1, you get this error:

File "pygr.cnestedlist.pyx", line 784, in
pygr.cnestedlist.NLMSASlice.groupByIntervals
TypeError: 'dict' object does not support item assignment

And in Pyrex 0.9.7.2, you get *this* error:

File "pygr.cnestedlist.pyx", line 884, in
pygr.cnestedlist.NLMSASlice.filterIvalConservation
TypeError: 'dict' object doesn't support item deletion

--

(easy_install makes it really easy to install multiple versions!)

--

Going into the pyrex CHANGES.txt,

  http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/CHANGES.txt

I note further clues:

0.9.7.2 -- Another integer indexing problem fixed.

0.9.7.1 --
  
  - The optimisation for indexing using a C int failed when the
    object being indexed was a mapping rather than a sequence.
    [Arc Riley]

--

So it's likely just to be a bug in Pyrex; I'll submit a bug report to
them once I can get the problem written up in a nice, small bit of pyx
code.

In the meantime, there are two possible fixes for pygr:

 - don't declare targetID as a C integer (-> unoptimized performance)

 - call 'seqIntervals.__delitem__(targetID)' instead of
   'del seqIntervals[targetID]' .

See the attached diff for exact line numbers in cnestedlist.pyx.

Both seem to work -- as in, no complaints from Python or Pyrex in
running the tests -- and I'm slightly in favor of the first change.

Chris, let me know which you prefer and I'll wrap it up in a nice patch.
Alternatively you can just make the changes yourself and check it in:
the first fix is a one-line change, and the second is a two-line change.

sleuthing-ly yours,
--titus
-- 
C. Titus Brown, [EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pygr-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pygr-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

diff --git a/pygr/cnestedlist.pyx b/pygr/cnestedlist.pyx
index f71ae03..5593775 100644
--- a/pygr/cnestedlist.pyx
+++ b/pygr/cnestedlist.pyx
@@ -856,7 +856,7 @@ alignment intervals to an NLMSA after calling its build() me
 
   def filterIvalConservation(self,seqIntervals,pIdentityMin=None,
                              filterFun=None,**kwargs):
-    cdef int i,j,targetID
+    cdef int i,j
     cdef NLMSA nl
     import types
     if filterFun is None:
@@ -869,6 +869,7 @@ alignment intervals to an NLMSA after calling its build() me
         try:
           pIdentityMin=pIdentityMin0[seq] # LOOK UP DESIRED IDENTITY FOR THIS S
         except KeyError:
+#          seqIntervals.__delitem__(targetID) # pyrex bug? CTB
           del seqIntervals[targetID] # SO REMOVE TARGET ENTIRELY
           continue # NO NEED TO PROCESS THIS TARGET ANY FURTHER
       j=0
@@ -879,6 +880,7 @@ alignment intervals to an NLMSA after calling its build() me
         l[j]=newIval # COMPACT THE ARRAY: KEEP newIval IN LOCATION j
         j=j+1 # KEEP THIS ARRAY ENTRY, SO INCREMENT COUNT OF ENTRIES
       if j==0: # NO INTERVALS FOR THIS SEQUENCE SURVIVED MASKING
+#        seqIntervals.__delitem__(targetID) # pyrex bug? CTB
         del seqIntervals[targetID] # SO REMOVE TARGET ENTIRELY
       elif j<i: # SOME INTERVALS REMOVED, SO SHRINK ITS LIST
         del l[j:] # JUST TRUNCATE THE LIST TO ENTRIES THAT PASSED

Reply via email to