-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path15.dcarv3analysis.sh
executable file
·237 lines (201 loc) · 8.09 KB
/
15.dcarv3analysis.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/bin/bash
set -o pipefail
set -u # error if reference uninitialized variable
shopt -s nullglob
# comparative analysis of DCARv3d with v2 and v3c assemblies
# configuration
pfx=$(echo $0 | sed -e "s/^.*\///" -e "s/\..*$//")
chrs="Chr1 Chr2 Chr3 Chr4 Chr5 Chr6 Chr7 Chr8 Chr9 MT PT"
# input files
v2seq="/vcru_share_s/carrot/LNRQ01/data/130.DHv2.fna"
v3cseq="/vcru_share_s/carrot/dcarv3c/data/DCARv3c.fna.gz"
v3dseq="/vcru_share_s/carrot/dcarv3d/data/DCARv3d.fna.gz"
# output files
outdir="$pfx.outputdir"
nboutdir="notebook/$pfx.outputdir"
# 1. Initialization
for d in $outdir $nboutdir ; do
if [ ! -d $d ]; then
echo "1. Creating directory \"$d\" $(date)"
mkdir "$d"
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
fi
done
# 2. Extract subsequences
for chr in $chrs ; do
oldchr="/vcru_share_s/carrot/LNRQ01/data/130.DHv2_$chr.fna.gz"
v3cchr="/vcru_share_s/carrot/dcarv3c/data/DCARv3c_${chr}.fna.gz"
v3dchr="/vcru_share_s/carrot/dcarv3d/data/DCARv3d_${chr}.fna.gz"
if [ ! -s "$oldchr" ]; then
echo "Extracting v2 $chr $(date)"
bb.fastagrep --grep="DCARv2_$chr" --infile="$v2seq" --outfile="$oldchr"
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
fi
if [ ! -s "$v3cchr" ]; then
echo "Extracting v3c $chr $(date)"
bb.fastagrep --grep="DCARv3_$chr" --infile="$v3cseq" --outfile="$v3cchr"
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
fi
if [ ! -s "$v3dchr" ]; then
echo "Extracting v3d $chr $(date)"
bb.fastagrep --grep="DCARv3_$chr" --infile="$v3dseq" --outfile="$v3dchr"
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
fi
done # for chr
# 3. Comparison with MUMmer v2 chromosome vs. v3d chromosome
for chr in $chrs ; do
oldchr="/vcru_share_s/carrot/LNRQ01/data/130.DHv2_$chr.fna.gz"
v3cchr="/vcru_share_s/carrot/dcarv3c/data/DCARv3c_${chr}.fna.gz"
v3dchr="/vcru_share_s/carrot/dcarv3d/data/DCARv3d_${chr}.fna.gz"
mummerout3a="$outdir/$pfx.mummer-v2-v3d.$chr"
mummerout3b="$outdir/$pfx.mummer-v3c-v3d.$chr"
if [ ! -s "${mummerout3a}1-0.tn.jpg" ]; then
echo "3a. Comparing v2-v3d $chr with MUMmer $(date)"
bb.mummer --task=compare \
--infile="$v3dchr" \
--infile="$oldchr" \
--outfile="$mummerout3a" \
--size=large \
--savedeltafile --reusedeltafile \
--savecoords \
--savegnuplot \
--nopoints \
--minlength=5000 \
--minpercent=96 \
--showgaps=1000
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
tn "${mummerout3a}1-0.png" 6
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
cp -puv --no-preserve=owner "${mummerout3a}1-0.png" "${mummerout3a}1-0.tn.jpg" "$nboutdir"/
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
fi
if [ ! -s "${mummerout3b}1-0.tn.jpg" ]; then
echo "3b. Comparing v3c-v3d $chr with MUMmer $(date)"
bb.mummer --task=compare \
--infile="$v3dchr" \
--infile="$v3cchr" \
--outfile="$mummerout3b" \
--size=large \
--savedeltafile --reusedeltafile \
--savecoords \
--savegnuplot \
--nopoints \
--minlength=5000 \
--minpercent=96 \
--showgaps=1000
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
tn "${mummerout3b}1-0.png" 6
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
cp -puv --no-preserve=owner "${mummerout3b}1-0.png" "${mummerout3b}1-0.tn.jpg" "$nboutdir"/
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
fi
done # for chr
exit
# 4. Comparison with MUMmer organellar with alignment output
# ( organellar are the same for v3c and v3d )
for chr in MT PT ; do
oldchr="/vcru_share_s/carrot/LNRQ01/data/130.DHv2_$chr.fna.gz"
v3dchr="/vcru_share_s/carrot/dcarv3d/data/DCARv3d_${chr}.fna.gz"
mummerout4a="$outdir/$pfx.mummer4a.$chr"
if [ ! -s "${mummerout4a}1-0.alignment.txt" ]; then
echo "4a. Comparing $chr with MUMmer $(date)"
bb.mummer --task=compare \
--infile="$v3dchr" \
--infile="$oldchr" \
--outfile="$mummerout4a" \
--size=none \
--savedeltafile --reusedeltafile \
--savecoords \
--showaligns \
--minlength=5000 \
--minpercent=96 \
--showgaps=1000
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
fi
done # for chr
# 5. New region analysis - compare a chromosome to entire old genome = SLOW!
for chr in $chrs ; do
v3dchr="/vcru_share_s/carrot/dcarv3d/data/DCARv3d_${chr}.fna.gz"
mummerout5a="$outdir/$pfx.mummer5a-v3d-to-v2.$chr"
mummerout5b="$outdir/$pfx.mummer5b-v3d-to-v3c.$chr"
if [ ! -s "${mummerout5a}1-0.tn.jpg" ]; then
echo "5a. Comparing v3d $chr to v2 genome with MUMmer $(date)"
bb.mummer --task=compare \
--infile="$v3dchr" \
--infile="$v2seq" \
--outfile="$mummerout5a" \
--size=large \
--savedeltafile --reusedeltafile \
--savecoords \
--savegnuplot \
--nopoints \
--minlength=5000 \
--minpercent=96 \
--showgaps=100000
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
tn "${mummerout5a}1-0.png" 6
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
cp -puv --no-preserve=owner "${mummerout5a}1-0.png" "${mummerout5a}1-0.tn.jpg" "$nboutdir"/
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
fi
if [ ! -s "${mummerout5b}1-0.tn.jpg" ]; then
echo "5b. Comparing v3d $chr to v3c genome with MUMmer $(date)"
bb.mummer --task=compare \
--infile="$v3dchr" \
--infile="$v3cseq" \
--outfile="$mummerout5b" \
--size=large \
--savedeltafile --reusedeltafile \
--savecoords \
--savegnuplot \
--nopoints \
--minlength=5000 \
--minpercent=96 \
--showgaps=100000
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
tn "${mummerout5b}1-0.png" 6
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
cp -puv --no-preserve=owner "${mummerout5b}1-0.png" "${mummerout5b}1-0.tn.jpg" "$nboutdir"/
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
fi
done # for chr
# 6. Comparison of MUMmer organellar to self
for chr in MT PT ; do
v3dchr="/vcru_share_s/carrot/dcarv3d/data/DCARv3d_${chr}.fna.gz"
mummerout6a="$outdir/$pfx.mummer6a.$chr"
mummerout6b="$outdir/$pfx.mummer6b.$chr"
if [ ! -s "${mummerout6b}1-0.alignment.txt" ]; then
echo "6a. Comparing $chr with MUMmer to self $(date)"
bb.mummer --task=compare \
--infile="$v3dchr" \
--infile="$v3dchr" \
--outfile="$mummerout6a" \
--size=large \
--savedeltafile --reusedeltafile \
--savecoords \
--savegnuplot \
--nopoints \
--showgaps=1000
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
tn "${mummerout6a}1-0.png" 6
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
cp -puv --no-preserve=owner "${mummerout6a}1-0.png" "${mummerout6a}1-0.tn.jpg" "$nboutdir"/
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
echo "6b. Comparing $chr with MUMmer to self with alignments $(date)"
bb.mummer --task=compare \
--infile="$v3dchr" \
--infile="$v3dchr" \
--outfile="$mummerout6b" \
--size=none \
--savedeltafile --reusedeltafile \
--savecoords \
--showaligns \
--nopoints \
--showgaps=1000
r=$?; if [ $r != 0 ]; then echo "Error code $r line $LINENO script $0, halting"; exit $r; fi
fi
done # for chr
cp -puv --no-preserve=owner "$0" notebook/
echo "$0 Done $(date)"
exit 0
#eof