[Biopython-dev] Accessing built-in data files

Peter biopython at maubp.freeserve.co.uk
Mon Nov 19 15:52:14 UTC 2007


Tiago Antão wrote:
>> I may be naive here, but I would expect the datafiles to be installed in
>> the same relative path as the python files.  Is this not always the case?
> 
> Yep, but which datafiles and where? By which I mean, platform
> dependent or platform independent. Again this is mainly a not issue.
> But "where" is important. "Where" might be the system path and all is
> fine and dandy, but it also might be elsewhere (In my case, when
> testing I don't install to the system path. Also, if you don't have
> admin access to the machine...)

If the data files are installed the data subdirectory of where your 
python are, can't your python files just load them using a relative path?

e.g. On Windows, using Python 2.3 (from memory) the files should go:

C:\Python23\lib\site-packages\Bio\PopGen\SimCoal\*.py
C:\Python23\lib\site-packages\Bio\PopGen\SimCoal\data\*.par

On my linux machine, where I have installed Biopython under my home 
directory (rather than system wide):

~/lib/python2.4/site-packages/Bio/PopGen/SimCoal/*.py
~/lib/python2.4/site-packages/Bio/PopGen/SimCoal/data/*.par

If I had installed Biopython using admin access, it might be:

/usr/lib/python2.4/site-packages/Bio/PopGen/SimCoal/*.py
/usr/lib/python2.4/site-packages/Bio/PopGen/SimCoal/data/*.par

In all those cases, one of your SimCoal python files just needs to open 
its data files using a relative path, for example "data/island.par".

For comparison, the EUtils DTD files did end up here as I expected:

~/lib/python2.4/site-packages/Bio/EUtils/DTDs/*.dtd

Am I missing something?

Peter



More information about the Biopython-dev mailing list