Commit d7f36232 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

allow to process gzipped or plain input files

parent 3d66124d
......@@ -65,16 +65,30 @@ output = open(output_file_unsorted, "w")
print('Generating bed file: ' + output_file_unsorted)
with gzip.open(inputFile, 'rt') as hIN:
for line in hIN:
F = line.rstrip('\n').split('\t')
output_line = transform(F)
if output_line[0] in chromosomes:
print("\t".join(output_line), file=output)
else:
if not output_line[0] in unkown_chromosomes:
print("Unknown chromosome '" + output_line[0] + "'")
unkown_chromosomes[output_line[0]] = True
if inputFile.endswith('gz'):
with gzip.open(inputFile, 'rt') as hIN:
for line in hIN:
F = line.rstrip('\n').split('\t')
output_line = transform(F)
if output_line[0] in chromosomes:
print("\t".join(output_line), file=output)
else:
if not output_line[0] in unkown_chromosomes:
print("Unknown chromosome '" + output_line[0] + "'")
unkown_chromosomes[output_line[0]] = True
else:
with open(inputFile) as f:
lines = f.readlines()
for line in lines:
F = line.rstrip('\n').split('\t')
output_line = transform(F)
if output_line[0] in chromosomes:
print("\t".join(output_line), file=output)
else:
if not output_line[0] in unkown_chromosomes:
print("Unknown chromosome '" + output_line[0] + "'")
unkown_chromosomes[output_line[0]] = True
output.close()
if not Path('bin').is_dir():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment