def c_write_and_read_array(a, ref='chr1', start=0): filename = "tmp.bedgraph" with open(filename, 'w') as fileh: c_array_to_bedgraph(a, ref, start, fileh) a = bedgraph_to_array(open(filename)) os.remove(filename) return a.get(ref, None)
def write_and_read_array(a, ref='chr1', start=0): buf = cStringIO.StringIO() array_to_bedgraph(a, ref, start, buf) contents = buf.getvalue() a = bedgraph_to_array(cStringIO.StringIO(contents)) return a.get(ref, None)