-
Notifications
You must be signed in to change notification settings - Fork 2
/
start.sh
executable file
·177 lines (147 loc) · 6.33 KB
/
start.sh
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#/bin/sh
# folder where circos files will be written to
rm -rf data/circos
rm -rf data/circos/orf/all_orf.txt
rm -rf data/circos/hmm/hmm_all.txt
rm -rf data/circos/prokka/prokka_orf.txt
mkdir -p data/circos/orf
mkdir -p data
mkdir -p data/output
mkdir -p data/circos/hmmvis1
mkdir -p data/circos/hmmvis2
mkdir -p data/circos/hmmvis3
mkdir -p data/circos/hmmvis4
mkdir -p data/circos/hmmvis5
mkdir -p data/circos/hmmvis6
mkdir -p data/circos/fasta/
mkdir -p data/circos/hmm
mkdir -p data/circos/coverage
mkdir -p data/circos/blast
rm -rf data/circos/karyotype/
mkdir -p data/circos/karyotype/
# make a copy from input files
mkdir -p data/circos/fasta/
cp data/genomes/*.fasta data/circos/fasta/
# add file name to fasta header
for f in data/circos/fasta/*.fasta; do
header_string=$(basename ${f%.*})
perl -pi -e "s/^>/>$header_string-/g" $f
done
# run prokka
for file in data/circos/fasta/*.fasta; do
echo "run Prokka on $file"
name=$(basename ${file%.*})
prokka --outdir data/circos/prokka/$name $file >/dev/null 2>/dev/null
mv data/circos/prokka/$name/*.gff data/circos/prokka/$name.gff
done
# run prodigal and hmmsearch on input fasta files
hmmvis/hmmvis/hmmvis --fasta_dir data/circos/fasta --output_dir data/circos/hmmvis1/ --hmm data/hmm/list1.hmm >/dev/null 2>/dev/null
hmmvis/hmmvis/hmmvis --fasta_dir data/circos/fasta --output_dir data/circos/hmmvis2/ --hmm data/hmm/list2.hmm >/dev/null 2>/dev/null
hmmvis/hmmvis/hmmvis --fasta_dir data/circos/fasta --output_dir data/circos/hmmvis3/ --hmm data/hmm/list3.hmm >/dev/null 2>/dev/null
hmmvis/hmmvis/hmmvis --fasta_dir data/circos/fasta --output_dir data/circos/hmmvis4/ --hmm data/hmm/list4.hmm >/dev/null 2>/dev/null
hmmvis/hmmvis/hmmvis --fasta_dir data/circos/fasta --output_dir data/circos/hmmvis5/ --hmm data/hmm/list5.hmm >/dev/null 2>/dev/null
hmmvis/hmmvis/hmmvis --fasta_dir data/circos/fasta --output_dir data/circos/hmmvis6/ --hmm data/hmm/list6.hmm >/dev/null 2>/dev/null
# generate circos files
colors_pos=(paired-12-qual-1 paired-12-qual-3 paired-12-qual-5 paired-12-qual-7 paired-12-qual-9)
colors_neg=(paired-12-qual-2 paired-12-qual-4 paired-12-qual-6 paired-12-qual-8 paired-12-qual-10)
n=1
for i in data/circos/hmmvis1/*.fasta; do
echo "processing: 'data/circos/fasta/'${i##*/}"
./generate_chr.sh 'data/circos/fasta/'${i##*/} ${colors_neg[@]:$n:1}
./generate_gc.sh $i >/dev/null 2>/dev/null
./generate_orf.sh $i >/dev/null 2>/dev/null
./generate_hmm.sh $i.out >/dev/null 2>/dev/null
n=$(($n+1))
done
# process the hmm files
hmmcol=(paired-12-qual-2 paired-12-qual-4 paired-12-qual-6 paired-12-qual-8 paired-12-qual-10)
n=1
for i in data/circos/hmmvis1/*.fasta; do
echo "processing: 'data/circos/fasta/'${i##*/}"
./generate_hmm.sh $i.out data/circos/hmm/hmm_all_1.txt >/dev/null 2>/dev/null
done
n=$(($n+1))
for i in data/circos/hmmvis2/*.fasta; do
echo "processing: 'data/circos/fasta/'${i##*/}"
./generate_hmm.sh $i.out data/circos/hmm/hmm_all_2.txt >/dev/null 2>/dev/null
done
n=$(($n+1))
for i in data/circos/hmmvis3/*.fasta; do
echo "processing: 'data/circos/fasta/'${i##*/}"
./generate_hmm.sh $i.out data/circos/hmm/hmm_all_3.txt >/dev/null 2>/dev/null
done
n=$(($n+1))
for i in data/circos/hmmvis4/*.fasta; do
echo "processing: 'data/circos/fasta/'${i##*/}"
./generate_hmm.sh $i.out data/circos/hmm/hmm_all_4.txt >/dev/null 2>/dev/null
done
n=$(($n+1))
for i in data/circos/hmmvis5/*.fasta; do
echo "processing: 'data/circos/fasta/'${i##*/}"
./generate_hmm.sh $i.out data/circos/hmm/hmm_all_5.txt >/dev/null 2>/dev/null
done
n=$(($n+1))
for i in data/circos/hmmvis6/*.fasta; do
echo "processing: 'data/circos/fasta/'${i##*/}"
./generate_hmm.sh $i.out data/circos/hmm/hmm_all_6.txt >/dev/null 2>/dev/null
done
for i in data/circos/prokka/*.gff; do
# generate ORF locations
./generate_orf_prokka.sh $i >/dev/null 2>/dev/null
done
for i in data/circos/prokka/*.gff; do
basename=${i##*/}
name=${basename%.*}
./generate_coverage.sh $i data/circos/fasta/$name.fasta >/dev/null 2>/dev/null
./generate_coverage_hyp.sh $i data/circos/fasta/$name.fasta >/dev/null 2>/dev/null
done
# multiple karyotypes
echo "update circos config file"
list_karyo=(data/circos/karyotype/*.txt)
files=$(printf '%q,' "${list_karyo[@]}")
sed -i "2s|.*|karyotype = $files|" data/config/circos.conf
echo "make blast search"
# make a list
ls -1 data/circos/hmmvis1/*.fasta > data/circos/blast/list.txt
colors=(spectral-11-div-1 spectral-11-div-2 spectral-11-div-3 spectral-11-div-4 spectral-11-div-5 spectral-11-div-6 spectral-11-div-7 spectral-11-div-8 spectral-11-div-9 spectral-11-div-10 spectral-11-div-11)
# step 1: pick one and run vs. all others
firstline=$(head -n 1 data/circos/blast/list.txt)
tail -n +2 data/circos/blast/list.txt > data/circos/blast/list2.txt # to prevent self-comparison
n=1
while read line; do
echo "comparing $firstline with $line"
./generate_blast.sh $firstline $line ${colors[@]:$n:1} >/dev/null 2>/dev/null
n=$(($n+1))
done <data/circos/blast/list2.txt
# step 2: pick another one and run vs. all other without the first one picket
samplenum=$(wc -l /data/circos/blast/list2.txt | awk '{print $1}')
if [ $samplenum -gt 1 ]
then
firstline=$(head -n 1 data/circos/blast/list2.txt)
tail -n +2 /data/circos/blast/list2.txt > /data/circos/blast/list3.txt # to
while read line; do
echo "comparing $firstline with $line"
./generate_blast.sh $firstline $line ${colors[@]:$n:1} >/dev/null 2>/dev/null
n=$(($n+1))
done </data/circos/blast/list3.txt
# step 3: this should be recursive...
samplenum=$(wc -l /data/circos/blast/list3.txt | awk '{print $1}')
if [ $samplenum -gt 1 ]
then
firstline=$(head -n 1 /data/circos/blast/list3.txt)
tail -n +2 /data/circos/blast/list3.txt > /data/circos/blast/list4.txt # to
while read line; do
echo "comparing $firstline with $line"
./generate_blast.sh $firstline $line ${colors[@]:$n:1} >/dev/null 2>/dev/null
n=$(($n+1))
done <data/circos/blast/list4.txt
fi
fi
#update link colors
Rscript updateLinkColors.R
# remove blast matches without color
#mv /data/circos/blast/blast_links_colored.txt /data/circos/blast/blast_links_colored_backup.txt
#grep -v "color=vlgrey" /data/circos/blast/blast_links_colored_backup.txt > /data/circos/blast/blast_links_colored.txt
# draw circos plot
/root/software/circos/current/bin/circos -conf data/config/circos.conf -noparanoid >/dev/null 2>/dev/null
echo "finished"