Skip to content

Commit

Permalink
add no tree generation flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nlouwen committed Oct 23, 2024
1 parent 1210a0a commit 57d74fb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
14 changes: 11 additions & 3 deletions big_scape/cli/cli_common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,20 @@ def common_all(fn):
"runs with limited memory.",
),
click.option(
"--no-interactive",
"--no-output",
type=bool,
is_flag=True,
default=False,
help="Do not generate an interactive visualization. This speeds up runs, and "
"for runs with a large amount of BGCs, the interactive visualization can fail to load.",
help="Do not generate any output besides the data stored in the database. "
"Suitable for advanced users that work with the SQL database directly.",
),
click.option(
"--no-trees",
type=bool,
is_flag=True,
default=False,
help="Do not generate any GCF newick trees. Suitable for users that do not "
"utilize our output visualization, but work with output tsv files directly.",
),
click.option(
"--force-gbk",
Expand Down
22 changes: 16 additions & 6 deletions big_scape/output/legacy_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# from python
from itertools import repeat
import json
import logging
from multiprocessing import Pool
from distutils import dir_util
from pathlib import Path
Expand Down Expand Up @@ -162,7 +163,8 @@ def legacy_prepare_output(

click_context = click.get_current_context(silent=True)

if click_context and click_context.obj["no_interactive"]:
if click_context and click_context.obj["no_output"]:
logging.info("Skipping all output generation")
return

copy_base_output_templates(output_dir)
Expand All @@ -187,7 +189,7 @@ def legacy_prepare_cutoff_output(run: dict, cutoff: float, gbks: list[GBK]) -> N

click_context = click.get_current_context(silent=True)

if click_context and click_context.obj["no_interactive"]:
if click_context and click_context.obj["no_output"]:
return

output_dir: Path = run["output_dir"]
Expand All @@ -213,7 +215,7 @@ def legacy_prepare_bin_output(

click_context = click.get_current_context(silent=True)

if click_context and click_context.obj["no_interactive"]:
if click_context and click_context.obj["no_output"]:
return

output_dir: Path = run["output_dir"]
Expand All @@ -225,6 +227,9 @@ def legacy_prepare_bin_output(
pair_generator_files_path = cutoff_files_path / pair_generator.label
pair_generator_files_path.mkdir(exist_ok=True)

if click_context and click_context.obj["no_trees"]:
return

tree_path = pair_generator_files_path / Path("GCF_trees")
tree_path.mkdir(exist_ok=True)

Expand All @@ -247,14 +252,19 @@ def legacy_generate_bin_output(

click_context = click.get_current_context(silent=True)

if click_context and click_context.obj["no_interactive"]:
if click_context and click_context.obj["no_output"]:
return

families_members = generate_bs_families_members(
cutoff, pair_generator, run["run_id"]
)
write_clustering_file(run, cutoff, pair_generator)
write_cutoff_network_file(run, cutoff, pair_generator)

if click_context and click_context.obj["no_trees"]:
logging.info("Skipping GCF alignments and trees generation")
return

generate_newick_trees(run, cutoff, pair_generator, families_members)


Expand Down Expand Up @@ -322,7 +332,7 @@ def write_record_annotations_file(run, cutoff, all_bgc_records) -> None:

click_context = click.get_current_context(silent=True)

if click_context and click_context.obj["no_interactive"]:
if click_context and click_context.obj["no_output"]:
return

run_id = run["run_id"]
Expand Down Expand Up @@ -527,7 +537,7 @@ def write_full_network_file(run: dict, all_bgc_records: list[BGCRecord]) -> None

click_context = click.get_current_context(silent=True)

if click_context and click_context.obj["no_interactive"]:
if click_context and click_context.obj["no_output"]:
return

output_dir = run["output_dir"]
Expand Down

0 comments on commit 57d74fb

Please sign in to comment.