- #!/usr/bin/python
- # programmer : Daofeng
- # usage:
- from batch_big_2_tabix import *
- import sys
- #chr start end length summit tags -10*log10(pvalue) fold_enrichment FDR(%)
- #chr1 887607 888881 1275 940 110 89.97 4.17 88.94
- #chr1 968170 970743 2574 1243 256 291.17 5.1 100
- # peak
- #chr9 95326322 95326374 merge_4074-0_peak_1226 150 . 6.31835 15.07557 -1.00000 23
- #chr5 64735232 64735586 merge_4074-0_peak_894 108 . 6.25611 10.87670 -1.00000 169
- def main():
- inf = sys.argv[1]
- outf = '{}.bed'.format(inf)
- i = 0
- try:
- with open(inf,"rU") as infile:
- next(infile)
- with open(outf,'w') as outfile:
- for line in infile:
- i += 1
- t = line.strip().split('\t')
- #outfile.write('{0[0]}\t{0[1]}\t{0[2]}\tscorelst:[{0[5]},{0[6]},{0[7]},{0[8]}],id:{1},name:"{1}",sbstroke:[{0[4]}]\n'.format(t, i))
- #for peak
- outfile.write('{0[0]}\t{0[1]}\t{0[2]}\tscorelst:[{0[4]},{0[6]},{0[7]},{0[8]}],id:{1},name:"{0[3]}",sbstroke:[{0[9]}]\n'.format(t, i))
- except IOError,message:
- print >> sys.stderr, "cannot open file",message
- sys.exit(1)
- toTabix(outf)
- if __name__=="__main__":
- main()
Raw Paste