Skip to content

Commit

Permalink
add Sentieon arg
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasbio committed Jul 2, 2024
1 parent 6f48313 commit 7a92486
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 29 deletions.
4 changes: 4 additions & 0 deletions BALSAMIC/commands/config/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
OPTION_PANEL_BED,
OPTION_PON_CNN,
OPTION_QUALITY_TRIM,
OPTION_SENTIEON_INSTALL_DIR,
OPTION_SWEGEN_SNV,
OPTION_SWEGEN_SV,
OPTION_TUMOR_SAMPLE_NAME,
Expand Down Expand Up @@ -84,6 +85,7 @@
@OPTION_PANEL_BED
@OPTION_PON_CNN
@OPTION_QUALITY_TRIM
@OPTION_SENTIEON_INSTALL_DIR
@OPTION_SWEGEN_SNV
@OPTION_SWEGEN_SV
@OPTION_TUMOR_SAMPLE_NAME
Expand Down Expand Up @@ -117,6 +119,7 @@ def case_config(
panel_bed: Path,
pon_cnn: Path,
quality_trim: bool,
sentieon_install_dir: Path,
swegen_snv: Path,
swegen_sv: Path,
tumor_sample_name: str,
Expand Down Expand Up @@ -188,6 +191,7 @@ def case_config(
directory.mkdir(exist_ok=True)

config_collection_dict = ConfigModel(
sentieon_install_dir=sentieon_install_dir.as_posix(),
QC={
"quality_trim": quality_trim,
"adapter_trim": adapter_trim,
Expand Down
7 changes: 7 additions & 0 deletions BALSAMIC/commands/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@
help="Sample configuration file",
)

OPTION_SENTIEON_INSTALL_DIR = click.option(
"--sentieon-install-dir",
type=click.Path(exists=True, resolve_path=True),
required=False,
help="Path to Sentieon install directory",
)

OPTION_SHOW_ONLY_MISSING_FILES = click.option(
"-m",
"--show-only-missing",
Expand Down
1 change: 1 addition & 0 deletions BALSAMIC/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class ConfigModel(BaseModel):
background_variants: Optional[str] = None
analysis: AnalysisModel
custom_filters: CustomFilters | None = None
sentieon_install_dir: Annotated[Optional[str], AfterValidator(is_dir)]

@field_validator("reference")
def abspath_as_str(cls, reference: Dict[str, Path]):
Expand Down
73 changes: 44 additions & 29 deletions BALSAMIC/workflows/balsamic.smk
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,50 @@ params = BalsamicWorkflowConfig.model_validate(WORKFLOW_PARAMS)
if config_model.custom_filters and config_model.custom_filters.umi_min_reads:
params.umiconsensuscall.filter_minreads = config_model.custom_filters.umi_min_reads

# Set Sentieon license
try:
config["SENTIEON_LICENSE"] = os.environ["SENTIEON_LICENSE"]
except KeyError as error:
LOG.error(
"Set environment variable SENTIEON_LICENSE to a valid Sentieon license"
)
raise BalsamicError

# Set Sentieon binary from Sentieon path argument
sentieon_install_dir: str = config_model.sentieon_install_dir
if sentieon_install_dir:
config["SENTIEON_INSTALL_DIR"] = Path(sentieon_install_dir).as_posix()
config["SENTIEON_EXEC"] = Path(sentieon_install_dir, "bin", "sentieon").as_posix()
else:
# Find and set Sentieon binary and license server from env variables
try:
config["SENTIEON_INSTALL_DIR"] = os.environ["SENTIEON_INSTALL_DIR"]

if os.getenv("SENTIEON_EXEC") is not None:
config["SENTIEON_EXEC"] = os.environ["SENTIEON_EXEC"]
else:
config["SENTIEON_EXEC"] = Path(
os.environ["SENTIEON_INSTALL_DIR"], "bin", "sentieon"
).as_posix()

except KeyError as error:
LOG.error(
"Set environment variables SENTIEON_INSTALL_DIR and optionally SENTIEON_EXEC"
)
raise BalsamicError

config["SENTIEON_TNSCOPE"] = SENTIEON_TNSCOPE_DIR.as_posix()
config["SENTIEON_DNASCOPE"] = SENTIEON_DNASCOPE_DIR.as_posix()


if not Path(config["SENTIEON_EXEC"]).exists():
LOG.error(
"Sentieon executable not found {}".format(
Path(config["SENTIEON_EXEC"]).as_posix()
)
)
raise BalsamicError

# vcfanno annotations
research_annotations.append(
{
Expand Down Expand Up @@ -293,35 +337,6 @@ if config["analysis"]["sequencing_type"] != "wgs":
if len(cluster_config.keys()) == 0:
cluster_config = config

# Find and set Sentieon binary and license server from env variables
try:
config["SENTIEON_LICENSE"] = os.environ["SENTIEON_LICENSE"]
config["SENTIEON_INSTALL_DIR"] = os.environ["SENTIEON_INSTALL_DIR"]

if os.getenv("SENTIEON_EXEC") is not None:
config["SENTIEON_EXEC"] = os.environ["SENTIEON_EXEC"]
else:
config["SENTIEON_EXEC"] = Path(
os.environ["SENTIEON_INSTALL_DIR"], "bin", "sentieon"
).as_posix()

config["SENTIEON_TNSCOPE"] = SENTIEON_TNSCOPE_DIR.as_posix()
config["SENTIEON_DNASCOPE"] = SENTIEON_DNASCOPE_DIR.as_posix()

except KeyError as error:
LOG.error(
"Set environment variables SENTIEON_LICENSE, SENTIEON_INSTALL_DIR, SENTIEON_EXEC "
"to run SENTIEON variant callers"
)
raise BalsamicError

if not Path(config["SENTIEON_EXEC"]).exists():
LOG.error(
"Sentieon executable not found {}".format(
Path(config["SENTIEON_EXEC"]).as_posix()
)
)
raise BalsamicError

if "hg38" in config["reference"]["reference_genome"]:
config["reference"]["genome_version"] = "hg38"
Expand Down

0 comments on commit 7a92486

Please sign in to comment.