Skip to content

Commit

Permalink
Use same haplotype style for tree and tables
Browse files Browse the repository at this point in the history
Updates the script that annotates derived haplotypes for nodes in the
tree to use the same style as the haplotypes table with hyphen-delimited
mutations (which work as values in URL parameters unlike comma-delimited
lists) and with the ancestral allele included for each mutation. These
changes should allow us to link from the haplotype tables to the tree
view for the same haplotypes.
  • Loading branch information
huddlej committed Jul 25, 2024
1 parent d783bcd commit dd9aae5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scripts/annotate_haplotypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@
mutations = []
for i in range(len(sequence_by_node[node.name])):
if sequence_by_node[node.name][i] != sequence_by_clade[clade][i]:
# Store 1-based mutation position and derived allele.
mutations.append(f"{i + 1}{sequence_by_node[node.name][i]}")
# Store ancestral allele, 1-based mutation position, and derived allele.
mutations.append(f"{sequence_by_clade[clade][i]}{i + 1}{sequence_by_node[node.name][i]}")

# Store the clade name plus a comma-delimited list of derived
# mutations present in the current node.
haplotype = f"{clade}:{','.join(mutations)}"
# Store the clade name plus a delimited list of derived mutations
# present in the current node.
haplotype = f"{clade}:{'-'.join(mutations)}"

# Store the clade and haplotype values for this node.
haplotypes[node.name][args.attribute_name] = haplotype
Expand Down

0 comments on commit dd9aae5

Please sign in to comment.