Skip to content
Open
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ line-length = 79

[tool.flake8]
max-line-length = 79
extend-ignore = ["E231", "E221"]
extend-ignore = ["E203", "E231", "E221"]
exclude = [
".github/scripts/license_message.py",
"sentieon_cli/scripts/combine_cnv.py",
Expand Down
84 changes: 46 additions & 38 deletions sentieon_cli/command_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,45 +248,20 @@ def cmd_pyexec_hybrid_select(
threads: int,
slop_size: int = 1000,
) -> Pipeline:
select_cmd = Command(
sys.executable,
str(hybrid_select),
"-v",
str(vcf),
"-t",
str(threads),
"-",
)
view_cmd = Command(
"bcftools",
"view",
"-f",
"PASS,.",
"-",
)
query_cmd = Command(
"bcftools",
"query",
"-f",
"%CHROM\\t%POS0\\t%END\\n",
"-",
)
slop_cmd = Command(
"bedtools",
"slop",
"-b",
str(slop_size),
"-g",
str(ref_fai),
"-i",
"-",
)
return Pipeline(
select_cmd,
view_cmd,
query_cmd,
slop_cmd,
file_output=out_bed,
Command(
sys.executable,
str(hybrid_select),
"-v",
str(vcf),
"-t",
str(threads),
"--reference-fai",
str(ref_fai),
"--slop-size",
str(slop_size),
str(out_bed),
)
)


Expand All @@ -311,6 +286,39 @@ def cmd_pyexec_hybrid_anno(
return Pipeline(Command(*cmd))


def cmd_pyexec_hybrid_transfer(
out_vcf: pathlib.Path,
raw_vcf: pathlib.Path,
population_vcf: pathlib.Path,
reference_fai: pathlib.Path,
temp_dir: pathlib.Path,
hybrid_transfer: pathlib.Path,
threads: int,
workers: int,
) -> Pipeline:
"""Transfer population annotations in one bounded ordered job."""

return Pipeline(
Command(
sys.executable,
str(hybrid_transfer),
"--raw-vcf",
str(raw_vcf),
"--population-vcf",
str(population_vcf),
"--reference-fai",
str(reference_fai),
"--temp-dir",
str(temp_dir),
"--threads",
str(threads),
"--workers",
str(workers),
str(out_vcf),
)
)


def hybrid_stage1(
out_aln: pathlib.Path,
reference: pathlib.Path,
Expand Down
63 changes: 36 additions & 27 deletions sentieon_cli/dnascope_hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
parse_fai,
vcf_contigs,
)
from .transfer import build_transfer_jobs

logger = get_logger(__name__)

Expand All @@ -61,6 +60,9 @@
"ONT": packaging.version.Version("1.2"),
}

HYBRID_TRANSFER_WORKERS = 32
FINAL_NORM_PROCESSES = 3


class RgInfo:
"""A container class for short and long-read readgroups"""
Expand Down Expand Up @@ -651,8 +653,7 @@ def build_dag(self) -> DAG:
concat_job,
rm_job5,
anno_job,
transfer_jobs,
transfer_concat,
transfer_job,
apply_job,
norm_job,
) = self.call_variants(sr_aln, lr_aln, rg_info)
Expand All @@ -670,11 +671,9 @@ def build_dag(self) -> DAG:
dag.add_job(anno_job, {concat_job})

apply_dependencies = {anno_job}
if transfer_jobs and transfer_concat:
for job in transfer_jobs:
dag.add_job(job, {anno_job})
dag.add_job(transfer_concat, set(transfer_jobs))
apply_dependencies = {transfer_concat}
if transfer_job:
dag.add_job(transfer_job, {anno_job})
apply_dependencies = {transfer_job}

if apply_job:
dag.add_job(apply_job, apply_dependencies)
Expand Down Expand Up @@ -715,7 +714,6 @@ def call_variants(
Job,
Job,
Job,
Optional[List[Job]],
Optional[Job],
Optional[Job],
Optional[Job],
Expand Down Expand Up @@ -781,7 +779,7 @@ def call_variants(
threads=self.cores,
),
"hybrid-select",
0,
self.cores,
)

mapq0_bed = self.tmp_dir.joinpath("hybrid_mapq0.bed")
Expand Down Expand Up @@ -1010,11 +1008,10 @@ def call_variants(
self.cores,
),
"anno-calls",
0,
self.cores,
)

transfer_jobs: Optional[List[Job]] = None
transfer_concat_job: Optional[Job] = None
transfer_job: Optional[Job] = None
input_to_apply = anno_target

if self.pop_vcf:
Expand All @@ -1024,15 +1021,29 @@ def call_variants(
if self.skip_model_apply:
transfer_target = self.output_vcf

transfer_jobs, transfer_concat_job = build_transfer_jobs(
transfer_target,
self.pop_vcf,
anno_target,
self.tmp_dir,
self.shards,
self.pop_vcf_contigs,
self.fai_data,
self.dry_run,
hybrid_transfer = pathlib.Path(
str(
files("sentieon_cli.scripts").joinpath(
"hybrid_transfer.py"
)
)
).resolve()
transfer_workers = min(
HYBRID_TRANSFER_WORKERS,
max(1, self.cores - 1),
)
transfer_job = Job(
cmds.cmd_pyexec_hybrid_transfer(
out_vcf=transfer_target,
raw_vcf=anno_target,
population_vcf=self.pop_vcf,
reference_fai=ref_fai,
temp_dir=self.tmp_dir,
hybrid_transfer=hybrid_transfer,
threads=self.cores,
workers=transfer_workers,
),
"population-transfer",
self.cores,
)
input_to_apply = transfer_target
Expand All @@ -1056,8 +1067,7 @@ def call_variants(
concat_job,
rm_job5,
anno_job,
transfer_jobs,
transfer_concat_job,
transfer_job,
None,
None,
)
Expand Down Expand Up @@ -1089,7 +1099,7 @@ def call_variants(
exclude_homref=not self.gvcf,
),
"final-norm",
0,
min(FINAL_NORM_PROCESSES, self.cores),
)
return (
call_job,
Expand All @@ -1109,8 +1119,7 @@ def call_variants(
concat_job,
rm_job5,
anno_job,
transfer_jobs,
transfer_concat_job,
transfer_job,
apply_job,
norm_job,
)
Loading