Mercurial > repos > mvdbeek > igv_take_screenshots
changeset 13:1100d5a77c4d draft
planemo upload for repository https://github.com/bardin-lab/readtagger/tree/master/galaxy commit 1ddb87e95baeea2a4ee9b95930da6e0927fb7ff7-dirty
author | mvdbeek |
---|---|
date | Fri, 28 Jul 2017 12:47:05 -0400 |
parents | 9dca6aa224a2 |
children | bda2fa1b2cba |
files | igv_make_screenshots.xml test-data/complete_batchscript.txt test-data/igv_session.xml test-data/rover_corrected.bam test-data/rover_dont_split.bam test-data/rover_dont_split.bam.bai test-data/rover_reference.fa xvfb_igv.py |
diffstat | 8 files changed, 100 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/igv_make_screenshots.xml Mon Jul 03 12:40:16 2017 -0400 +++ b/igv_make_screenshots.xml Fri Jul 28 12:47:05 2017 -0400 @@ -1,11 +1,15 @@ <tool id="igv_make_screenshots" name="IGV_screenshots" version="0.1.0"> <requirements> <requirement type="package" version="0.2.9">xvfbwrapper</requirement> + <requirement type="package" version="2.3.93">igv</requirement> </requirements> <command detect_errors="exit_code"><![CDATA[ - #for $inputsection in $inputfiles - #set $path="%s.%s" % ($inputsection.input.element_identifier, $inputsection.input.extension) - sed -i.bak -e "s|$path|\$PWD/$path|g" '$igv_session' && + ln -s '$genome_source.genome' genome.fa && + samtools faidx genome.fa && + sed -i.bak -e "s|\"genome.fa\"|\"\$PWD/genome.fa\"|g" '$igv_session' && + #for $i, $inputsection in enumerate($inputfiles): + #set $path="%s.%s.%s" % ($i, $inputsection.input.element_identifier, $inputsection.input.extension) + sed -i.bak -e "s|\"$path\"|\"\$PWD/$path\"|g" '$igv_session' && ln -fs '$inputsection.input' '$path' && #if $inputsection.input.is_of_type('bam') ln -fs $inputsection.input.metadata.bam_index '$path'.bai && @@ -15,28 +19,25 @@ cat '$load_session' > load_session.txt && echo snapshotDirectory "\$PWD" >> load_session.txt && cat load_session.txt '$script_file' '$exit_session' > igv_script.txt && - ## gives the cluster a bit of time to actually create the symlinks ... ughs - sleep 10s && + cp '$igv_session' '$igv_session_out' && python $__tool_directory__/xvfb_igv.py igv_script.txt '$igv_preferences' $width,$height && - cp '$igv_session' '$igv_session_out' && zip screenshots.zip *.png && cp screenshots.zip '$screenshots_out' ]]></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"> + <configfile name="igv_session"><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<Session genome="genome.fa" hasGeneTrack="false" hasSequenceTrack="true" version="8"> <Resources> - #for $inputsection in $inputfiles - #set $path="%s.%s" % ($inputsection.input.element_identifier, $inputsection.input.extension) + #for $i, $inputsection in enumerate($inputfiles): + #set $path="%s.%s.%s" % ($i, $inputsection.input.element_identifier, $inputsection.input.extension) #set $coverage_id="%s_coverage" % $path <Resource path="$path"/> #end for </Resources> - #for $inputsection in $inputfiles + #for $i, $inputsection in enumerate($inputfiles): #if $inputsection.input.is_of_type('bam') #set $label=str($inputsection.label) if str($inputsection.label) else str($inputsection.input.element_identifier) - #set $path="%s.%s" % ($inputsection.input.element_identifier, $inputsection.input.extension) + #set $path="%s.%s.%s" % ($i, $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="$coverage_id" name="$label Coverage" showReference="false" snpThreshold="0.2" sortable="true" visible="true"> @@ -51,13 +52,10 @@ #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 + #for $i, $inputsection in enumerate($inputfiles): #if not $inputsection.input.is_of_type('bam') #set $label=str($inputsection.label) if str($inputsection.label) else str($inputsection.input.element_identifier) - #set $path="%s.%s" % ($inputsection.input.element_identifier, $inputsection.input.extension) + #set $path="%s.%s.%s" % ($i, $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 @@ -76,10 +74,22 @@ </configfile> </configfiles> <inputs> + <conditional name="genome_source"> + <param name="input_type_selector" type="select" label="Choose the genome source"> + <option value="cached" selected="True">Built-in references</option> + <option value="history">Select a fasta file from your history</option> + </param> + <when value="cached"> + <param name="genome" type="select" label="Select a genome"> + <options from_data_table="fasta_indexes" /> + </param> + </when> + <when value="history"> + <param name="genome" type="data" format="fasta" label="Select a fasta file as reference genome"/> + </when> + </conditional> <repeat name="inputfiles" min="1" title="Add tracks"> - <param name="input" type="data" format="bam,gff,gtf,bed,vcf" label="Choose an input file"> - <validator type="unspecified_build" /> - </param> + <param name="input" type="data" format="bam,gff,gff3,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"> @@ -97,7 +107,22 @@ <data name="igv_session_out" format="xml"/> <data name="screenshots_out" format="zip"/> </outputs> + <tests> + <test> + <param name="genome_source|input_type_selector" value="history"/> + <param name="genome_source|genome" value="rover_reference.fa"/> + <repeat name="inputfiles"> + <param name="input" value="rover_corrected.bam"/> + </repeat> + <output name="igv_session_out" file="igv_session.xml" lines_diff="6"/> + </test> + </tests> <help><![CDATA[ - TODO: Fill in help. + This tool can automate taking screenshots using IGV. + It takes as input a reference genome, an IGV script file (bedtools igv can produce such a file) + and a variable number of BAM,GFF,GTF,BED or VCF files, and produces a zip file containing screenshots for each genomic region in the IGV script file. ]]></help> + <citations> + <citation type="doi">10.1093/bib/bbs017</citation> + </citations> </tool>
--- a/test-data/complete_batchscript.txt Mon Jul 03 12:40:16 2017 -0400 +++ b/test-data/complete_batchscript.txt Fri Jul 28 12:47:05 2017 -0400 @@ -1,2 +1,2 @@ -goto 2R:7050658-7051658 -snapshot 2R_rover_7050658_7051658_slop300.png +goto 2R:1-1551 +snapshot 2R_rover_1_1551_slop300.png
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/igv_session.xml Fri Jul 28 12:47:05 2017 -0400 @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<Session genome="/Users/mvandenb/src/galaxy/database/jobs_directory/000/350/working/genome.fa" hasGeneTrack="false" hasSequenceTrack="true" version="8"> + <Resources> + <Resource path="/Users/mvandenb/src/galaxy/database/jobs_directory/000/350/working/0.rover_corrected.bam.bam"/> + </Resources> + <Panel height="300" name="Panelrover_corrected.bam" width="1920"> + <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="0.rover_corrected.bam.bam_coverage" name="rover_corrected.bam 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> + <Track altColor="0,0,178" autoScale="false" color="0,0,178" displayMode="EXPANDED" featureVisibilityWindow="-1" fontSize="10" id="/Users/mvandenb/src/galaxy/database/jobs_directory/000/350/working/0.rover_corrected.bam.bam" name="rover_corrected.bam" sortable="true" visible="true"> + <RenderOptions colorByTag="CD" 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> + <Panel height="186" name="FeaturePanel" width="1920"> + <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"/> + </Panel> + <PanelLayout dividerFractions="0.004995836802664446,0.12905911740216486,0.2681099084096586,0.5512073272273106,0.8409658617818485"/> +</Session> + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/rover_reference.fa Fri Jul 28 12:47:05 2017 -0400 @@ -0,0 +1,31 @@ +>2R +ATGTTTATATTGCGCCCTGTTCCCATCCCCCCACTGCCGCCAGAGCCTTCAATTGCTTTC +ACCACCGCTCCCGCAGGATGATGTCATGTCCACGTACCCTCGCCCAGTATTCGCACTCTA +GTTTGCAGTCTGACCTATATATCGCAATCGAACGCCGGAGTTTCCAAAACTGGGCCACCA +ACGAGGGTGATTTGCCAACCCCCGGATGCGCGGGTATGGGAGTGAGGCGGAGGATTCATT +TCATTATCACAGCGCTCAGTCAGGCAAACTTCCCGAACCACAAATTATGTGATGCACTCA +GCTGCGGCTTTTAATTGCCACACAAATGAATGGCAATTGCCCTTGTAATTGCAACTGCAA +CCGTATCATATTGTACAGGCGATCTTCTATAAGACCAACATTATATATGTATTTATTAGA +AATTGAGGGATGTATTATTTGATTTAAGGATTCGATTCACCCATTAAATGTAAACGTTTC +ATTAGATTAAGTTGTGAGTAATGTTCCTAAGTTCTAAAAGTCGATATAAGTATTCGATGC +ACAGAGGTTTTACTGTCATAAATTTCAGTTTCTTGCTGCTGGGGCCATCGGCTGGATAGC +TTACAATGCGGACACGGAGACGGAGGAATTCGTAATAGCCGCTTACATCGCGTGCTCGCT +CATCCTGGTCTTTGCTCTGCTGGGCATCTTCGCGGCCATCCGGGAATCGGTGGTGCTGAC +TGCAACGGTAGGCAATATAGTCAGGAAACCGTTTCTGAATTAACGCTGTTACGTATCCCT +TAGAGTGCTGTCTTCCTGCTGATCTTGGCCATCCTGCAGATCGTGAGCACCTGCCTGTTC +CTCCACGAGTTCGACGTGAAGAGCGGCCGGGACATGGTGGAGGTGGCCTGGCAGGCGAAC +AACATGGATTCCTTGCAGCAGAAGCACGAGTGCTGCGGCCAGAGCAGCGCCCAGGACTAT +ATCCACCTCAGCCTGCTGATCCCGCCCAGCTGCTACGCGGATCTGCAGCAGACCCCCGAC +CACCTCTATCTGGACGGGTGCATCGAAAAGGTGCAGAGCTTCTACGAAAGCGACAAGCTG +CGCTTCATCATAGTGTCCTGGGTGCTAGTGGCCTTCGAGGTGGGTTTTTCCTTAGCCCGA +CTTAAGTACCAATATATTTAAATTAACCGACTTTCTTTCAGTTAATCTGCTTCGCCTTGG +CCGTGTTTCTGGCCATTAGTTTTAAGAACAAGCAGCGACGGATGGAGTTCTAGTTCTAGG +CCTTCGGTAATCTCGAGCTATCCAACAGTACAAACTCGGAATCGGGGTCTCGCTGATATT +TTTCTCTTCAACATTTCATAACCAAATGCAAAGGACAGTCATAAATTATTCACTCCTACC +TTAATGTAACCTGTAATTAAAGTACATATTTATAGTTCAATTACCCATTATAAGTATCAT +AATAAATGTGCGCGTGTTTGTTTTCACATGATTTGCTCGCTTGTCAGTTTGTTTGTGTGT +TCTGCCCGATGGAAATATTAAGCATACGACGCGTAGTCCCGACGAGCTTTGTATGGCCGA +AACATTTCTCTATTTGCTTTGACTGCCAAATGACTTGTTGCTCGTCGCGTAATGGCATGC +TTGGAATCTGTAGGGTTCCGTTAAGTGTGCGGCGCAGAAATATCTCAATGATGTCCTGTA +ATCTATGATGTTAGTGCTCTGCGGTGGATGGATTTTGGTGGCCCCATTCAATTCCTAAAT +AAAGAAAATGCGGTGAAAGCTTTAGCCGCTGTGACA
--- a/xvfb_igv.py Mon Jul 03 12:40:16 2017 -0400 +++ b/xvfb_igv.py Fri Jul 28 12:47:05 2017 -0400 @@ -8,7 +8,7 @@ def take_screenshots(igv_script, preferences_file, screensize): width, height = screensize.split(',') with xvfbwrapper.Xvfb(width=width, height=height) as xvfb: - exit_code = subprocess.call(['igv', '-o', preferences_file, '--batch', igv_script], env=os.environ.copy()) + exit_code = subprocess.call(['igv', '-g', 'genome.fa', '-o', preferences_file, '--batch', igv_script], env=os.environ.copy()) sys.exit(exit_code)