Skip to content

Commit

Permalink
Add missing lineages instead of recombinant lineages
Browse files Browse the repository at this point in the history
  • Loading branch information
yexiao-cheng committed Oct 3, 2023
1 parent 8f1cffd commit b098e28
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions scripts/modify_covizu_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,22 @@ def main():
warnings.filterwarnings('ignore')

# command line interface
parser = argparse.ArgumentParser(description='Add recombinant lineages to covizu tree')
parser = argparse.ArgumentParser(description='Add missing lineages to covizu tree')
parser.add_argument('--covizu-tree', required=True, help='CoVizu time-scaled tree file')
parser.add_argument('--output', required=True, help='Modified tree file')
args = parser.parse_args()

# get recombinant lineages from github repo: pango-designation
# add lineages to tree
t = Tree(args.covizu_tree, format=1)
leaves = [leaf.name for leaf in t.get_leaves()]
url = 'https://raw.githubusercontent.com/cov-lineages/pango-designation/master/lineage_notes.txt'
resp = requests.get(url)
content = resp.content.decode()
recomb = []
for i in content.split('\n')[1:]:
l = i.split('\t')[0]
if l.startswith('X'):
recomb.append(l)

# add recombinant lineages to tree
t = Tree(args.covizu_tree, format=1)
leaves = [leaf.name for leaf in t.get_leaves()]
for r in recomb:
if r not in leaves:
t.add_child(name=r, dist=1)
if (not l.startswith('*')) and (l != ''):
if l not in leaves:
t.add_child(name=l, dist=1)

# write modified tree
t.write(outfile=args.output)
Expand Down

0 comments on commit b098e28

Please sign in to comment.