Skip to content

Commit

Permalink
Merge pull request #557 from hyanwong/new-map-mutations
Browse files Browse the repository at this point in the history
Switch to the (more correct) new map_mutations code
  • Loading branch information
mergify[bot] committed Jul 10, 2021
2 parents b20889e + 0242c6c commit 6de0cb4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion requirements/CI-tests-complete/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ pytest-xdist==2.2.1
seaborn==0.11.1
sortedcontainers==2.3.0
tqdm==4.60.0
tskit==0.3.5
tskit==0.3.7
zarr==2.8.1
2 changes: 1 addition & 1 deletion requirements/CI-tests-pip/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ pytest-xdist==2.2.1
seaborn==0.11.1
sortedcontainers==2.3.0
tqdm==4.61.1
tskit==0.3.6
tskit==0.3.7
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def finalize_options(self):
"tqdm",
"humanize",
"daiquiri",
"tskit>=0.3.3",
"tskit>=0.3.7",
"numcodecs>=0.6",
"zarr>=2.2",
"lmdb",
Expand Down
17 changes: 3 additions & 14 deletions tsinfer/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def insert_missing_sites(
for variant in sample_data.variants(sites=new_sd_sites):
site = variant.site
pos = site.position
anc_state = site.ancestral_state
anc_state = site.ancestral_state # NB: None means an unknown ancestral state
anc_value = 0 # sample_data files always have 0 as the ancestral allele idx
G = variant.genotypes[sample_id_map]
# We can't perform parsimony inference if all sites are missing, and there's no
Expand All @@ -725,11 +725,9 @@ def insert_missing_sites(
else:
while tree.interval[1] <= pos:
tree = next(trees)
inferred_anc_state, mapped_mutations = tree.map_mutations(
G, variant.alleles
anc_state, mapped_mutations = tree.map_mutations(
G, variant.alleles, ancestral_state=anc_state
)
if anc_state is None:
anc_state = inferred_anc_state
metadata = _update_site_metadata(
site.metadata, inference_type=constants.INFERENCE_PARSIMONY
)
Expand All @@ -741,15 +739,6 @@ def insert_missing_sites(
metadata=metadata,
)
mut_map = {tskit.NULL: tskit.NULL}
if anc_state != inferred_anc_state:
# Need to add an extra mutation above the root to switch ancestral state
for root in tree.roots:
mut_map[tskit.NULL] = tables.mutations.add_row(
site=new_site_id,
node=root,
derived_state=inferred_anc_state,
parent=tskit.NULL,
)
for i, mutation in enumerate(mapped_mutations):
mut_map[i] = tables.mutations.add_row(
site=new_site_id,
Expand Down

0 comments on commit 6de0cb4

Please sign in to comment.