Created
April 14, 2019 22:04
-
-
Save mdshw5/1a32d1ee141aa73af421299a8d0a6e4a to your computer and use it in GitHub Desktop.
IGV headless screenshots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rule screenshot_config: | |
input: bam="{dataset}.sort.bam", bai="{dataset}.sort.bam.bai", calls="{dataset}.calls" | |
output: batch="{dataset}.igv.batch" | |
params: runtime="600", memory="1G", filename="{dataset}.alignments.png" | |
run: | |
import os.path | |
batch_template = """load {bam} | |
preference SAM.SHOW_CENTER_LINE false | |
snapshotDirectory {directory} | |
genome hg38 | |
goto {region} | |
sort | |
collapse | |
snapshot {filename} | |
exit""" | |
with open(input.calls) as call_file: | |
for line in call_file: | |
if line.startswith('# amplicon='): | |
region = line.rstrip().replace('# amplicon=', '') | |
directory = os.path.dirname(input.bam) | |
bam = input.bam | |
filename = os.path.basename(params.filename) | |
with open(output.batch, 'w') as batchfile: | |
batchfile.write(batch_template.format(**locals())) | |
rule igv_download: | |
output: "igv.jar" | |
params: runtime="600", memory="1G" | |
shell: "curl http://data.broadinstitute.org/igv/projects/downloads/2.4/IGV_2.4.9.zip > IGV.zip; unzip -j IGV.zip IGV_2.4.9/igv.jar" | |
rule igv_screenshot: | |
input: batchfile="{dataset}.igv.batch", igv="igv.jar" | |
output: "{dataset}.alignments.png" | |
params: runtime="4300", memory="4G" | |
shell: 'xvfb-run --auto-servernum --server-args="-screen 0 3200x2400x24" java -Xmx4000m -jar {input.igv} -b {input.batchfile} || true' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment