Skip to content
nchernia edited this page Oct 14, 2016 · 20 revisions

Compiling (Bootstrap version)

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

  1. Get Boost:
    http://www.boost.org/doc/libs/1_61_0/more/getting_started/unix-variants.html#get-boost
  2. 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)
  3. Type "bjam" in the directory with the files (assuming you've put boost and bjam in your path).

Examples

See the script straw.py for an example of how to call the C++. The usage is the same as in C++, e.g.:

  • Extract all reads on chromosome X at 1MB resolution with no normalization in local file "HIC001.hic"

    import straw_ext
    
    bins = straw_ext.straw("NONE HIC001.hic X X BP 1000000");
    # the values returned are in bins.x / bins.y / bins.counts
    for i in range(len(bins.x)):
       print bins.x[i], bins.y[i], bins.counts[i]
  • Extract reads between 1MB and 7.5MB on chromosome 1 at 25KB resolution with KR (balanced) normalization:

    import straw_ext
    
    bins =  straw_ext.straw("KR HIC001.hic 1:1000000:7400000 1:1000000:7400000 BP 25000")
    # the values returned are in bins.x / bins.y / bins.counts
    for i in range(len(bins.x)):
       print bins.x[i], bins.y[i], bins.counts[i]
  • Extract all interchromosomal reads between chromosome 5 and chromosome 12 at 500 fragment resolution with VC (vanilla coverage) normalization:

    import straw_ext
    
    bins =  straw_ext.straw("VC HIC001.hic 5 12 FRAG 500")
    # the values returned are in bins.x / bins.y / bins.counts
    for i in range(len(bins.x)):
       print bins.x[i], bins.y[i], bins.counts[i]

Pure Python (incomplete)

We're working on a Python-only API for reading .hic files. For now, see the file read_hic_header.py for a Python script that reads the header of a hic file.

Clone this wiki locally