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

Hotfix/config file location #162

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions big_scape/cli/cli_common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
validate_classify,
validate_output_dir,
)
from .constants import ROOT_DIR


def common_all(fn):
Expand All @@ -35,9 +36,9 @@ def common_all(fn):
type=click.Path(
exists=True, dir_okay=False, file_okay=True, path_type=Path
),
default="./config.ini",
default=ROOT_DIR / "config.ini",
help="Path to BiG-SCAPE config file, which stores values for a "
"series of advanced use parameters. (default: ./config.ini).",
"series of advanced use parameters. (default: [BiG-SCAPE directory]/config.ini).",
),
# diagnostic parameters
click.option(
Expand Down
8 changes: 7 additions & 1 deletion big_scape/cli/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
"""Contains constant values"""

DB_SCHEMA_PATH = "big_scape/data/schema.sql"
from sys import argv
from pathlib import Path

# TODO: this almost certainly will break when packaging
ROOT_DIR = Path(argv[0]).parent

DB_SCHEMA_PATH = ROOT_DIR / "big_scape/data/schema.sql"

# TODO: add comments with notes as in BS1
# TODO: move to config file
Expand Down
17 changes: 7 additions & 10 deletions big_scape/output/legacy_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from big_scape.enums import SOURCE_TYPE
from big_scape.trees import generate_newick_tree
from big_scape.comparison import get_record_category
from big_scape.cli.constants import ROOT_DIR

import big_scape.network.network as bs_network
import big_scape.network.utility as bs_network_utility
Expand All @@ -34,7 +35,7 @@ def copy_base_output_templates(output_dir: Path):
output_dir (Path): main output directory
"""

template_root = Path("big_scape/output/html_template")
template_root = ROOT_DIR / Path("big_scape/output/html_template")
template_dir = template_root / "output"

# copy html content
Expand Down Expand Up @@ -65,7 +66,7 @@ def prepare_cutoff_folders(output_dir: Path, label: str, cutoff: float) -> None:
cutoff_network_path.mkdir(exist_ok=True)
cutoff_files_path.mkdir(exist_ok=True)

template_root = Path("big_scape/output/html_template")
template_root = ROOT_DIR / Path("big_scape/output/html_template")
overview_template = template_root / "overview_html"

# copy overview html
Expand Down Expand Up @@ -100,7 +101,7 @@ def prepare_pair_generator_folders(

tree_path.mkdir(exist_ok=True)

template_root = Path("big_scape/output/html_template")
template_root = ROOT_DIR / Path("big_scape/output/html_template")
pair_generator_template = template_root / "index_html"

shutil.copy(
Expand All @@ -118,7 +119,7 @@ def generate_pfams_js(output_dir: Path, pfam_info: list[tuple[str, str, str]]) -
"""

# gather color information
pfam_colors_file_path = Path("big_scape/output/domain_colors.tsv")
pfam_colors_file_path = ROOT_DIR / Path("big_scape/output/domain_colors.tsv")

# make accession to color dictionary
pfam_colors_dict = {}
Expand Down Expand Up @@ -224,9 +225,7 @@ def generate_run_data_js(
"classify": (
"Legacy Groups"
if run["legacy_classify"]
else run["classify"].name.title()
if run["classify"]
else "Not Classify"
else run["classify"].name.title() if run["classify"] else "Not Classify"
),
"weights": "Legacy Weights" if run["legacy_weights"] else "Mix",
"alignment_mode": run["alignment_mode"].name.title(),
Expand Down Expand Up @@ -1699,9 +1698,7 @@ def write_full_network_file(run: dict, all_bgc_records: list[BGCRecord]) -> None
write_network_file(full_network_file_path, edgelist)


def get_full_network_edgelist(
run: dict, all_bgc_records: list
) -> set[
def get_full_network_edgelist(run: dict, all_bgc_records: list) -> set[
tuple[
str,
str,
Expand Down
Loading