Hi Marek, it would be helpful if you'd post the details of the traceback for the "int key" megatest error, and the location / procedure for running the megatests to reproduce the problem. If the traceback message sent by Namshin below matches what you're seeing, something strange is happening: the code actually guarantees that the key is a string, so shelve reporting that the key is an int is... confusing.
def get_prefix_id(self, k): 'subdivide key into prefix, id using separator' try: t = k.split(self.separator) except AttributeError: raise KeyError('key should be string! ' + repr(k)) l = len(t) if l == 2: return t ... more lines of code here... def __getitem__(self,k): "for ID 'foo.bar', return item 'bar' in dict f associated with prefix 'foo'" prefix,seqID = self.get_prefix_id(k) try: return self.get_subitem(self.prefixDict[prefix], seqID) As you can see, __getitem__() first calls get_prefix_id(), which immediately verifies that k is a string (or at least has a split() method). So seqID is guaranteed to be a string. So how can return d[seqID] in get_subitem() raise an error claiming that seqID is an int? -- Chris > On Tue, Mar 24, 2009 at 1:03 PM, Namshin Kim <n...@rna.kr> wrote: > File "/usr/local/lib/python2.5/shelve.py", line 112, in __getitem__ > f = StringIO(self.dict[key]) > TypeError: 'int' object is unsubscriptable > > At the end of error message, you can see shelve error saying integer > key is not allowed. > > On Tue, Mar 24, 2009 at 12:40 PM, Namshin Kim <n...@rna.kr> wrote: > Hi Marek, > > I think the error is coming from seqdb. It should change integer ID > into string automatically, but it looks like it is returning integer > ID as itself. As you know, python shelve does not take integer ID, > only string ID. > > For further checking, we need to build custom annotation database > with integer ID and check whether it handles integer<->string > conversion correctly. As I remember, integer ID is somehow changed > into like 'INT:1'. > > File "/result/pygr_mt_metabase/pygr/build/lib.linux-x86_64-2.5/ > pygr/seqdb.py", line 565, in __getitem__ > return self.get_subitem(self.prefixDict[prefix], seqID) > File "/result/pygr_mt_metabase/pygr/build/lib.linux-x86_64-2.5/ > pygr/seqdb.py", line 558, in get_subitem > return d[seqID] > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pygr-dev" group. To post to this group, send email to pygr-dev@googlegroups.com To unsubscribe from this group, send email to pygr-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pygr-dev?hl=en -~----------~----~----~----~------~----~------~--~---