-
Notifications
You must be signed in to change notification settings - Fork 35
Python
-
Extract all reads on chromosome X at 1MB resolution with no normalization in local file "HIC001.hic"
import straw result = straw.straw('NONE', 'HIC001.hic', 'X', 'X', 'BP', 1000000) # the values returned are in x / y / counts for i in range(len(result)): print("{0}\t{1}\t{2}".format(result[0][i], result[1][i], result[2][i]))
-
Extract reads between 1MB and 7.5MB on chromosome 1 at 25KB resolution with KR (balanced) normalization:
import straw result = straw.straw("KR", "HIC001.hic", "1:1000000:7400000", "1:1000000:7400000", "BP", 25000) # the values returned are in results for i in range(len(result)): print("{0}\t{1}\t{2}".format(result[0][i], result[1][i], result[2][i]))
-
Extract all interchromosomal reads between chromosome 5 and chromosome 12 at 500 fragment resolution with VC (vanilla coverage) normalization:
import straw result = straw.straw("VC", "HIC001.hic", "5", "12", "FRAG", 500) # the values returned are in results for i in range(len(result)): print("{0}\t{1}\t{2}".format(result[0][i], result[1][i], result[2][i]))
See the script straw.py for an example of how to print the results to a file.
See the file read_hic_header.py for a Python script that reads the header of a hic file and outputs the information (including resolutions).
These are old instructions and are no longer necessary.
Straw can be called from Python by using Boost http://www.boost.org/
The files Jamroot, straw.py, and main-python.cpp are used to hook the C++ to Python. main-python.cpp is essentially the same as main.cpp
- Get Boost:
http://www.boost.org/doc/libs/1_61_0/more/getting_started/unix-variants.html#get-boost - Compile bjam:
http://www.boost.org/doc/libs/1_49_0/more/getting_started/unix-variants.html#prepare-to-use-a-boost-library-binary (just do --with-libraries python) - Type "bjam" in the directory with the files (assuming you've put boost and bjam in your path).