Skip to content

Commit

Permalink
Validate arguments to ReclusteringOptions
Browse files Browse the repository at this point in the history
This allows Vamb to fail early if passed paths to files that do not exist.
  • Loading branch information
jakobnissen committed Nov 9, 2023
1 parent 9d044c9 commit a235e49
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions vamb/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,18 @@ def __init__(
clusters_path: Path,
hmmout_path: Path,
binsplit_separator: Optional[str],
algorithm: Optional[str],
algorithm: str,
):
assert isinstance(latent_path, Path)
assert isinstance(clusters_path, Path)
assert isinstance(hmmout_path, Path)

for path in [latent_path, clusters_path, hmmout_path]:
if not path.is_file():
raise FileNotFoundError(path)

if algorithm not in ("kmeans", "dbscan"):
raise ValueError("Algortihm must be 'kmeans' or 'dbscan'")

self.latent_path = latent_path
self.clusters_path = clusters_path
Expand Down Expand Up @@ -1706,7 +1714,6 @@ def run_inner(self, logfile: Optional[IO[str]]):
class ReclusteringArguments(BasicArguments):
def __init__(self, args):
super(ReclusteringArguments, self).__init__(args)
assert args.algorithm in ("kmeans", "dbscan")
self.reclustering_options = ReclusteringOptions(
latent_path=args.latent_path,
clusters_path=args.clusters_path,
Expand Down

0 comments on commit a235e49

Please sign in to comment.