Skip to content

Commit

Permalink
expose ambiguity map for protobuf loading
Browse files Browse the repository at this point in the history
  • Loading branch information
willdumm committed Jan 3, 2024
1 parent 446cdee commit 18f14a2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion historydag/mutation_annotated_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
compact_genome_hamming_distance_countfuncs,
leaf_ambiguous_compact_genome_hamming_distance_countfuncs,
default_nt_transitions,
standard_nt_ambiguity_map,
)
import historydag.dag_pb2 as dpb
import json
Expand Down Expand Up @@ -588,6 +589,7 @@ def load_MAD_protobuf(
compact_genomes=False,
node_ids=True,
leaf_cgs={},
ambiguity_map=standard_nt_ambiguity_map,
):
"""Convert a Larch MAD protobuf to a CGLeafIDHistoryDag with compact
genomes in the `compact_genome` label attribute.
Expand All @@ -607,6 +609,8 @@ def load_MAD_protobuf(
labels are unique.
leaf_cgs: (not implemented) A dictionary keyed by unique string leaf IDs containing CompactGenomes.
Use :meth:`compact_genome.read_alignment` to read an alignment from a file.
ambiguity_map: A :meth:`historydag.parsimony_utils.AmbiguityMap` object
to determine how conflicting pendant edge mutations are represented.
Note that if leaf sequences in the original alignment do not contain ambiguities, it is not
necessary to provide alignment data; leaf sequences can be completely inferred without it.
Expand Down Expand Up @@ -710,7 +714,8 @@ def get_leaf_cg(node_id):
[
node_id_to_cg[edge.parent_node].apply_muts(muts)
for edge, muts in zip(edges, str_mutations)
]
],
ambiguitymap=ambiguity_map,
)

for node_id in self.id_reverse_postorder[1:]:
Expand Down

0 comments on commit 18f14a2

Please sign in to comment.