forked from GATB/short_read_connector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshort_read_connector.sh
executable file
·245 lines (189 loc) · 5.34 KB
/
short_read_connector.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
238
239
240
241
242
243
244
245
#!/bin/bash
version="1.0.0"
EDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
platform='mac'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
platform='linux'
fi
dsk_bin=$EDIR/thirdparty/dsk/bin/macosx/dsk
if [[ $platform == 'linux' ]]; then
dsk_bin=$EDIR/thirdparty/dsk/bin/linux/dsk
fi
chmod a+x ${dsk_bin}
#BIN DIR:
if [ -d "$EDIR/build/" ] ; then # VERSION SOURCE COMPILED
BIN_DIR=$EDIR/build/bin
else # VERSION BINARY
BIN_DIR=$EDIR/bin
fi
function help {
echo "short_read_connector.sh - Groups reads within a RNA read set."
echo "Version "$version
echo "Usage: sh short_read_connector.sh -b read_file_of_files [OPTIONS]"
echo "MANDATORY:"
echo " -b read_file_of_files for bank"
echo " Example: -b data/c1.fasta.gz"
echo "OPTIONS:"
echo " -p prefix. All out files will start with this prefix. Default=\"short_read_connector_res\""
echo " -g: with this option, if a file of solid kmer exists with same prefix name and same k value, then it is re-used and not re-computed."
echo " -k value. Set the length of used kmers. Must fit the compiled value. Default=31"
echo " -f value. Fingerprint size. Size of the key associated to each indexed value, limiting false positives. Default=12"
echo " -G value. gamma value. MPHF expert users parameter - Default=2"
echo " -a: kmer abundance min (kmer from bank seen less than this value are not indexed). Default=2"
echo " -s: Minimal percentage of shared kmer in a region for considering 2 reads in a same group. Default=75"
echo " -w: Region (putative exon) size. Default=80"
echo " -t: number of thread used. Default=0"
echo " -d: use disk over RAM (slower and no impact with -c option)"
echo " -c: use short_read_connector_counter (SRC_counter)"
echo " -r: use short_read_connector_RNA (SRC_linker_RNA)"
}
bank_set=""
query_set=""
kmer_size=31
abundance_min=2
gamma=5
fingerprint_size=24
kmer_threshold=75
window_size=80
core_used=0
prefix="short_read_connector_res"
remove=1
diskMode=0
countMode=0
#######################################################################
#################### GET OPTIONS #######################
#######################################################################
while getopts "hgb:q:p:k:a:s:w:t:f:G:dcr" opt; do
case $opt in
h)
help
exit
;;
G)
echo "use gamma: $OPTARG" >&2
gamma=$OPTARG
;;
d)
echo "use disk mode"
diskMode=1
;;
c)
echo "use SRC_counter"
countMode=1
;;
r)
echo "use SRC_linker_RNA"
rnaMode=1
;;
f)
echo "use fingerprint size: $OPTARG" >&2
fingerprint_size=$OPTARG
;;
b)
echo "use bank read set: $OPTARG" >&2
bank_set=$OPTARG
;;
q)
echo "use query read set: $OPTARG" >&2
query_set=$OPTARG
;;
p)
echo "use prefix=$OPTARG" >&2
prefix=$OPTARG
;;
g)
echo "reuse solid precomputed solid kmers if exists"
remove=0
;;
k)
echo "use k=$OPTARG" >&2
kmer_size=$OPTARG
;;
a)
echo "use abundance_min=$OPTARG" >&2
abundance_min=$OPTARG
;;
s)
echo "use kmer_threshold=$OPTARG" >&2
kmer_threshold=$OPTARG
;;
w)
echo "use window_size=$OPTARG" >&2
window_size=$OPTARG
;;
t)
echo "use $OPTARG threads">&2
core_used=$OPTARG
;;
#
# u)
# echo "use at most $OPTARG cores" >&2
# option_cores_gatb="-nb-cores $OPTARG"
# option_cores_post_analysis="-t $OPTARG"
# ;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
#######################################################################
#################### END GET OPTIONS #######################
#######################################################################
if [ -z "${bank_set}" ]; then
echo "You must provide a bank read set (-b)"
help
exit 1
fi
out_dsk=${prefix}"_solid_kmers_k"${kmer_size}".h5"
result_file=${prefix}".txt"
if [ $remove -eq 1 ]; then
rm -f ${out_dsk}
fi
# Count kmers using dsk if file absent
if [ ! -e ${out_dsk} ]; then
cmd="${dsk_bin} -file ${bank_set} -kmer-size ${kmer_size} -abundance-min ${abundance_min} -out ${out_dsk} -solidity-kind all"
echo ${cmd}
${cmd}
if [ $? -ne 0 ]
then
echo "there was a problem with the kmer counting."
exit 1
fi
fi
# Compare read sets
# SRC_LINKER_RNA
if [ $diskMode -eq 0 ]; then
cmd="${BIN_DIR}/SRC_linker_rna"
# adding options
cmd="${cmd} -graph ${out_dsk} -bank ${bank_set} -out ${result_file} -kmer_threshold ${kmer_threshold} -window_size ${window_size} -fingerprint_size ${fingerprint_size} -core ${core_used} -gamma ${gamma}"
#else
# SRC_LINKER_DISK
# cmd="${BIN_DIR}/SRC_linker_disk"
# adding options
# cmd="${cmd} -graph ${out_dsk} -bank ${bank_set} -query{query_set} -out ${result_file} -kmer_threshold ${kmer_threshold} -fingerprint_size ${fingerprint_size} -core ${core_used} -gamma ${gamma}"
fi
# adding options
#cmd="${cmd} -graph ${out_dsk} -bank ${bank_set} -query ${query_set} -out ${result_file} -kmer_threshold ${kmer_threshold} -fingerprint_size ${fingerprint_size} -core ${core_used} -gamma ${gamma}"
echo ${cmd}
${cmd}
if [ $? -ne 0 ]
then
echo "there was a problem with short read connector."
exit 1
fi
# sort results
#sort -n ${unsorted_result_file} > ${result_file}
#rm -f ${unsorted_result_file}
./scripts/SRC_linker2reads.py ${bank_set} ${result_file}
echo "***********************************"
echo "Short read connector finished"
echo "results in:"
echo " "${result_file}
echo "Contact: [email protected]"
echo "***********************************"