Skip to content

Commit

Permalink
Merge pull request #73 from GavinHuttley/main
Browse files Browse the repository at this point in the history
Fix newick output
  • Loading branch information
GavinHuttley authored Nov 7, 2024
2 parents e72811d + 1c9671e commit 07e3f2d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/diverse_seq/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ def ctree(
hide_progress: bool,
):
"""Quickly compute a cluster tree based on kmers for a collection of sequences."""

if seqfile.suffix != ".dvseqs":
dvs_util.print_colour(
"Sequence data needs to be preprocessed, use 'dvs prep'",
Expand Down Expand Up @@ -492,7 +491,6 @@ def ctree(
seqs[name] = arr2str_app(record.read()) # pylint: disable=not-callable

seqs = make_unaligned_seqs(seqs, moltype=moltype)

app = dvs_cluster.dvs_par_ctree(
k=k,
sketch_size=sketch_size,
Expand All @@ -504,6 +502,9 @@ def ctree(
show_progress=not hide_progress,
)
tree = app(seqs) # pylint: disable=not-callable
if not tree:
dvs_util.print_colour(tree, "red")
sys.exit(1)
tree.write(outpath)


Expand Down
8 changes: 3 additions & 5 deletions src/diverse_seq/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,10 @@ def make_cluster_tree(
tree_dict.pop(right_index),
)
node_index += 1

tree = make_tree(str(tree_dict[node_index - 1]))

# use string representation and then remove quotes
treestring = str(tree_dict[node_index - 1]).replace("'", "")
tree = make_tree(treestring=treestring, underscore_unmunge=True)
progress.update(tree_task, completed=1, total=1)

return tree


Expand Down Expand Up @@ -297,7 +296,6 @@ def __init__(
mash_canonical_kmers=mash_canonical_kmers,
show_progress=show_progress,
)

if parallel:
if max_workers is None:
max_workers = multiprocessing.cpu_count()
Expand Down
1 change: 0 additions & 1 deletion src/diverse_seq/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def mash_distances(
numpy.ndarray
Pairwise mash distances between sequences.
"""

if progress is None:
progress = Progress(disable=True)

Expand Down
4 changes: 1 addition & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ def test_ctree(
):
outpath = tmp_dir / "out.tre"

args = (
f"-s {processed_seq_path} -o {outpath} -d {distance} -k {k} -np {max_workers}"
)
args = f"-s {processed_seq_path} -o {outpath} -d {distance} -k {k} -np {max_workers} -hp"
if sketch_size is not None:
args += f" --sketch-size {sketch_size}"
args = args.split()
Expand Down

0 comments on commit 07e3f2d

Please sign in to comment.