comparison igvscreenshot.sh @ 0:aad38011de33 draft default tip

Uploaded
author saskia-hiltemann
date Tue, 28 Jul 2015 11:16:53 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:aad38011de33
1 # Get igv screenshot
2
3 echo $@
4
5 # parse input parameters
6 set -- `getopt -n$0 -u -a --longoptions="track: region: archive: build: outfile: scriptdir: ftype: index: label: viewaspairs: view:" "h:" "$@"` || usage
7 [ $# -eq 0 ] && usage
8
9 while [ $# -gt 0 ]
10 do
11 case "$1" in
12 --track) tracks+=",$2";shift;;
13 --region) region=$2;shift;;
14 --build) build=$2;shift;;
15 --outfile) outfile=$2;shift;;
16 --scriptdir) scriptdir=$2;shift;;
17 --ftype) ftypes+=",$2";shift;;
18 --index) indexfiles+=",$2";shift;;
19 --label) tracklabels+=",$2";shift;;
20 --view) view+=",$2";shift;;
21 --viewaspairs) viewaspairs+=",$2";shift;;
22 -h) shift;;
23 --) shift;break;;
24 -*) usage;;
25 *) break;;
26 esac
27 shift
28 done
29
30 # location of IGV installation
31 igvlocation="${scriptdir}/IGV_2.1.28"
32
33 # set preferences properly
34 echo -e "IGV.track.show.attribute.views=true
35 LAST_CHROMOSOME_VIEWED_KEY=All
36 DEFAULT_GENOME_KEY=${build}" > prefs.properties
37
38 #IGV.Bounds=0,0,$width,$height
39 #SHOW_SEQUENCE_TRANSLATION=true
40 #IGV.Frame.ExtendedState=0
41
42 # parse track, filetype and indexfile strings
43 tracks=${tracks/,/} # remove leading comma from list
44 tracks=${tracks//,/ } # replace commas with spaces
45 ftypes=${ftypes/,/} # remove leading comma from list
46 indexfiles=${indexfiles/,/} # remove leading comma from list
47 tracklabels=${tracklabels/,/} # remove leading comma from list
48 tracklabels=${tracklabels// /_} # replace spaces with underscores for track labels
49 view=${view/,/} # remove leading comma from list
50 viewaspairs=${viewaspairs/,/} # remove leading comma from list
51
52 # generate batch file recipe for igv
53 echo -e "new
54 genome ${build}" > recipe.txt
55
56 # add tracks to recipe
57 IFS=',' read -a ftypearray <<< "$ftypes"
58 IFS=',' read -a indexarray <<< "$indexfiles"
59 IFS=',' read -a labelarray <<< "$tracklabels"
60 IFS=',' read -a viewarray <<< "$view"
61 IFS=',' read -a viewaspairsarray <<< "$viewaspairs"
62 count=0
63 for track in $tracks
64 do
65
66 # make symlink to file with the proper extension (or IGV will not work)
67 ftype=${ftypearray[count]}
68 label=${labelarray[count]}
69 ltrack="${label}.${ftype}"
70 ln -s ${track} ${ltrack}
71
72 # link the index file too if needed
73 if [[ $ftype == "bam" ]]
74 then
75 indexltrack="${label}.bam.bai"
76 ln -s ${indexarray[count]} ${indexltrack}
77 fi
78
79 # add track to recipe
80 echo -e "load ${ltrack}" >>recipe.txt
81
82 # set view for track (collapsed/expanded/squished)
83 echo -e "${viewarray[count]} ${ltrack}" >> recipe.txt
84
85 # set to view as pairs if requested
86 if [[ ${viewaspairsarray[count]} == "yes" ]]
87 then
88 echo -e "viewaspairs ${ltrack}" >> recipe.txt
89 fi
90
91
92 count=$[$count+1]
93
94 done
95
96
97 echo -e "snapshotDirectory .
98 goto ${region//,/ }
99 sort base
100 snapshot screenshot.png
101 exit" >> recipe.txt
102
103 # for debugging purposes:
104 echo -e "\nIGV batch recipe is:\n"
105 cat recipe.txt
106
107 # setup X environment
108 echo -e "\nsetting up Xvfb:\n"
109 Xvfb :0 2>&1 &
110 export DISPLAY=:0
111
112 # run igv
113 echo -e "\nrunning IGV:\n"
114 igv.sh -b recipe.txt -o prefs.properties 2>&1
115