Last active
October 25, 2022 11:19
-
-
Save elowy01/6d3639b5f8b480bc1e30d8ec74f1290c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pdb | |
all_ids = set() | |
def parse_ids(ifile: str): | |
"""Parse ids from list. Ids are in first column""" | |
info_d = dict() | |
with open(ifile) as ifile1: | |
for line in ifile1: | |
line = line.rstrip("\n"); | |
if line.startswith("#"): continue | |
els = line.split('\t') | |
all_ids.add(els[0]) | |
info_d[els[0]] = els[1] | |
return info_d | |
info_d1 = parse_ids('file1.tsv') | |
info_d2 = parse_ids('file2.tsv') | |
for id in all_ids: | |
newline = f"{id}\t" | |
if id in info_d1: | |
newline+=f"{info_d1[id]}\t" | |
else: | |
newline+="NA\t" | |
if id in info_d2: | |
newline+=f"{info_d2[id]}" | |
else: | |
newline+="NA" | |
print(newline) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment