Skip to content
Merged
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
6 changes: 5 additions & 1 deletion sentieon_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .dnascope import DNAscopePipeline
from .dnascope_hybrid import DNAscopeHybridPipeline
from .dnascope_longread import DNAscopeLRPipeline
from .job import Job
from .sentieon_pangenome import SentieonPangenome
from .util import __version__

Expand All @@ -16,7 +17,7 @@ def main():
action="store_const",
dest="loglevel",
const="INFO",
default="WARNING",
default="INFO",
)
parser.add_argument(
"-d",
Expand Down Expand Up @@ -59,6 +60,9 @@ def main():
dnascope_pangenome_subparser.set_defaults(pipeline=pipeline.main)

args = parser.parse_args()
# Job ids must be unique for the whole run, which may execute more than
# one DAG, so numbering restarts here rather than per DAG.
Job.reset_ids()
args.pipeline(args)


Expand Down
2 changes: 2 additions & 0 deletions sentieon_cli/base_pangenome.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def build_kmc_job(
),
"kmc",
job_threads,
task_name="kmer-counting",
)

return kmc_job
Expand All @@ -150,6 +151,7 @@ def build_ploidy_job(
),
"estimate-ploidy",
0,
task_name="ploidy",
)
return ploidy_job

Expand Down
50 changes: 42 additions & 8 deletions sentieon_cli/dnascope.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ def sr_align_inputs(self) -> Tuple[List[pathlib.Path], Set[Job], Job]:
),
f"bam-align-{i}",
self.cores,
task_name="alignment",
)
res.append(out_aln)
jobs.add(job)
Expand All @@ -532,6 +533,7 @@ def sr_align_inputs(self) -> Tuple[List[pathlib.Path], Set[Job], Job]:
),
"rm-bam-aln",
0,
task_name="cleanup",
)

return (res, jobs, rm_job)
Expand Down Expand Up @@ -613,6 +615,7 @@ def sr_align_fastq(
f"bam-align-{i}-{j}",
split_cores,
resources={f"node{j}": 1},
task_name="alignment",
)
res.append(out_aln)
jobs.add(job)
Expand All @@ -628,6 +631,7 @@ def sr_align_fastq(
),
"rm-fq-aln",
0,
task_name="cleanup",
)

return (res, jobs, rm_job)
Expand Down Expand Up @@ -716,6 +720,7 @@ def dedup_and_metrics(
Pipeline(Command(*driver.build_cmd())),
"locuscollector",
self.cores,
task_name="dedup",
)

if self.sr_duplicate_marking == "none":
Expand Down Expand Up @@ -743,7 +748,10 @@ def dedup_and_metrics(
)
)
dedup_job = Job(
Pipeline(Command(*driver.build_cmd())), "dedup", self.cores
Pipeline(Command(*driver.build_cmd())),
"dedup",
self.cores,
task_name="dedup",
)

if self.skip_metrics:
Expand All @@ -767,7 +775,10 @@ def dedup_and_metrics(
driver.add_algo(HsMetricAlgo(hs_metrics, self.bed, self.bed))
driver.add_algo(InsertSizeMetricAlgo(is_metrics))
metrics_job = Job(
Pipeline(Command(*driver.build_cmd())), "metrics", 0
Pipeline(Command(*driver.build_cmd())),
"metrics",
0,
task_name="metrics",
) # Run metrics in the background

# Run WgsMetricsAlgo after duplicate marking to account for
Expand All @@ -779,7 +790,10 @@ def dedup_and_metrics(
)
driver.add_algo(CoverageMetrics(coverage_metrics))
metrics_job = Job(
Pipeline(Command(*driver.build_cmd())), "metrics", 0
Pipeline(Command(*driver.build_cmd())),
"metrics",
0,
task_name="metrics",
) # Run metrics in the background

# Rehead WGS metrics so they are recognized by MultiQC
Expand All @@ -801,6 +815,7 @@ def dedup_and_metrics(
),
"Rehead metrics",
0,
task_name="metrics",
)
return ([deduped], lc_job, dedup_job, metrics_job, rehead_job)

Expand Down Expand Up @@ -874,6 +889,7 @@ def sr_call_variants(
Pipeline(Command(*driver.build_cmd())),
"variant-calling",
self.cores,
task_name="variant-calling",
)

# Genotyping and filtering with DNAModelApply
Expand All @@ -889,12 +905,20 @@ def sr_call_variants(
)
)
apply_job = Job(
Pipeline(Command(*driver.build_cmd())), "model-apply", self.cores
Pipeline(Command(*driver.build_cmd())),
"model-apply",
self.cores,
task_name="model-apply",
)

# Remove the tmp_vcf
rm_cmd = ["rm", str(tmp_vcf), str(tmp_vcf) + ".tbi"]
rm_job = Job(Pipeline(Command(*rm_cmd, fail_ok=True)), "rm-tmp-vcf", 0)
rm_job = Job(
Pipeline(Command(*rm_cmd, fail_ok=True)),
"rm-tmp-vcf",
0,
task_name="cleanup",
)

# Genotype gVCFs
gvcftyper_job = None
Expand All @@ -911,7 +935,10 @@ def sr_call_variants(
)
)
gvcftyper_job = Job(
Pipeline(Command(*driver.build_cmd())), "gvcftyper", self.cores
Pipeline(Command(*driver.build_cmd())),
"gvcftyper",
self.cores,
task_name="gvcftyper",
)

# Call SVs
Expand All @@ -930,7 +957,9 @@ def sr_call_variants(
)
)
svsolver_job = Job(
Pipeline(Command(*driver.build_cmd())), "svsolver"
Pipeline(Command(*driver.build_cmd())),
"svsolver",
task_name="sv-calling",
)
sv_rm_job = Job(
Pipeline(
Expand All @@ -943,6 +972,7 @@ def sr_call_variants(
),
"rm-tmp-sv",
0,
task_name="cleanup",
)

return (
Expand Down Expand Up @@ -991,7 +1021,10 @@ def call_cnvs(
)
)
cnvscope_job = Job(
Pipeline(Command(*driver.build_cmd())), "CNVscope", cores
Pipeline(Command(*driver.build_cmd())),
"CNVscope",
cores,
task_name="cnv",
)

driver = Driver(
Expand All @@ -1009,6 +1042,7 @@ def call_cnvs(
Pipeline(Command(*driver.build_cmd())),
"CNVModelApply",
cores,
task_name="cnv",
)

return (cnvscope_job, cnvmodelapply_job)
61 changes: 53 additions & 8 deletions sentieon_cli/dnascope_hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,10 @@ def call_variants(
)
)
call_job = Job(
Pipeline(Command(*driver.build_cmd())), "calling-1", self.cores
Pipeline(Command(*driver.build_cmd())),
"calling-1",
self.cores,
task_name="variant-calling",
)

# Region selection
Expand All @@ -782,6 +785,7 @@ def call_variants(
),
"hybrid-select",
0,
task_name="region-selection",
)

mapq0_bed = self.tmp_dir.joinpath("hybrid_mapq0.bed")
Expand All @@ -802,6 +806,7 @@ def call_variants(
Pipeline(Command(*driver.build_cmd())),
"mapq0-bed",
self.cores,
task_name="region-selection",
)

mapq0_slop_bed = self.tmp_dir.joinpath("hybrid_mapq0.ex1000.bed")
Expand All @@ -814,6 +819,7 @@ def call_variants(
),
"mapq0-bed-slop",
0,
task_name="region-selection",
)

diff_bed = self.tmp_dir.joinpath("merged_diff.bed")
Expand All @@ -825,9 +831,15 @@ def call_variants(
),
"concat-merge-bed",
0,
task_name="region-selection",
)
rm_cmd = ["rm", str(selected_bed), str(mapq0_slop_bed)]
rm_job1 = Job(Pipeline(Command(*rm_cmd, fail_ok=True)), "rm-tmp1", 0)
rm_job1 = Job(
Pipeline(Command(*rm_cmd, fail_ok=True)),
"rm-tmp1",
0,
task_name="cleanup",
)

stage1_ins_fa = self.tmp_dir.joinpath("stage1_ins.fa")
stage1_ins_bed = self.tmp_dir.joinpath("stage1_ins.bed")
Expand Down Expand Up @@ -881,14 +893,20 @@ def call_variants(
),
"first-stage",
self.cores,
task_name="hybrid-realignment",
)
rm_cmd = [
"rm",
str(stage1_ins_fa),
str(stage1_ins_bed),
str(stage1_hap_vcf),
]
rm_job2 = Job(Pipeline(Command(*rm_cmd, fail_ok=True)), "rm-tmp2", 0)
rm_job2 = Job(
Pipeline(Command(*rm_cmd, fail_ok=True)),
"rm-tmp2",
0,
task_name="cleanup",
)

stage2_bed = self.tmp_dir.joinpath("hybrid_stage2.bed")
stage2_unmap_bam = self.tmp_dir.joinpath("hybrid_stage2_unmap.bam")
Expand All @@ -911,10 +929,16 @@ def call_variants(
Pipeline(Command(*driver.build_cmd())),
"second-stage",
self.cores,
task_name="hybrid-realignment",
)

rm_cmd = ["rm", str(stage1_bam), str(stage1_hap_bam)]
rm_job3 = Job(Pipeline(Command(*rm_cmd, fail_ok=True)), "rm-tmp3", 0)
rm_job3 = Job(
Pipeline(Command(*rm_cmd, fail_ok=True)),
"rm-tmp3",
0,
task_name="cleanup",
)

suffix = "bam" if self.bam_format else "cram"
stage3_aln = pathlib.Path(
Expand Down Expand Up @@ -943,9 +967,15 @@ def call_variants(
),
"third-stage",
self.cores,
task_name="hybrid-realignment",
)
rm_cmd = ["rm", str(stage2_unmap_bam), str(stage2_alt_bam)]
rm_job4 = Job(Pipeline(Command(*rm_cmd, fail_ok=True)), "rm-tmp4", 0)
rm_job4 = Job(
Pipeline(Command(*rm_cmd, fail_ok=True)),
"rm-tmp4",
0,
task_name="cleanup",
)

# pass 2 of variant calling
pass2_vcf = self.tmp_dir.joinpath("hybrid_pass2.vcf.gz")
Expand All @@ -967,7 +997,10 @@ def call_variants(
)
)
call2_job = Job(
Pipeline(Command(*driver.build_cmd())), "call2", self.cores
Pipeline(Command(*driver.build_cmd())),
"call2",
self.cores,
task_name="variant-calling",
)

# Merge and normalize the VCFs
Expand All @@ -981,6 +1014,7 @@ def call_variants(
),
"subset-calls",
0,
task_name="vcf-merge",
)
concat_job = Job(
cmds.bcftools_concat(
Expand All @@ -989,9 +1023,15 @@ def call_variants(
),
"concat-calls",
0,
task_name="vcf-merge",
)
rm_cmd = ["rm", str(combined_vcf), str(subset_vcf), str(pass2_vcf)]
rm_job5 = Job(Pipeline(Command(*rm_cmd, fail_ok=True)), "rm-tmp5", 0)
rm_job5 = Job(
Pipeline(Command(*rm_cmd, fail_ok=True)),
"rm-tmp5",
0,
task_name="cleanup",
)

# Annotate the output VCF
hybrid_anno = pathlib.Path(
Expand All @@ -1011,6 +1051,7 @@ def call_variants(
),
"anno-calls",
0,
task_name="annotation",
)

transfer_jobs: Optional[List[Job]] = None
Expand Down Expand Up @@ -1077,7 +1118,10 @@ def call_variants(
)
)
apply_job = Job(
Pipeline(Command(*driver.build_cmd())), "model-apply", self.cores
Pipeline(Command(*driver.build_cmd())),
"model-apply",
self.cores,
task_name="model-apply",
)

# Final normalize
Expand All @@ -1090,6 +1134,7 @@ def call_variants(
),
"final-norm",
0,
task_name="vcf-norm",
)
return (
call_job,
Expand Down
Loading
Loading