# Custom script for handling peak data from P. Farnham's lab # # Find the center of each peak, and generate coordinates +/- 3kb from center # Also add 'name' attribute import sys in_fn = None out_fn = None if len(sys.argv) != 3: print "\nSpecify:\n" print "(1) input peaks file in GFF format," print "(2) output GFF file name\n" sys.exit() else: in_fn = sys.argv[1] out_fn = sys.argv[2] in_fh = open(in_fn, 'r') out_fh = open(out_fn, 'w') while 1: line = in_fh.readline() if not line: break line = line.strip() pieces = line.split("\t") start = int(pieces[3]) end = int(pieces[4]) middle = start + (end-start)/2; nStart = middle - 3000; nEnd = middle + 3000; name = pieces[0] + "_" + str(start) + "_" + str(end) out_fh.write(pieces[0] + "\t" + pieces[1] + "\t" + pieces[2] + "\t" + str(nStart) + "\t" + str(nEnd) + "\t" + pieces[5] + "\t" + pieces[6] + "\t" + pieces[7] + # '\tname \"' + name +'\"\n') "\t" + name + "\n") in_fh.close() out_fh.close()