-
Notifications
You must be signed in to change notification settings - Fork 2
/
replong.sh
executable file
·237 lines (229 loc) · 5.11 KB
/
replong.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
SECONDS=0
DIR=$( cd $(dirname $0) ; pwd -P )
printf "script path = %s\n" $DIR
#source ${DIR}/generateFasta.sh
source ${DIR}/processRead.sh
lines=65000000 genomeSize= file= temp= lendiff=200 fromlen=250 ratio=0.96 drops=3 n1=3 n2=8 degree=10 commu_size=10 window=100 cor=false breaks=200 outputfile="replong.log" canuPath="" faidxPath="" javaPath="" minOverlapLength=500 minReadLength=1000 netMinOverlap=100 weight=false
while getopts f:o:r:s:e:h:n:l:t:p:j:b:q:w:d:x:c:g:a:m:z: opt
do
case $opt in
f) file=$OPTARG
;;
s) genomeSize=$OPTARG
;;
h) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
maxThreads=$OPTARG
;;
e) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
maxMemory=$OPTARG
;;
r) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
minReadLength=$OPTARG
;;
o) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
minOverlapLength=$OPTARG
;;
j) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
javaPath=$OPTARG
;;
l) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
lines=$OPTARG
;;
t) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
temp=$OPTARG
;;
b) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
breaks=$OPTARG
;;
x) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
drops=$OPTARG
;;
q) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
n1=$OPTARG
;;
w) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
weight=$OPTARG
;;
p) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
netMinOverlap=$OPTARG
;;
y) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
n2=$OPTARG
;;
d) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
degree=$OPTARG
;;
a) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
faidxPath=$OPTARG
;;
g) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
lendiff=$OPTARG
;;
c) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
cor=$OPTARG
;;
m) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
fromlen=$OPTARG
;;
z) if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
outputfile=$OPTARG
esac
done
shift $((OPTIND - 1))
printf "file=%s\n" $file
printf "genomeSize=%s\n" $genomeSize
#printf "range=%s\n" $range
printf "correction=%s\n" $cor
#printf "lines=%s\n" $lines
printf "temp folder=%s\n" ${temp}
#printf "breaks=%d\n" ${breaks}
#printf "n1=%d\n" $n1
#printf "n2=%d\n" $n2
#printf "degree=%d\n" $degree
#printf "commu_size=%d\n" $commu_size
#printf "drops=%d\n" $drops
printf "lendiff=%d\n" $lendiff
#printf "ratio=%s\n" $ratio
#printf "window=%d\n" $window
printf "fromlen=%d\n" $fromlen
printf "outputfile=%s\n" $outputfile
printf "network minimum overlap length=%s\n" $netMinOverlap
home=$(pwd)
orifile="$(cd "$(dirname "$file")" && pwd)/$(basename "$file")"
printf "original place=%s\n" $home
if [ -z $file ]
then
printf "no input file!\n"
exit 1
fi
if [ -z $temp ]
then
printf "no temp folder!\n"
exit 1
fi
if [ -z $genomeSize ]
then
printf "no genome size!\n"
exit 1
fi
mkdir $temp
if [ -z $javaPath ]
then
javaPath=$(command -v java)
javaPath=${javaPath%java}
else
ORGPATH=`pwd`
RELPATH=$javaPath
cd $RELPATH
javaPath=`pwd`
cd $ORGPATH
fi
#if [ -z $canuPath ]
#then
# canuPath=$(command -v canu)
# canuPath=${canuPath%canu}
#else
# ORGPATH=`pwd`
# canuPath=${canuPath%canu}
# RELPATH=$canuPath
# cd $RELPATH
# canuPath=`pwd`
# cd $ORGPATH
#fi
canuPath="canu/Linux-amd64/bin"
canuPath="$DIR/$canuPath"
if [ -z $faidxPath ]
then
faidxPath=$(command -v faidx)
faidxPath=${faidxPath%faidx}
else
ORGPATH=`pwd`
RELPATH=$faidxPath
cd $RELPATH
faidxPath=`pwd`
cd $ORGPATH
fi
printf "canu path is %s\n" $canuPath
printf "min Read Length is %s\n" $minReadLength
printf "min Overlap Length is %s\n" $minOverlapLength
printf "faidx path is %s\n" $faidxPath
printf "java path is %s\n" $javaPath
if [ $cor = true ]
then
printf "Use raw reads, read correction is running.\n"
$canuPath/canu -correct -p "step1" -d $temp genomeSize="$genomeSize" saveReadCorrections=T maxThreads=$maxThreads maxMemory=$maxMemory java=$javaPath/java corOutCoverage=400 gnuplotTested=true minReadLength=$minReadLength minOverlapLength=$minOverlapLength corMinCoverage=0 -pacbio-raw "$file"
printf "the folder is %s\n" $temp
cd $temp
printf "process reads\n"
processRead
else
printf "Use corrected reads, no need for read correction.\n"
$canuPath/canu -correct -p "step1" -d $temp genomeSize="$genomeSize" corOutCoverage=400 java=$javaPath/java gnuplotTested=true maxThreads=$maxThreads maxMemory=$maxMemory corMinCoverage=0 minReadLength=$minReadLength minOverlapLength=$minOverlapLength stopAfter=overlap -pacbio-corrected "$file"
printf "the folder is %s\n" $temp
cd $temp
printf "process reads\n"
processRead
fi
#echo $parameters >> ${home}/${outputfile}
duration=$SECONDS
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed." >> ${home}/${outputfile}
#rm -rf $temp
cd $home