Hi Michel, the error message appears to indicate that Python's anydbm module was unable to create a file .pygr_data in your directory D:/pygr/data. A few questions:
- are you running this on cygwin? it's confusing that you're using unix style path separators (/) in your PYGRDATAPATH, even though you are evidently running on Windows. I assume os.path.join() is going to use backslash as the path separator on your platform, so presumably shelve will try to open 'D:/pygr/data\.pygr_data', and I have no idea whether that will succeed on your platform. You can use the python debugger to see exactly what file path it is trying to open, I guess... - are you able to create a file with that path by hand? Are you sure there is no privilege problem? The error message clearly indicates a failure to open that file: > d.open(file, db.DB_HASH, flags, mode) > DBError: (5, 'Input/output error') - Does the pygr 0.8 test suite pass on your box? I run the full test suite on Windows XP + cygwin pretty much every day, passing all tests (including the metabase tests that are exactly equivalent to what you are trying to do). Run them as follows: cd pygr/tests python runtest.py - minor point: I find it confusing that you are using the wrong import statements. It should be "from pygr import seqdb" or "import pygr.seqdb", not "import seqdb". It looks like you have installed pygr into your Python sitepackages. Are you using some wierd setting of PYTHONPATH? Why not just set PYGRDATAPATH to '.' (current directory), to eliminate all issues about whether the directory is writable... -- Chris On May 2, 2009, at 10:01 AM, michel bellis wrote: > > Hi, > > I want to develop an application based on PyGr, and learn to use the > version 0.8. > I first succeeded in merging several FASTA files into pureseq and > seqlen files but I have run > into a problem when trying to create from them a pygr file (I use > eclipse on windows xp and set the environment variable PYGRDATAPATH to > a local disk). > > Thanks for your help > > Michel > > 1/ if I run the following program (cf 3/) I get this error message : > Traceback (most recent call last): > File "E:\sosma\projet\python\SYSBIOPY\src\tool\database > \makepygr.py", line 8, in <module> > import Data > File "Z:\prog\python25\lib\site-packages\pygr\Data.py", line 2, in > <module> > from pygr import pygrData,pygrSchema > ImportError: cannot import name pygrData > > 2/ if I use the console I get this message: > > import seqdb > import Data > os.chdir('D:/data/ucsc/genome') > newDB = seqdb.SequenceFileDB('D:/data/ucsc/genome/hg18') > seqLenDict open > newDB.__doc__ = 'homo sapiens genome sequence draft 18' > Data.Bio.Seq.HUMAN.hg18 = newDB > Traceback (most recent call last): > File "Z:\prog\python25\lib\site-packages\pygr\metabase.py", line > 905, in update > **mdbArgs) > File "Z:\prog\python25\lib\site-packages\pygr\metabase.py", line > 770, in __init__ > storage = ShelveMetabase(dbpath, self, **kwargs) > File "Z:\prog\python25\lib\site-packages\pygr\metabase.py", line > 488, in __init__ > self.db = dbfile.shelve_open(self.dbpath, 'c') > File "Z:\prog\python25\lib\site-packages\pygr\dbfile.py", line 119, > in shelve_open > d = open_index(filename, flag, useHash, mode) # construct Shelf > only if OK > File "Z:\prog\python25\lib\site-packages\pygr\dbfile.py", line 77, > in open_index > return open_bsddb(filename, flag, useHash, mode) > File "Z:\prog\python25\lib\site-packages\pygr\dbfile.py", line 45, > in open_bsddb > return open_anydbm(filename, flag) > File "Z:\prog\python25\lib\site-packages\pygr\dbfile.py", line 21, > in open_anydbm > return anydbm.open(*args, **kwargs) > File "Z:\prog\python25\lib\anydbm.py", line 83, in open > return mod.open(file, flag, mode) > File "Z:\prog\python25\lib\dbhash.py", line 16, in open > return bsddb.hashopen(file, flag, mode) > File "Z:\prog\python25\lib\bsddb\__init__.py", line 310, in hashopen > d.open(file, db.DB_HASH, flags, mode) > DBError: (5, 'Input/output error') > > WARNING: error accessing metabase 'D:/pygr/data'. Continuing... > Exception exceptions.AttributeError: "'ShelveMetabase' object has no > attribute 'db'" in <bound method ShelveMetabase.__del__ of > <pygr.metabase.ShelveMetabase object at 0x0122C8B0>> ignored > Traceback (most recent call last): > File "<console>", line 1, in <module> > File "Z:\prog\python25\lib\site-packages\pygr\metabase.py", line > 1196, in __setattr__ > self._mdb.add_resource(self.getPath(name), obj) > File "Z:\prog\python25\lib\site-packages\pygr\metabase.py", line > 724, in add_resource > self.get_writer().saver.add_resource(resID, obj) > File "Z:\prog\python25\lib\site-packages\pygr\metabase.py", line > 864, in get_writer > return MetabaseBase.get_writer(self) # proceed as usual > File "Z:\prog\python25\lib\site-packages\pygr\metabase.py", line > 721, in get_writer > raise PygrDataReadOnlyError('this metabase is read-only!') > PygrDataReadOnlyError: this metabase is read-only! > > 3/ my program: > > ''' > Created on 23 avr. 2009 > construct pygr data base > @author: bellis > ''' > import os > import seqdb > import Data > > > > > def make_blast_db(inputFileDir): > """ generate .seqlen and test.pureseq files. > test.seqlen file is for saving coordinates and identifiers > information > to access your sequences (python shelve file), and test.pureseq > file > is sequence only file without sequence header. > """ > os.chdir(inputFileDir) > fileList=os.listdir(inputFileDir) > for fileName in fileList: > seqdb.BlastDB(fileName) > > > def make_pygr_db(inputFileDir, speciesName, dbName, shortDescription): > os.chdir(inputFileDir) > newDB = seqdb.SequenceFileDB(inputFileDir+os.sep+dbName) > newDB.__doc__ = shortDescription > eval('Data.Bio.Seq.Genome.%s.%s = newDB',speciesName,dbName) > Data.save() > > > > if __name__=='__main__': > > #MERGE FASTA FILES > # INPUTFILE_DIR='D:/data/ucsc/hg18' > # make_blast_db(INPUTFILE_DIR) > > #CREATE PYGR RESSOURCE > INPUTFILE_DIR='D:/data/ucsc/genome' > SPECIES='HUMAN' > DB_NAME='hg18' > SHORT_DESCRIPTION='homo sapiens genome sequence draft 18' > make_pygr_db(INPUTFILE_DIR, SPECIES, DB_NAME, SHORT_DESCRIPTION) > > #COMMAND USED IN CONSOLE MODE > #import os > #import seqdb > #import Data > #os.chdir('D:/data/ucsc/genome') > #newDB = seqdb.SequenceFileDB('D:/data/ucsc/genome/hg18') > #newDB.__doc__ = 'homo sapiens genome sequence draft 18' > #Data.Bio.Seq.HUMAN.hg18 = newDB > #Data.save() > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---