Skip to content

Commit eb6693e

Browse files
authored
Add support for dynamic neighbour-joining (#647)
* upgrade anjl * add support for dynamic nj
1 parent 674169f commit eb6693e

File tree

5 files changed

+355
-350
lines changed

5 files changed

+355
-350
lines changed

malariagen_data/anoph/distance.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,13 @@ def _njt(
367367
# neighbour-joining iterations.
368368
progress_options = dict(desc="Construct neighbour-joining tree", leave=False)
369369

370-
# Decide which algorithm to use and run the neighbour-joining.
371-
if algorithm == "rapid":
370+
# Decide which algorithm to use and run the neighbour-joining. The "dynamic"
371+
# algorithm is fastest.
372+
if algorithm == "dynamic":
373+
Z = anjl.dynamic_nj(
374+
D=D, progress=self._progress, progress_options=progress_options
375+
)
376+
elif algorithm == "rapid":
372377
Z = anjl.rapid_nj(
373378
D=D, progress=self._progress, progress_options=progress_options
374379
)

malariagen_data/anoph/distance_params.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
default_distance_metric: distance_metric = "cityblock"
1515

1616
nj_algorithm: TypeAlias = Annotated[
17-
Literal["rapid", "canonical"],
18-
"Neighbour-joining algorithm to use.",
17+
Literal["dynamic", "rapid", "canonical"],
18+
"Neighbour-joining algorithm to use. The 'dynamic' algorithm is fastest.",
1919
]
2020

21-
default_nj_algorithm: nj_algorithm = "rapid"
21+
default_nj_algorithm: nj_algorithm = "dynamic"

0 commit comments

Comments
 (0)