-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIGVscript.sh
More file actions
executable file
·80 lines (69 loc) · 1.74 KB
/
IGVscript.sh
File metadata and controls
executable file
·80 lines (69 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
### input information
INDELS=$1 ## indels files
BAM=$2 ## bam files
DIR=$3 ## figure output folder
###=========================================================
IGVR="/Volumes/TwoT/Desktop/breastcancer/IGV/IGV_2.3.57/igv.sh" ## igv
SCRF="igv_batch_script_v4.txt"
touch $SCRF
printf "#! /bin/bash\n" >> $SCRF
kk=1
BAMS0="OO"
while read line
do
## Step 1: write the tmp IGV igv_batch_script.txt
##printf "$line"
NAME=`echo $line | cut -d ' ' -f 1`
VALUE=`echo $line | cut -d ' ' -f 2`
SAMPLE=`echo $line | cut -d ' ' -f 3`
SAMS=`echo $SAMPLE|tr "," "\n"`
##echo $line
i=1
for ONE in $SAMS;
do
ONEBAM=`grep $ONE $BAM`
ONEBAM=`echo ${ONEBAM//[[:space:]]/,}`
#echo $ONEBAM
if [[ "$ONEBAM" != "" ]]
then
if [[ $i -gt 1 ]]; then
BAMS=`echo $BAMS,$ONEBAM`
else
BAMS=`echo $ONEBAM`
fi
fi
let i+=1
done
#echo $BAMS
let "START=$VALUE - 25"
let "END=$VALUE + 25"
outputf=`echo $DIR$NAME.$START.$END.$SAMPLE.png`
#echo $outputf
if [[ ! -f $outputf ]];then
if [[ ($kk -gt 1 && "$BAMS0" != "$BAMS" ) || $kk -eq 1 ]];then
printf "new\n" >> $SCRF
printf "genome hg19\n" >> $SCRF
printf "load $BAMS\n" >> $SCRF
printf "snapshotDirectory $DIR \n" >> $SCRF
fi
printf "goto chr$NAME:$START-$END \n" >> $SCRF
printf "sort position \n" >> $SCRF
#printf "expand \n" >> $SCRF
printf "collapse \n" >> $SCRF
#printf "squish \n" >> $SCRF
#printf "viewaspairs \n" >> $SCRF
printf "maxPanelHeight 2000 \n" >> $SCRF
printf "snapshot $NAME.$START.$END.$SAMPLE.png \n" >> $SCRF
printf "\n" >> $SCRF
let kk+=1
BAMS0=$BAMS
fi
done < "$INDELS"
printf "exit \n" >> $SCRF
## run IGV
NUMLINES=$(wc -l < "$SCRF")
if [[ $NUMLINES -gt 10 ]];then
$IGVR -g hg19 -b $SCRF
rm $SCRF
fi