From bd53b9cce97594c29ac314d72e9f4a77ace081b1 Mon Sep 17 00:00:00 2001 From: Shadi Zaheri Date: Tue, 10 Sep 2024 13:16:51 -0400 Subject: [PATCH] new wdl-the script has been tested on the vm --- .../PacBio/Utility/IGV_HaplotypeViz.wdl | 130 +++++++++--------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/wdl/pipelines/PacBio/Utility/IGV_HaplotypeViz.wdl b/wdl/pipelines/PacBio/Utility/IGV_HaplotypeViz.wdl index 1202411f3..6b3342843 100644 --- a/wdl/pipelines/PacBio/Utility/IGV_HaplotypeViz.wdl +++ b/wdl/pipelines/PacBio/Utility/IGV_HaplotypeViz.wdl @@ -1,77 +1,77 @@ version 1.0 -workflow igv_screenshot_automation { +workflow IGVScreenshotWorkflow { - input { - File asm_hap1_bam # BAM file for asm haplotype 1 - File asm_hap2_bam # BAM file for asm haplotype 2 - File bam # A single BAM file for the sample - File reference_fasta # Reference FASTA file - File regions_bed # Path to the BED file with regions of interest - String genome # Reference genome version (e.g., "hg38") - Int image_height = 500 # Height for the IGV tracks - } + input { + File aligned_bam_hap1 # BAM file for haplotype 1 + File aligned_bam_hap2 # BAM file for haplotype 2 + File alignments # BAM file for total alignments + File bed_file # BED file with regions + File fasta_file # Reference FASTA file + String sample_name # Sample name to use in filenames + Int image_height = 500 + Int memory_mb = 4000 + Int disk_gb = 100 # Disk size in GB, default to 100 GB + String docker_image = "us.gcr.io/broad-dsp-lrma/igv_screenshot_docker:v982024" # The Docker image to use + } - # Directly use .bam.bai files co-located with the BAM files - call IGVScreenshotTask { - input: - asm_hap1_bam = asm_hap1_bam, - asm_hap1_bai = asm_hap1_bam + ".bai", - asm_hap2_bam = asm_hap2_bam, - asm_hap2_bai = asm_hap2_bam + ".bai", - bam = bam, - bam_bai = bam + ".bai", - reference_fasta = reference_fasta, - regions_bed = regions_bed, - genome = genome, - image_height = image_height - } + call RunIGVScreenshot { + input: + aligned_bam_hap1 = aligned_bam_hap1, + aligned_bam_hap2 = aligned_bam_hap2, + alignments = alignments, + bed_file = bed_file, + fasta_file = fasta_file, + sample_name = sample_name, + image_height = image_height, + memory_mb = memory_mb, + disk_gb = disk_gb, + docker_image = docker_image + } - output { - Array[File] snapshots = IGVScreenshotTask.snapshots - } + output { + Array[File] snapshots = RunIGVScreenshot.snapshots + } } -task IGVScreenshotTask { - input { - File asm_hap1_bam - File asm_hap1_bai - File asm_hap2_bam - File asm_hap2_bai - File bam - File bam_bai - File reference_fasta - File regions_bed - String genome - Int image_height - } +task RunIGVScreenshot { + input { + File aligned_bam_hap1 + File aligned_bam_hap2 + File alignments + File bed_file + File fasta_file + String sample_name + Int image_height + Int memory_mb + Int disk_gb + String docker_image + } - command { - # Localize the BAM and BAI files to ensure IGV can use them - ln -s ${asm_hap1_bam} . - ln -s ${asm_hap1_bai} . - ln -s ${asm_hap2_bam} . - ln -s ${asm_hap2_bai} . - ln -s ${bam} . - ln -s ${bam_bai} . + command { + mkdir -p IGV_Snapshots + Xvfb :1 -screen 0 1024x768x16 &> xvfb.log & + export DISPLAY=:1 - # Run the Python script with inputs for asm_hap1, asm_hap2, and bam - python3 /opt/IGV_Linux_2.18.2/make_igv_screenshot.py \ - ${asm_hap1_bam} ${asm_hap2_bam} ${bam} \ - -r ${regions_bed} -g ${genome} -ht ${image_height} \ - -ref_fasta ${reference_fasta} \ - -bin /opt/IGV_Linux_2.18.2/igv.sh - } + # Run the IGV screenshot script with the provided inputs + python3 /opt/IGV_Linux_2.18.2/make_igv_screenshot.py \ + ~{aligned_bam_hap1} ~{aligned_bam_hap2} ~{alignments} \ + -r ~{bed_file} \ + -ht ~{image_height} \ + -bin /opt/IGV_Linux_2.18.2/igv.sh \ + -mem ~{memory_mb} \ + --fasta_file ~{fasta_file} \ + --sample_name ~{sample_name} + } - output { - # Capture all the snapshot files generated by the script from the 'IGV_Snapshots' directory - Array[File] snapshots = glob("IGV_Snapshots/*.png") - } + runtime { + docker: docker_image + memory: "~{memory_mb} MB" + cpu: 2 + disks: "local-disk ~{disk_gb} HDD" + } - runtime { - docker: "us.gcr.io/broad-dsp-lrma/igv_screenshot_docker:v982024" - memory: "8G" - cpu: 2 - disks: "local-disk 100 HDD" # Adjust this based on file size needs - } + output { + Array[File] snapshots = glob("IGV_Snapshots/*.png") + } }