Skip to content

Commit

Permalink
fix annotation and adjust logging level of a few messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rpetit3 committed Apr 30, 2024
1 parent 36e9b13 commit b8a9883
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions bactopia/cli/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,14 @@ def summary(
dfs.append(df)
logging.debug(f"\tRank: {rank} ({reason})")
else:
logging.debug(
logging.info(
f"Skipping {sample['id']} ({sample['path']}) due to missing files. Missing:"
)
for missing_file in parsable_files:
logging.debug(f"\t{missing_file}")
logging.info(f"\t{missing_file}")
increment_and_append("ignore-unknown", sample["id"])
else:
logging.debug(
logging.info(
f"Skipping {sample['id']} ({sample['path']}), incomplete or not a Bactopia directory"
)
increment_and_append("ignore-unknown", sample["id"])
Expand Down
7 changes: 4 additions & 3 deletions bactopia/parsers/annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def _parse_annotation(path: str, name: str) -> dict:
with open(path, "rt") as fh:
for line in fh:
line = line.rstrip()
key, val = line.split(":")
if key in COLS:
results[f"annotator_total_{key}"] = int(val.lstrip())
if ":" in line:
key, val = line.split(":")
if key in COLS:
results[f"annotator_total_{key}"] = int(val.lstrip())
return results
12 changes: 10 additions & 2 deletions bactopia/parsers/parsables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A list of files that can be parsed by Bactopia
"""
import logging
from pathlib import Path

EXCLUDE_COLUMNS = [
Expand All @@ -24,8 +25,6 @@
def get_parsable_files(path: str, name: str) -> list:
parsable_files = {
# main
# annotator
f"{path}/main/annotator/prokka/{name}.txt": "annotator",
# assembler
f"{path}/main/assembler/{name}.tsv": "assembler",
# gather
Expand All @@ -49,14 +48,23 @@ def get_parsable_files(path: str, name: str) -> list:

# Check annotation files seperately, since Prokka or Bakta can be used
if Path(f"{path}/main/annotator/bakta/{name}.txt").exists():
logging.debug(
f"Found Bakta annotation file: {path}/main/annotator/bakta/{name}.txt"
)
parsable_files[f"{path}/main/annotator/bakta/{name}.txt"] = "annotator"
elif Path(f"{path}/main/annotator/prokka/{name}.txt").exists():
logging.debug(
f"Found Prokka annotation file: {path}/main/annotator/prokka/{name}.txt"
)
parsable_files[f"{path}/main/annotator/prokka/{name}.txt"] = "annotator"
else:
is_complete = False
missing_files.append(f"{path}/main/annotator/prokka/{name}.txt")
missing_files.append(f"{path}/main/annotator/bakta/{name}.txt")

logging.debug(f"Missing Files: {missing_files}")
logging.debug(f"Is Complete: {is_complete}")

if is_complete:
parsable_files[f"{path}/main/qc/summary/{name}-original.json"] = "qc"
parsable_files[f"{path}/main/qc/summary/{name}-final.json"] = "qc"
Expand Down

0 comments on commit b8a9883

Please sign in to comment.