Skip to content

Instantly share code, notes, and snippets.

@saliksyed
Created November 1, 2018 19:53
Show Gist options
  • Save saliksyed/84b7f2674c489a1c6f65e4330eab1d32 to your computer and use it in GitHub Desktop.
Save saliksyed/84b7f2674c489a1c6f65e4330eab1d32 to your computer and use it in GitHub Desktop.
Immune Atlas data parser
"""
Downloaded from: https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE118189
"""
with open('GSE118189_ATAC_counts.txt', 'r') as f:
cell_files = None
for line in f.readlines():
line = line.rstrip()
if not cell_files:
cell_types = line.split('\t')
cell_files = [open('./ImmuneAtlasBed/' + cell + '.bed' , 'w') for cell in cell_types]
else:
values = line.split('\t')
interval = values[0].split('_')
counts = [int(x) for x in values[1:]]
for i, file in enumerate(cell_files):
file.write('\t'.join(interval + [str(counts[i])]) + '\n')
for file in cell_files:
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment