annotate igvscreenshot.sh @ 0:aad38011de33 draft default tip

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