[Biopython-dev] COMPASS parsing code

Brad Chapman chapmanb at uga.edu
Wed May 5 06:32:31 EDT 2004


Hi James;

> I have written some code for parsing compass results.  
[...]
> I have attached the code, which you might like to include in the biopython 
> distribution. 

Thank you! I just checked this code into Bio/Compass/__init__.py.
There are a few adjustments based on your points below but basically
it is as submitted. Please let me know if I messed anything up.

> There are probably a few issues with the code that could make it better:
> 
> * the unit tests use some sample input, file comtest1 and comtest2.  These are 
> just read using open.  I have seen someone use test.locate or something like 
> that, but I'm not sure how that works.  If you want to enlighten me, I'll 
> change it.

Biopython has it's own test system in the Tests directory, which 
allows us to run all of the tests at once. It is documented pretty
decently in:

http://www.biopython.org/docs/cookbook/biopython_test.html

I converted your code over to this system (thanks for using
unittest, by the way) and it is located in Tests/test_Compass.py
with the input files in Tests/Compass/.

> * i have used regular expressions inefficiently, as I'm not sure how you're 
> supposed to cache them using the _Scanner/_Consumer framework.  At the moment 
> each subroutine compiles an re when called, which can't be good.  Again, 
> please enlighten me to a better way and I will change it.

I just made the compiled regular expressions attributes of the
_Scanner class. This way they should only be compiled a single time
when a class is first instantiated, and then will be used when the
functions are called during the scanning. I think this will make
things a little more efficient, although I am certainly no regular
expressions expert myself.

Thanks again for the contribution! Much appreciated.
Brad



More information about the Biopython-dev mailing list