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

Print a warning log when partition step fails #269

Merged
merged 2 commits into from
Aug 22, 2024
Merged
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
29 changes: 12 additions & 17 deletions ppanggolin/nem/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,26 +166,14 @@ def run_partitioning(nem_dir_path: Path, nb_org: int, beta: float = 2.5, free_di
else:
partitions_list[i] = parti[positions_max_prob.pop()]
except OSError:
logging.getLogger("PPanGGOLiN").debug(
"partitioning did not work (the number of genomes used is probably too low), "
"see logs here to obtain more details " + nem_dir_path.as_posix() + "/nem_file_" +
str(kval) + ".log")
logging.getLogger("PPanGGOLiN").warning("Partitioning did not work (the number of genomes used is probably too low), "
f"see logs here to obtain more details {nem_dir_path.as_posix()}")
return {}, None, None # return empty objects

except ValueError:
# return the default partitions_list which correspond to undefined
pass

if not keep_files and no_nem is False:
os.remove(nem_dir_path / f"nem_file_{str(kval)}.uf")
os.remove(nem_dir_path / f"nem_file_{str(kval)}.mf")
os.remove(nem_dir_path / f"nem_file_{str(kval)}.log")
os.remove(nem_dir_path / f"nem_file_{str(kval)}.stderr")
os.remove(nem_dir_path / f"nem_file_init_{str(kval)}.m")
os.remove(nem_dir_path / "nem_file.index")
os.remove(nem_dir_path / "nem_file.dat")
os.remove(nem_dir_path / "nem_file.nei")
os.remove(nem_dir_path / "nem_file.str")

if just_log_likelihood:
return kval, log_likelihood, entropy
else:
Expand Down Expand Up @@ -469,8 +457,15 @@ def partition(pangenome: Pangenome, output: Path = None, beta: float = 2.5, sm_d
check_pangenome_former_partition(pangenome, force)
check_pangenome_info(pangenome, need_annotations=True, need_families=True, need_graph=True, disable_bar=disable_bar)
organisms = set(pangenome.organisms)
tmp_dir = tempfile.TemporaryDirectory(dir=tmpdir)
tmp_path = Path(tmp_dir.name)

if keep_tmp_files:
# Create a temporary directory without auto-cleanup
tmp_dir = tempfile.mkdtemp(dir=tmpdir)
tmp_path = Path(tmp_dir)
else:
# Create a temporary directory with auto-cleanup
tmp_dir = tempfile.TemporaryDirectory(dir=tmpdir)
tmp_path = Path(tmp_dir.name)

if len(organisms) <= 10:
logging.getLogger("PPanGGOLiN").warning(f"The number of selected genomes is too low ({len(organisms)} "
Expand Down