Skip to content

Commit 66cbdc4

Browse files
fthirion89Florence Thirion
andauthored
Fix tree path list (#50)
Co-authored-by: Florence Thirion <florence.thirion@inra.fr>
1 parent 4ce3a3b commit 66cbdc4

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

meteor/phylogeny.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import sys
1717
from dataclasses import dataclass, field
1818
from meteor.session import Session, Component
19-
from subprocess import check_call, run
19+
from subprocess import check_call, run, DEVNULL
2020
from time import perf_counter
2121
from pathlib import Path
2222
import tempfile
@@ -68,7 +68,7 @@ def clean_sites(
6868
# Count sites with more than the specified maximum gap ratio
6969
info_sites = sum(1 for ratio in info_ratio if ratio <= self.max_gap)
7070
logging.info(
71-
"%d / %d sites with less than %.1f%% gaps",
71+
"%d/%d sites with less than %.1f%% gaps",
7272
info_sites,
7373
len(info_ratio),
7474
self.max_gap * 100,
@@ -139,7 +139,7 @@ def execute(self) -> None:
139139
msp_count = len(self.msp_file_list)
140140
for idx, msp_file in enumerate(self.msp_file_list, start=1):
141141
logging.info(
142-
"Start analysis of MSP %s: %d/%d", msp_file.name, idx, msp_count
142+
"%d/%d %s: Start analysis", idx, msp_count, msp_file.name.replace(".fasta", "")
143143
)
144144
with NamedTemporaryFile(
145145
mode="wt", dir=self.meteor.tmp_dir, suffix=".fasta"
@@ -148,18 +148,17 @@ def execute(self) -> None:
148148
".fasta", ""
149149
)
150150
# Clean sites
151+
logging.info("Clean sites")
151152
cleaned_seqs, info_sites = self.clean_sites(msp_file, temp_clean)
152-
logging.info("Clean sites for MSP %d/%d", idx, msp_count)
153153
if info_sites < self.min_info_sites:
154154
logging.info(
155-
"Only %d informative sites (< %d threshold) left after cleaning for MSP %d/%d",
155+
"Only %d informative sites (< %d threshold) left after cleaning, skip.",
156156
info_sites,
157-
self.min_info_sites,
158-
idx,
159-
msp_count,
157+
self.min_info_sites
160158
)
161159
elif len(cleaned_seqs) >= 4:
162160
# Compute trees
161+
logging.info("Run raxml-ng")
163162
result = check_call(
164163
[
165164
"raxml-ng",
@@ -177,14 +176,14 @@ def execute(self) -> None:
177176
"perf,msa", # not working with raxml-ng-mpi
178177
"--prefix",
179178
str(tree_file.resolve()),
180-
]
179+
],
180+
stdout = DEVNULL
181181
)
182182
if result != 0:
183183
logging.error("raxml-ng failed with return code %d", result)
184184
else:
185185
logging.info(
186-
"MSP %s have less than 4 sequences, distance will be calculated with cogent3",
187-
msp_file.name,
186+
"Less than 4 sequences, run cogent3"
188187
)
189188
aligned_seqs = load_aligned_seqs(
190189
temp_clean.name,
@@ -206,14 +205,15 @@ def execute(self) -> None:
206205
# )
207206
if tree_file.with_suffix(".tree").exists():
208207
self.tree_files.append(tree_file.with_suffix(".tree"))
209-
logging.info("Completed MSP tree %d/%d", idx, msp_count)
210-
elif tree_file.with_suffix(".raxml.bestTree"):
208+
logging.info("Completed MSP tree with cogent3")
209+
elif tree_file.with_suffix(".raxml.bestTree").exists():
211210
self.tree_files.append(tree_file.with_suffix(".raxml.bestTree"))
212-
logging.info("Completed MSP tree %d/%d", idx, msp_count)
211+
logging.info("Completed MSP tree with raxml")
213212
else:
214213
logging.info(
215-
"No tree file generated for MSP %s, skipping", msp_file.name
214+
"No tree file generated"
216215
)
217216
logging.info("Completed phylogeny in %f seconds", perf_counter() - start)
217+
logging.info("Trees were generated for %d/%d MSPs", len(self.tree_files), msp_count)
218218
config = self.set_tree_config(raxml_ng_version)
219219
self.save_config(config, self.meteor.tree_dir / "census_stage_4.json")

0 commit comments

Comments
 (0)