Mercurial > repos > mvdbeek > igv_take_screenshots
changeset 0:d828cf6bff42 draft
planemo upload for repository https://github.com/bardin-lab/readtagger/tree/master/galaxy commit 4824aeaa8107bd30ec786e8ca81779f053f0e736-dirty
author | mvdbeek |
---|---|
date | Mon, 26 Jun 2017 10:00:06 -0400 |
parents | |
children | 8b80357d8ab1 |
files | igv_make_screenshots.xml test-data/complete_batchscript.txt test-data/rover_dont_split.bam xvfb_igv.py |
diffstat | 4 files changed, 109 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/igv_make_screenshots.xml Mon Jun 26 10:00:06 2017 -0400 @@ -0,0 +1,90 @@ +<tool id="igv_make_screenshots" name="IGV_screenshots" version="0.1.0"> + <requirements> + <requirement type="package" version="0.2.9">xvfbwrapper</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + #for $inputsection in $inputfiles + #set $path="%s.%s" % ($inputsection.input.element_identifier, $inputsection.input.extension) + ln -fs $inputsection.input $path && + #if $inputsection.input.is_of_type('bam') + ln -fs $inputsection.input.metadata.bam_index '$path'.bai && + #end if + #end for + cat '$load_session' > load_session.txt && + echo snapshotDirectory "\$PWD" >> load_session.txt && + cat load_session.txt '$script_file' '$exit_session' > '$igv_session_out' && + python $__tool_directory__/xvfb_igv.py '$igv_session_out' $width,$height && + zip '$screenshots_out' *.png + ]]></command> + <configfiles> + <configfile name="igv_session"><![CDATA[#set $genome=$inputfiles[0].input.metadata.dbkey +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<Session genome="${genome}" hasGeneTrack="true" hasSequenceTrack="true" version="8"> + <Resources> + #for $inputsection in $inputfiles + #set $path="%s.%s" % ($inputsection.input.element_identifier, $inputsection.input.extension) + <Resource name="$inputsection.input.element_identifier" path="$path"/> + #end for + </Resources> + #for $inputsection in $inputfiles + #if $inputsection.input.is_of_type('bam') + #set $label=$inputsection.label if not $inputsection.label == '' else $inputsection.input.element_identifier + #set $path="%s.%s" % ($inputsection.input.element_identifier, $inputsection.input.extension) + <Panel height="$inputsection.section_height" name="Panel${label}" width="$width"> + ## First track is the coverage + <Track altColor="0,0,178" autoScale="true" color="175,175,175" colorScale="ContinuousColorScale;0.0;10.0;255,255,255;175,175,175" displayMode="COLLAPSED" featureVisibilityWindow="-1" fontSize="10" id="${label}_coverage" name="${label} Coverage" showReference="false" snpThreshold="0.2" sortable="true" visible="true"> + <DataRange baseline="0.0" drawBaseline="true" flipAxis="false" maximum="10.0" minimum="0.0" type="LINEAR"/> + </Track> + ## Second track is the actual BAM alignment file + <Track altColor="0,0,178" autoScale="false" color="0,0,178" displayMode="EXPANDED" featureVisibilityWindow="-1" fontSize="10" id="$path" name="label" sortable="true" visible="true"> + <RenderOptions colorByTag="$inputsection.color_by_tag" colorOption="TAG" flagUnmappedPairs="false" groupByOption="NONE" groupByTag="BR" linkByTag="READNAME" linkedReads="false" maxInsertSize="1000" minInsertSize="50" quickConsensusMode="false" shadeBasesOption="QUALITY" shadeCenters="true" showAllBases="false" sortByTag="" viewPairs="false"/> + </Track> + </Panel> + #end if + #end for + <Panel height="186" name="FeaturePanel" width="$width"> + <Track altColor="0,0,178" autoScale="false" color="0,0,178" displayMode="COLLAPSED" featureVisibilityWindow="-1" fontSize="10" id="Reference sequence" name="Reference sequence" sortable="false" visible="true"/> + <Track altColor="0,0,178" autoScale="false" clazz="org.broad.igv.track.FeatureTrack" color="0,0,178" colorScale="ContinuousColorScale;0.0;817.0;255,255,255;0,0,178" displayMode="COLLAPSED" featureVisibilityWindow="-1" fontSize="10" height="35" id="${genome}_genes" name="Gene" renderer="BASIC_FEATURE" sortable="false" visible="true" windowFunction="count"> + <DataRange baseline="0.0" drawBaseline="true" flipAxis="false" maximum="817.0" minimum="0.0" type="LINEAR"/> + </Track> + #for $inputsection in $inputfiles + #if not $inputsection.input.is_of_type('bam') + #set $label=$inputsection.label if not $inputsection.label == '' else $inputsection.input.element_identifier + #set $path="%s.%s" % ($inputsection.input.element_identifier, $inputsection.input.extension) + <Track altColor="0,0,178" autoScale="false" clazz="org.broad.igv.track.FeatureTrack" color="0,0,178" displayMode="COLLAPSED" featureVisibilityWindow="-1" fontSize="10" id="${path}" name="${label}" renderer="BASIC_FEATURE" sortable="false" visible="true" windowFunction="count"/> + #end if + #end for + </Panel> + <PanelLayout dividerFractions="0.004995836802664446,0.12905911740216486,0.2681099084096586,0.5512073272273106,0.8409658617818485"/> +</Session> + ]]></configfile> + <configfile name="load_session"> +load $igv_session + </configfile> + <configfile name="exit_session"> +exit + </configfile> + </configfiles> + <inputs> + <repeat name="inputfiles" min="1" title="Add tracks"> + <param name="input" type="data" format="bam,gff,gtf,bed,vcf" label="Choose an input file"/> + <param name="label" type="text" label="Enter a label for this file. If no label is entered the history name will be used"/> + <param name="section_height" type="integer" value="300" label="Height for this track"/> + <param name="color_by_tag" type="text" value="CD" label="Enter a BAM/SAM tag that should detrmine the color of a read"> + <sanitizer invalid_char=""> + <valid initial="string.letters,string.digits"><add value="_" /> </valid> + </sanitizer> + </param> + </repeat> + <param name="script_file" type="data" format="text" label="Select a IGV script with regions for which to take screenshots"/> + <param name="width" label="Select the screenshot width" type="integer" min="640" value="1080"/> + <param name="height" label="Select the screenshot height" type="integer" min="800" value="1920"/> + </inputs> + <outputs> + <data name="igv_session_out" format="xml"/> + <data name="screenshots_out" format="zip"/> + </outputs> + <help><![CDATA[ + TODO: Fill in help. + ]]></help> +</tool>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/complete_batchscript.txt Mon Jun 26 10:00:06 2017 -0400 @@ -0,0 +1,2 @@ +goto 2R:18158676-7052469 +snapshot 2R_rover_18158676_7052469_slop300.png
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xvfb_igv.py Mon Jun 26 10:00:06 2017 -0400 @@ -0,0 +1,17 @@ +import os +import subprocess +import sys + +import xvfbwrapper + + +def take_screenshots(igv_script, screensize): + width, height = screensize.split(',') + with xvfbwrapper.Xvfb(width=width, height=height) as xvfb: + exit_code = subprocess.call(['igv', '--batch', igv_script], env=os.environ.copy()) + sys.exit(exit_code) + + +if __name__ == '__main__': + take_screenshots(sys.argv[1], sys.argv[2]) +