Ok, I found out what the problem was with gdbm. Since I had run pygr with Apple's builtin python distribution before, I had an existing database called /Users/naomi/projects/data/MM0240/MM0240.fa.seqlen.db. which was of format dbm. So, even though I am using Macports' python 2.7 with gdbm now, pygr picked up the existing dbm database and complained that it could not iterate over it. Removing the database fixed the problem, of course. But I wonder, is there something like a "make clean" command for pygr, which gets rid of all databases created, or at least those created for a certain .fa file?
-Naomi On Thu, Dec 23, 2010 at 10:25 AM, Christopher Lee <l...@chem.ucla.edu>wrote: > > On Dec 23, 2010, at 12:50 AM, Naomi Ellen wrote: > > > My Mac does not have the Berkeley DB installed, and there doesn't seem to > be any Berkeley DB build for the Mac. > > Besides, you need an account with Oracle to download the source code. > > Since you raised this, I just tried downloading and building Berkeley DB on > Mac OS 10.6 following these instructions, which seemed to work fine: > http://code.google.com/p/tonatiuh/wiki/InstallingBerkeleyDBForMac > (he provides a link for downloading Berkeley DB). The only annoyance I hit > was that it's not obvious what rules Oracle enforces on your proposed > password; it kept rejecting everything I tried. Finally I succeeded. The > rule seems to be: at least one number, at least one capital letter, at least > one lowercase letter, no non-alphanumeric characters, and at least 8 > characters long. Also, your username has to be an email address, although > they don't seem to do anything to verify it. > > The build ran fine. I didn't try to actually install it, as it's my policy > never to modify my Apple-supplied system files (i.e. I always install > software to other locations, a la Fink). > > > > > Is there really no way to run pygr with gdbm on the Mac? I installed > Python 2.7 and gdbm from Macports, and still, > > no success: > > > > >>> import gdbm > > >>> from pygr import seqdb > > >>> sp = > seqdb.SequenceFileDB('/Users/naomi/projects/data/MM0240/MM0240.fa') > > WARNING dbfile.open_index: Falling back to hash index: unable to import > bsddb > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygr-0.8.2-py2.7-macosx-10.6-x86_64.egg/pygr/seqdb.py", > line 433, in __init__ > > SequenceDB.__init__(self, filepath=filepath, dbname=dbname, **kwargs) > > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygr-0.8.2-py2.7-macosx-10.6-x86_64.egg/pygr/seqdb.py", > line 232, in __init__ > > self._set_seqtype() > > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygr-0.8.2-py2.7-macosx-10.6-x86_64.egg/pygr/seqdb.py", > line 244, in _set_seqtype > > for seqID in self: # get an iterator > > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygr-0.8.2-py2.7-macosx-10.6-x86_64.egg/pygr/seqdb.py", > line 304, in __iter__ > > return iter(self.seqInfoDict) > > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygr-0.8.2-py2.7-macosx-10.6-x86_64.egg/pygr/seqdb.py", > line 517, in __iter__ > > return iter(self.seqDB.seqLenDict) > > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygr-0.8.2-py2.7-macosx-10.6-x86_64.egg/pygr/dbfile.py", > line 150, in __iter__ > > Original error message was: %s''' % str(exc_value)) > > TypeError: cannot iterate over this dictionary. > > This means that you do not have bsddb, bsddb3, or gdbm available for use > by > > the 'shelve' module in this Python install. Please fix this! > > > > Original error message was: 'dbm.dbm' object is not iterable > > >>> definitions = gdbm.open('test_gdbm.dbm', 'c') > > Pygr relies on the Python standard module anydbm to return whatever dbm > style hash module your install supports, including gdbm. (anydbm tries them > in the order: dbhash, gdbm, dbm, dumbdbm). The Pygr error message above > means that both iter(d) and d.firstkey() failed, i.e. the hash-dictionary > object supports neither standard Python iteration nor gdbm's > firstkey()/nextkey() iteration methods. The implication is that either > > - anydbm is choosing something other than gdbm, even though you say you > have gdbm. > > - or somehow gdbm is misbehaving. > > To figure out what's going on, try the following tests: > > import anydbm > print anydbm._defaultmod > d = anydbm.open('test_anydbm.dbm', 'c') > it = iter(d) > it.next() > > anydbm._defaultmod shows which hash module anydbm actually chose. > If the hash supports iteration, it.next() should simply raise StopIteration > (because the hash is empty). > > A gdbm hash will fail on iter(d) because it lacks standard iteration > methods. In that case try the following: > > k = d.firstkey() > print k > > If gdbm is working normally, the value of k should be None (because the > hash is empty). > > Let me know what results you get. > > -- Chris > > -- > You received this message because you are subscribed to the Google Groups > "pygr-dev" group. > To post to this group, send email to pygr-...@googlegroups.com. > To unsubscribe from this group, send email to > pygr-dev+unsubscr...@googlegroups.com<pygr-dev%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/pygr-dev?hl=en. > > -- You received this message because you are subscribed to the Google Groups "pygr-dev" group. To post to this group, send email to pygr-...@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.