-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenomesize.sh
executable file
·235 lines (176 loc) · 4.95 KB
/
genomesize.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
### estimate genome size
out=$1
name=$2
data=$3
decont=$4
pwd=$5
threads=$6
RAM=$7
RAMAssembly=$8
SmudgePlot=$9
printf "sh FullPipeline/genomesize.sh $1 $2 $3 $4 $5 $6 $7 $8 $9\n# "
#############################
mkdir ${out}/results/GenomeSize
if [[ $data == *'ILL'* ]]
then
if [[ $decont == 'no' ]]
then
IllInp1=${name}_1_val_1
IllInp2=${name}_2_val_2
else
IllInp1=kraken_illumina_${name}_1
IllInp2=kraken_illumina_${name}_2
fi
fi
if [[ $data == *'ONT'* ]]
then
if [[ $decont == 'no' ]]
then
OntInp=${name}_ont
else
OntInp=raken_ont_${name}
fi
fi
if [[ $data == *'PB'* ]]
then
if [[ $decont == 'no' ]]
then
PbInp=${name}_pb
else
PbInp=raken_${name}_pb
fi
fi
### run JellyFish to obtain k-mer histograms
echo """
#!/bin/sh
## name of Job
#PBS -N jellyfish_${name}
## Redirect output stream to this file.
#PBS -o ${out}/log/GenomeSize_${name}_log.txt
## Stream Standard Output AND Standard Error to outputfile (see above)
#PBS -j oe
## Select a maximum walltime of 2h
#PBS -l walltime=48:00:00
## Select ${threads} cores and ${RAM}gb of RAM
#PBS -l select=1:ncpus=${threads}:mem=${RAMAssembly}g
## load all necessary software into environment
module load Assembly/Jellyfish-2.3.0
module load Assembly/genomescope-2.0
## Go to pwd
cd ${pwd}
if [[ ( $data == 'ILL' ) || ( $data == 'ILL_ONT' ) || ( $data == 'ILL_PB' ) || ( $data == 'ILL_ONT_PB' ) ]]
then
## unzip files
gunzip -c ${out}/data/Illumina/${IllInp1}.fq.gz > ${out}/data/Illumina/${IllInp1}.fq &
gunzip -c ${out}/data/Illumina/${IllInp2}.fq.gz > ${out}/data/Illumina/${IllInp2}.fq
wait
## run Jellyfish
## parameters
# -C canononical; count both strands
# -m 31 Length of mers
# -s initial hash size
jellyfish-linux count \
-C \
-m 31 \
-s 100M \
-t ${threads} \
-F 2 \
-o ${out}/results/GenomeSize/${name}_reads.jf \
${out}/data/Illumina/${IllInp1}.fq \
${out}/data/Illumina/${IllInp2}.fq
rm -f ${out}/data/Illumina/${IllInp1}.fq ${out}/data/Illumina/${IllInp2}.fq
fi
if [[ ( $data == 'ONT' ) || ( $data == 'ONT_PB' ) ]]
then
## unzip ONT file
gunzip -c ${out}/data/ONT/${OntInp}.fq.gz > ${out}/data/ONT/${OntInp}.fq
## run Jellyfish
## parameters
# -C canononical; count both strands
# -m 31 Length of mers
# -s initial hash size
jellyfish-linux count \
-C \
-m 31 \
-s 100M \
-t ${threads} \
-F 2 \
-o ${out}/results/GenomeSize/${name}_reads.jf \
${out}/data/ONT/${OntInp}.fq
rm -f ${out}/data/ONT/${OntInp}.fq
fi
if [[ ( $data == 'PB' ) ]]
then
## unzip file
gunzip -c ${out}/data/PB/${PbInp}.fq.gz > ${out}/data/PB/${PbInp}.fq
## run Jellyfish
## parameters
# -C canononical; count both strands
# -m 31 Length of mers
# -s initial hash size
jellyfish-linux count \
-C \
-m 31 \
-s 100M \
-t ${threads} \
-F 2 \
-o ${out}/results/GenomeSize/${name}_reads.jf \
${out}/data/PB/${PbInp}.fq
rm -f ${out}/data/PB/${PbInp}.fq
fi
jellyfish-linux histo \
-t ${threads} \
${out}/results/GenomeSize/${name}_reads.jf \
> ${out}/results/GenomeSize/${name}_reads.histo
## run GenomeScope
genomescope.R \
-i ${out}/results/GenomeSize/${name}_reads.histo \
-k 31 \
-p 2 \
-o ${out}/results/GenomeSize/${name}
""" > ${out}/shell/qsub_genomesize_${name}.sh
qsub -W block=true ${out}/shell/qsub_genomesize_${name}.sh
if [[ $SmudgePlot != "no" ]]
then
echo """
#!/bin/sh
## name of Job
#PBS -N smudgeplot_${name}
## Redirect output stream to this file.
#PBS -o ${out}/log/Smudgeplot_${name}_log.txt
## Stream Standard Output AND Standard Error to outputfile (see above)
#PBS -j oe
## Select a maximum walltime of 2h
#PBS -l walltime=48:00:00
## Select ${threads} cores and ${RAM}gb of RAM
#PBS -l select=1:ncpus=${threads}:mem=${RAM}g
## load all necessary software into environment
module load Assembly/Jellyfish-2.3.0
source /opt/anaconda3/etc/profile.d/conda.sh
conda activate smudgeplot-0.2.4
## run SmudgePlot
## Go to pwd
cd ${pwd}
L=\$(smudgeplot.py cutoff ${out}/results/GenomeSize/${name}_reads.histo L)
U=\$(smudgeplot.py cutoff ${out}/results/GenomeSize/${name}_reads.histo U)
## cheat if limits are COMPLETELY off
if [ $((U-L)) -lt 100 ]
then
L=1
U=100
fi
#echo $L $U
jellyfish-linux dump \
-c \
-L \$L \
-U \$U \
${out}/results/GenomeSize/${name}_reads.jf \
| smudgeplot.py hetkmers \
-o ${out}/results/GenomeSize/${name}_kmer_pairs
smudgeplot.py plot ${out}/results/GenomeSize/${name}_kmer_pairs_coverages.tsv \
-o ${out}/results/GenomeSize/${name} -k 31
rm -f ${out}/data/kraken_${name}_*.fq
""" > ${out}/shell/qsub_smudgeplot_${name}.sh
printf "# "
qsub ${out}/shell/qsub_smudgeplot_${name}.sh
fi