changeset 0:aad38011de33 draft default tip

Uploaded
author saskia-hiltemann
date Tue, 28 Jul 2015 11:16:53 -0400
parents
children
files README igvscreenshot.sh igvscreenshot.xml tool_dependencies.xml
diffstat 4 files changed, 254 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README	Tue Jul 28 11:16:53 2015 -0400
@@ -0,0 +1,29 @@
+IGV screenshot tool
+
+Installation
+-----------------------
+IMPORTANT: this tool assumes java runtime and Xvfb to be installed on the system!
+
+installing Xvfb on Ubuntu: 
+   apt-get install Xvfb
+
+
+Dependencies
+----------------------
+Dependencies installed with this tool: IGV version 2.3.57
+
+
+Troubleshooting
+-----------------------
+tested on Ubuntu, IGV seems quite fussy depending on version..
+
+--
+If you get this error:
+(process:52487): GLib-GIO-ERROR **: Settings schema 'org.gnome.system.proxy' is not installed
+
+Fix by installing: 
+sudo apt-get install gsettings-desktop-schemas
+--
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/igvscreenshot.sh	Tue Jul 28 11:16:53 2015 -0400
@@ -0,0 +1,115 @@
+# Get igv screenshot 
+
+echo $@
+
+# parse input parameters
+set -- `getopt -n$0 -u -a --longoptions="track: region: archive: build: outfile: scriptdir: ftype: index: label: viewaspairs: view:" "h:" "$@"` || usage
+[ $# -eq 0 ] && usage
+
+while [ $# -gt 0 ]
+do
+    case "$1" in
+                --track)	      	tracks+=",$2";shift;;  
+		--region)		region=$2;shift;; 
+		--build)		build=$2;shift;;
+		--outfile)              outfile=$2;shift;;
+		--scriptdir)            scriptdir=$2;shift;;
+		--ftype)                ftypes+=",$2";shift;;
+		--index)                indexfiles+=",$2";shift;;
+		--label)                tracklabels+=",$2";shift;;
+		--view)                 view+=",$2";shift;;
+		--viewaspairs)          viewaspairs+=",$2";shift;;
+                -h)       	 	shift;;
+		--)       		shift;break;;
+        -*)       		 	usage;;
+        *)        		 	break;;            
+    esac
+    shift
+done
+
+# location of IGV installation
+igvlocation="${scriptdir}/IGV_2.1.28"
+
+# set preferences properly
+echo -e "IGV.track.show.attribute.views=true
+LAST_CHROMOSOME_VIEWED_KEY=All
+DEFAULT_GENOME_KEY=${build}" > prefs.properties
+
+#IGV.Bounds=0,0,$width,$height
+#SHOW_SEQUENCE_TRANSLATION=true
+#IGV.Frame.ExtendedState=0
+
+# parse track, filetype and indexfile strings
+tracks=${tracks/,/}     # remove leading comma from list
+tracks=${tracks//,/ }   # replace commas with spaces
+ftypes=${ftypes/,/}     # remove leading comma from list
+indexfiles=${indexfiles/,/}       # remove leading comma from list
+tracklabels=${tracklabels/,/}     # remove leading comma from list
+tracklabels=${tracklabels// /_}   # replace spaces with underscores for track labels
+view=${view/,/}     # remove leading comma from list
+viewaspairs=${viewaspairs/,/}     # remove leading comma from list
+
+# generate batch file recipe for igv
+echo -e    "new 
+genome ${build}" > recipe.txt
+
+# add tracks to recipe
+IFS=',' read -a ftypearray <<< "$ftypes"
+IFS=',' read -a indexarray <<< "$indexfiles"
+IFS=',' read -a labelarray <<< "$tracklabels"
+IFS=',' read -a viewarray <<< "$view"
+IFS=',' read -a viewaspairsarray <<< "$viewaspairs"
+count=0
+for track in $tracks
+do 
+
+    # make symlink to file with the proper extension (or IGV will not work)
+    ftype=${ftypearray[count]}
+    label=${labelarray[count]}
+    ltrack="${label}.${ftype}"
+    ln -s ${track} ${ltrack}
+
+    # link the index file too if needed
+    if [[ $ftype == "bam" ]]
+    then
+        indexltrack="${label}.bam.bai"
+        ln -s ${indexarray[count]} ${indexltrack}
+    fi
+
+    # add track to recipe
+    echo -e "load ${ltrack}" >>recipe.txt
+
+    # set view for track (collapsed/expanded/squished)
+    echo -e "${viewarray[count]} ${ltrack}" >> recipe.txt
+    
+    # set to view as pairs if requested
+    if [[ ${viewaspairsarray[count]} == "yes" ]]
+    then
+        echo -e "viewaspairs ${ltrack}" >> recipe.txt
+    fi
+    
+    
+    count=$[$count+1]
+
+done
+
+
+echo -e "snapshotDirectory .
+goto ${region//,/ }
+sort base
+snapshot screenshot.png
+exit" >> recipe.txt
+
+# for debugging purposes:
+echo -e "\nIGV batch recipe is:\n"
+cat recipe.txt
+
+# setup X environment
+echo -e "\nsetting up Xvfb:\n"
+Xvfb :0 2>&1 &
+export DISPLAY=:0
+
+# run igv
+echo -e "\nrunning IGV:\n"
+igv.sh -b recipe.txt -o prefs.properties 2>&1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/igvscreenshot.xml	Tue Jul 28 11:16:53 2015 -0400
@@ -0,0 +1,84 @@
+<tool id="igvscreenshot" name="Take an IGV screenshot" version="1.2">
+
+	<description>specifying tracks and a genomic location</description> 
+
+        <requirements>		
+		<requirement type="package" version="2.3.57">igv</requirement>
+	</requirements>
+        
+	
+	<command interpreter="bash">
+		igvscreenshot.sh 
+                    --build $reference
+                    #for $i, $t in enumerate( $tracks )
+                        --track ${t.inputfile}
+                        --ftype ${t.inputfile.extension}
+                        --view ${t.view}
+                        --viewaspairs ${t.viewaspairs}
+                        #if not $t.trackname  <!-- validator for empty field does not seem to work within a repeat, so this is the workaround  -->
+                            #set $tracklabel = "noname"
+                        #else
+                            #set $tracklabel = $t.trackname
+                        #end if
+                        --label $tracklabel
+                        #if $t.inputfile.extension == "bam"
+                            --index $t.inputfile.metadata.bam_index
+                        #else
+                            --index "none"
+                        #end if
+                    #end for
+                    --region "$region"       
+	</command>
+
+
+	<inputs>
+	<!-- parameter examples, see https://wiki.galaxyproject.org/Admin/Tools/ToolConfigSyntax for descriptions -->
+                
+                <param name="reference" type="select" label="Select Build">
+                    <option value="hg18"> hg18 </option>
+                    <option value="hg19"> hg19 </option>
+		</param>
+                
+		<!-- file from history -->
+                <repeat name="tracks" title="Track" min="1">
+                    <param name="inputfile" type="data" format="bam,vcf,bed,gtf,gff" label="Select input file" help="choose input file from history"/>
+                    <param name="trackname" type="text" size="100" value="track label" label="Track Label" >
+                        <sanitizer>
+				<valid initial="default"> 
+					<add preset="string.printable"/> 
+					<remove value=" "/>
+				</valid> 
+				<mapping initial="none"> 
+					<add source=" " target="_"/>
+				</mapping> 
+			</sanitizer>                        
+                    </param>
+                    <param name="view" type="select" label="View settings of track" >
+                           <option value="collapse"  > collapsed </option>
+                           <option value="expand"  > expanded </option>
+                           <option value="squish"  > squished </option>
+                    </param>                    
+                    <param name="viewaspairs" type="boolean" checked="False" truevalue="Y" falsevalue="N" label="view as pairs?" help="optional setting for paired-end data"/>
+				
+                </repeat>
+                <!-- text field parameter -->
+		<param name="region" type="text" size="100" value="chr:start-end" label="Enter region to visualise in IGV, format chr:start-end" help="to show multiple regions in a single image, use comma-separated list of regions, e.g. chr1:0-100,chr2:100-200"/>
+    
+                </inputs>
+
+	
+	<outputs>
+		<data format="png" name="outputfile" from_work_dir="screenshot.png" label="IGV screenshot of region ${region} on ${on_string}"/>
+	</outputs>
+
+	<help>
+This tool will create an IGV screenshot of the desired location(s) with the desired tracks.
+        
+Tracks may be bam, vcf, bed, gff or gtf format.
+
+Multiple regions may be specified (comma-separated)
+
+
+        
+        </help>
+</tool>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Tue Jul 28 11:16:53 2015 -0400
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+
+<tool_dependency>
+	<package name="igv" version="2.3.57"> 
+    
+        <install version="1.0">
+            <actions>                				
+                <action type="download_by_url"> http://www.broadinstitute.org/igv/projects/downloads/IGV_2.3.57.zip</action>                 
+                <action type="shell_command"> chmod a+x igv.sh</action>
+                <action type="move_directory_files">
+                    <source_directory>.</source_directory>
+                    <destination_directory>$INSTALL_DIR</destination_directory>
+                </action>      
+                <action type="set_environment">
+                        <environment_variable name="PATH" action="prepend_to">$INSTALL_DIR</environment_variable>
+                </action>      
+            </actions>
+         
+       </install>
+        
+        <readme>
+			Downloads and installs the igv 2.3.57 package. 
+        </readme>
+    </package>      
+</tool_dependency>
+