Skip to content

Commit

Permalink
Debug missing trees
Browse files Browse the repository at this point in the history
  • Loading branch information
aghozlane committed Jun 27, 2024
1 parent a09c819 commit 0cf19e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions meteor/phylogeny.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import re
import logging
import sys
from dataclasses import dataclass
from dataclasses import dataclass, field
from meteor.session import Session, Component
from subprocess import check_call, run
from time import perf_counter
Expand All @@ -39,6 +39,7 @@ class Phylogeny(Session):
msp_file_list: list[Path]
max_gap: float
min_info_sites: int
tree_files: list[Path] = field(default_factory=list)

def compute_site_info(self, sequences: Iterable[str]) -> list[float]:
"""Calculate the percentage of "_" at each position
Expand Down Expand Up @@ -83,9 +84,7 @@ def clean_sites(
print(flush=True, file=output)
return resultdict, info_sites

def set_tree_config(
self, raxml_ng_version: str, tree_files: list[Path]
) -> dict: # pragma: no cover
def set_tree_config(self, raxml_ng_version: str) -> dict: # pragma: no cover
"""Define the census configuration
:param cmd: A string of the specific parameters
Expand All @@ -98,7 +97,7 @@ def set_tree_config(
"phylogeny_tool": "raxml-ng",
"phylogeny_version": raxml_ng_version,
"phylogeny_date": datetime.now().strftime("%Y-%m-%d"),
"tree_files": ",".join([tree.name for tree in tree_files]),
"tree_files": ",".join([tree.name for tree in self.tree_files]),
},
}
return config
Expand Down Expand Up @@ -136,7 +135,7 @@ def execute(self) -> None:

# Start phylogenies
start = perf_counter()
tree_files: list[Path] = []
self.tree_files: list[Path] = []
msp_count = len(self.msp_file_list)
for idx, msp_file in enumerate(self.msp_file_list, start=1):
logging.info(
Expand Down Expand Up @@ -208,12 +207,12 @@ def execute(self) -> None:
if tree_file.with_suffix(".tree").exists() or tree_file.with_suffix(
".raxml.bestTree"
):
tree_files.append(tree_file)
self.tree_files.append(tree_file)
logging.info("Completed MSP tree %d/%d", idx, msp_count)
else:
logging.info(
"No tree file generated for MSP %s, skipping", msp_file.name
)
logging.info("Completed phylogeny in %f seconds", perf_counter() - start)
config = self.set_tree_config(raxml_ng_version, tree_files)
config = self.set_tree_config(raxml_ng_version)
self.save_config(config, self.meteor.tree_dir / "census_stage_4.json")
2 changes: 1 addition & 1 deletion meteor/treebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def execute(self) -> None:
)
phylogeny_process.execute()
# Analyze tree data
for msp_file in msp_file_list:
for msp_file in phylogeny_process.tree_files:
# Check for a .raxml.bestTree file
raxml_tree_file = self.meteor.tree_dir / f"{msp_file.stem}.raxml.bestTree"
if raxml_tree_file.exists():
Expand Down

0 comments on commit 0cf19e9

Please sign in to comment.