-
Notifications
You must be signed in to change notification settings - Fork 35
Python
nchernia edited this page Mar 8, 2019
·
20 revisions
Straw uses the requests library for support of URLs. Be sure it is installed.
-
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[0])): 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 and write to a file:
import straw straw.printme("KR", "HIC001.hic", "1:1000000:7500000", "1:1000000:7500000", "BP", 25000, 'out.txt')
To get in an array:
import straw
result = straw.straw("KR", "HIC001.hic", "1:1000000:7500000", "1:1000000:7500000", "BP", 25000)
- Extract reads from a URL: chromosome 14 with KR normalization at 2.5Mb resolution, from the Cell 2014 GM12878 combined replicate map:
import straw result = straw.straw("KR", "https://hicfiles.s3.amazonaws.com/hiseq/gm12878/in-situ/combined.hic", "14", "14", "BP", 2500000)
All the maps listed in the Juicebox menu available at http://hicfiles.tc4ga.com/juicebox.properties
- 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[0])): 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).