Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RE2022-261: add fatal error file for checkm2 #537

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/loaders/compute_tools/checkm2/checkm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
from pathlib import Path
MrCreosote marked this conversation as resolved.
Show resolved Hide resolved
from typing import Dict

from src.common.storage.field_names import FLD_KBASE_ID
from src.loaders.compute_tools.tool_common import (
GenomeTuple,
ToolRunner,
run_command,
write_fatal_tuples_to_dict,
create_fatal_tuple,
)
from src.loaders.compute_tools.tool_result_parser import (
process_genome_attri_result,
Expand Down Expand Up @@ -47,12 +50,23 @@ def _run_checkm2(
)

tool_file_name, genome_id_col = 'quality_report.tsv', 'Name'
process_genome_attri_result(output_dir,
SELECTED_CHECKM2_FEATURES,
genome_id_col,
ids_to_files,
[tool_file_name],
)
genome_attri_docs = process_genome_attri_result(output_dir,
SELECTED_CHECKM2_FEATURES,
genome_id_col,
ids_to_files,
[tool_file_name],
)

# create fatal error file if any genome is missing from the result file
fatal_tuples = []
error_message = f"The genome is absent in the quality_report.tsv file generated by CheckM2."
success_ids = [genome_attri_doc[FLD_KBASE_ID] for genome_attri_doc in genome_attri_docs]
MrCreosote marked this conversation as resolved.
Show resolved Hide resolved
missing_ids = set(ids_to_files.keys()) - set(success_ids)
print(f"Found {len(missing_ids)} genomes missing from the CheckM2 output file.")
for missing_id in missing_ids:
fatal_tuple = create_fatal_tuple(missing_id, ids_to_files, error_message)
fatal_tuples.append(fatal_tuple)
write_fatal_tuples_to_dict(fatal_tuples, output_dir)


def main():
Expand Down
5 changes: 5 additions & 0 deletions src/loaders/compute_tools/checkm2/versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ versions:
date: 2023-10-24
notes: |
- update diamond reference DB default path
reference_db_version: 1.0.1
- version: 0.1.3
date: 2023-11-08
notes: |
- create fatal error file for CheckM2
reference_db_version: 1.0.1
4 changes: 3 additions & 1 deletion src/loaders/compute_tools/tool_result_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
result_files: List[str],
check_file_exists: bool = True,
prefix: str = ''
) -> None:
) -> List[Dict]:
"""
process the output files generated by the tool (checkm2, gtdb-tk, etc) to create a format suitable for
importing into ArangoDB
Expand Down Expand Up @@ -57,6 +57,8 @@
output = output_dir / TOOL_GENOME_ATTRI_FILE
create_jsonl_files(output, genome_attri_docs)

return genome_attri_docs

Check warning on line 60 in src/loaders/compute_tools/tool_result_parser.py

View check run for this annotation

Codecov / codecov/patch

src/loaders/compute_tools/tool_result_parser.py#L60

Added line #L60 was not covered by tests


def create_jsonl_files(
file_path: Path,
Expand Down
Loading