Skip to content

Commit f25caf3

Browse files
committed
don't extract unused abs rfdist
1 parent 2e19061 commit f25caf3

3 files changed

Lines changed: 10 additions & 23 deletions

File tree

pypythia/prediction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def collect_features(
104104
log_info and log_runtime_information(
105105
"Computing the RF-Distance for the parsimony trees."
106106
)
107-
num_topos, rel_rfdist, _ = raxmlng.get_rfdistance_results(trees, redo=None)
107+
num_topos, rel_rfdist = raxmlng.get_rfdistance_results(trees, redo=None)
108108

109109
features = {
110110
"num_taxa": msa.n_taxa,

pypythia/raxmlng.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,24 @@ def _get_value_from_line(line: str, search_string: str) -> float:
3636
)
3737

3838

39-
def get_raxmlng_rfdist_results(log_file: pathlib.Path) -> tuple[int, float, float]:
39+
def get_raxmlng_rfdist_results(log_file: pathlib.Path) -> tuple[int, float]:
4040
"""
41-
Method to parse the RAxML-NG log file and extract the number of unique topologies, relative RF-Distance, and absolute RF-Distance.
41+
Method to parse the RAxML-NG log file and extract the number of unique topologies and relative RF-Distance.
4242
Args:
4343
log_file (pathlib.Path): Filepath pointing to the RAxML-NG log file.
4444
4545
Returns:
4646
num_topos (float): Number of unique topologies of the given set of trees.
4747
rel_rfdist (float): Relative RF-Distance of the given set of trees. Computed as average over all pairwise RF-Distances. Value between 0.0 and 1.0.
48-
abs_rfdist (float): Absolute RF-Distance of the given set of trees.
4948
5049
"""
51-
abs_rfdist = None
5250
rel_rfdist = None
5351
num_topos = None
5452

5553
for line in log_file.open().readlines():
5654
line = line.strip()
5755

58-
if "Average absolute RF distance in this tree set:" in line:
59-
abs_rfdist = _get_value_from_line(
60-
line, "Average absolute RF distance in this tree set:"
61-
)
62-
elif "Average relative RF distance in this tree set:" in line:
56+
if "Average relative RF distance in this tree set:" in line:
6357
rel_rfdist = _get_value_from_line(
6458
line, "Average relative RF distance in this tree set:"
6559
)
@@ -68,10 +62,10 @@ def get_raxmlng_rfdist_results(log_file: pathlib.Path) -> tuple[int, float, floa
6862
line, "Number of unique topologies in this tree set:"
6963
)
7064

71-
if abs_rfdist is None or rel_rfdist is None or num_topos is None:
65+
if rel_rfdist is None or num_topos is None:
7266
raise ValueError("Error parsing raxml-ng log.")
7367

74-
return int(num_topos), rel_rfdist, abs_rfdist
68+
return int(num_topos), rel_rfdist
7569

7670

7771
class RAxMLNG:
@@ -179,8 +173,8 @@ def infer_parsimony_trees(
179173

180174
def get_rfdistance_results(
181175
self, trees_file: pathlib.Path, prefix: pathlib.Path = None, **kwargs
182-
) -> tuple[float, float, float]:
183-
"""Method that computes the number of unique topologies, relative RF-Distance, and absolute RF-Distance for the given set of trees.
176+
) -> tuple[float, float]:
177+
"""Method that computes the number of unique topologies and the relative RF-Distance for the given set of trees.
184178
185179
Args:
186180
trees_file (pathlib.Path): Filepath pointing to the file containing the trees.
@@ -193,7 +187,6 @@ def get_rfdistance_results(
193187
Returns:
194188
num_topos (float): Number of unique topologies of the given set of trees.
195189
rel_rfdist (float): Relative RF-Distance of the given set of trees. Computed as average over all pairwise RF-Distances. Value between 0.0 and 1.0.
196-
abs_rfdist (float): Absolute RF-Distance of the given set of trees.
197190
"""
198191
with TemporaryDirectory() as tmpdir:
199192
tmpdir = pathlib.Path(tmpdir)

tests/test_raxmlng.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,10 @@ def test_raxmlng_init_fails_non_raxmlng_exe():
4848

4949

5050
def test_get_raxmlng_rfdist_results(raxmlng_rfdistance_log):
51-
num_topos, rel_rfdist, abs_rfdist = get_raxmlng_rfdist_results(
52-
raxmlng_rfdistance_log
53-
)
51+
num_topos, rel_rfdist = get_raxmlng_rfdist_results(raxmlng_rfdistance_log)
5452

5553
assert num_topos == 2
5654
assert rel_rfdist == pytest.approx(1 / 3, abs=0.01)
57-
assert abs_rfdist == pytest.approx(2)
5855

5956

6057
def test_get_raxmlng_rfdist_results_raises_value_error(raxmlng_inference_log):
@@ -78,12 +75,9 @@ def test_infer_parsimony_trees(raxmlng, phylip_msa_file):
7875

7976

8077
def test_get_rfdistance_results(raxmlng, multiple_trees_path):
81-
num_topos, rel_rfdist, abs_rfdist = raxmlng.get_rfdistance_results(
82-
multiple_trees_path
83-
)
78+
num_topos, rel_rfdist = raxmlng.get_rfdistance_results(multiple_trees_path)
8479
assert num_topos == 6
8580
assert rel_rfdist == pytest.approx(0.114, abs=0.01)
86-
assert abs_rfdist == pytest.approx(22.269, abs=0.1)
8781

8882

8983
def test_run_raxmlng_command(raxmlng_command, phylip_msa_file):

0 commit comments

Comments
 (0)