Compile kent source as dynamic library

From genomewiki
Revision as of 18:51, 18 May 2013 by Max (talk | contribs)
Jump to navigationJump to search

To run kent src functions from python, you need to compile the tree with -fPIC. It's easier to deactivate the various libraries:

 cd src/lib
 make USE_SAMTABIX=0 USE_TABIX=0 USE_BAM=0 CFLAGS=-fPIC USE_SSL=0
 gcc -shared -o kent.so *.o font/*.o -lz -lpng

Now you can do this to generate a python stub (wrapper) for any kent source library:

 ctypesgen.py ../inc/psl.h -lkent.so -o psl.py
 

And then call kent source functions in your python script:

 import psl
 p = psl.pslLoadAll("test.psl")
 print p.contents.blockCount

Remember to specify the dependencies when you create these stubs, so for pslTransMap.h you need psl.h. Maybe easier to specify all .h files?

 ctypesgen.py ~/kent/src/inc/*.h -lkent.so -o pslTransMap.py -I ~/kent/src/inc/ -I ~/kent/src/hg/inc