Skip to content

Commit

Permalink
CWL: support for delly during SV runs
Browse files Browse the repository at this point in the history
Generalizes retrieval of sample name and BAM files to support CWL-based runs.
  • Loading branch information
chapmanb committed Jul 11, 2018
1 parent d8a6644 commit a4c5f46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions bcbio/structural/delly.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from bcbio.structural import shared as sshared
from bcbio.variation import vcfutils

def _get_full_exclude_file(items, work_dir):
base_file = os.path.join(work_dir, "%s-svs" % (os.path.splitext(os.path.basename(items[0]["work_bam"]))[0]))
def _get_full_exclude_file(items, work_bams, work_dir):
base_file = os.path.join(work_dir, "%s-svs" % (os.path.splitext(os.path.basename(work_bams[0]))[0]))
return sshared.prepare_exclude_file(items, base_file)

def _delly_exclude_file(items, base_file, chrom):
Expand Down Expand Up @@ -149,7 +149,7 @@ def run(items):
high quality reference pairs (DR).
"""
work_dir = utils.safe_makedir(os.path.join(items[0]["dirs"]["work"], "structural",
items[0]["name"][-1], "delly"))
dd.get_sample_name(items[0]), "delly"))
# Add core request for delly
config = copy.deepcopy(items[0]["config"])
delly_config = utils.get_in(config, ("resources", "delly"), {})
Expand All @@ -159,7 +159,7 @@ def run(items):
"progs": ["delly"]}
work_bams = [dd.get_align_bam(d) for d in items]
ref_file = dd.get_ref_file(items[0])
exclude_file = _get_full_exclude_file(items, work_dir)
exclude_file = _get_full_exclude_file(items, work_bams, work_dir)
bytype_vcfs = run_multicore(_run_delly,
[(work_bams, chrom, ref_file, work_dir, items)
for chrom in sshared.get_sv_chroms(items, exclude_file)],
Expand Down
2 changes: 1 addition & 1 deletion bcbio/structural/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def get_sv_chroms(items, exclude_file):
if int(region.start) == 0:
exclude_regions[region.chrom] = int(region.end)
out = []
with pysam.Samfile(items[0]["work_bam"], "rb") as pysam_work_bam:
with pysam.Samfile(dd.get_align_bam(items[0]) or dd.get_work_bam(items[0]))as pysam_work_bam:
for chrom, length in zip(pysam_work_bam.references, pysam_work_bam.lengths):
exclude_length = exclude_regions.get(chrom, 0)
if exclude_length < length:
Expand Down

0 comments on commit a4c5f46

Please sign in to comment.