forked from mckinsel/cellranger_clean
-
Notifications
You must be signed in to change notification settings - Fork 1
/
crconverter_open.sh
executable file
·321 lines (287 loc) · 7.01 KB
/
crconverter_open.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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#!/bin/bash
######convert version#####
crconverterversion="3.1.1.90001"
##########
#####cellranger version#####
cellrangerpath=`which cellranger` #location of cellranger
if [[ -z $cellrangerpath ]]; then
echo "cellranger command is not found."
exit 1
fi
cellrangerversion=`cellranger count --version | head -n 2 | tail -n 1 | cut -f2 -d'(' | cut -f1 -d')'`
##########
#####declare variables#####
SOURCE="${BASH_SOURCE[0]}"
##########
#####usage statement#####
statement='crconverter
Usage:
crconverter <name> <type> [options]
crconverter -h | --help | --version
'
options='
Options:
--inpath=PATH Path to a completed pipestance. crconvert will attempt find inputs automatically by filename
Explicit setting of input using other flags will override inputs found with --inpath
--output=PATH
--pipestance=PATH
--metrics=PATH
--analysis=PATH
--matrix=PATH
--aggregation=PATH
--gemgroups=PATH
--contiginfo=PATH
--peaks=PATH
--fragmentsindex=PATH
--geneannotations=PATH
--geneannotationtypes=TYPES
--description=DESC
-h --help
--version
This is an open-source implementation of crconverter.
This is only intended for testing open-source implementations
of cellranger and may not produce the same results as
software produced by 10x Genomics. We recommend the
supported software be used for other purposes.
The code in this repository is licensed under the MIT License.
'
##########
#####print usage#####
if [[ -z $1 ]]; then
echo "$statement"
exit 1
fi
##########
#####declare variables#####
name=$1
type=$2
inpath=""
output=""
pipestance=""
metrics=""
analysis=""
matrix=""
aggregation=""
gemgroups=""
contiginfo=""
peaks=""
fragmentsindex=""
geneannotations=""
geneannotationtypes=""
description=""
next=false
end=false
if [[ $1 == "-h" ]] || [[ $2 == "-h" ]] || [[ $1 == "--help" ]] || [[ $2 == "--help" ]]; then
end=true
usage=true
help=true
fi
if [[ $1 == "-v" ]] || [[ $2 == "-v" ]] || [[ $1 == "--version" ]] || [[ $2 == "--version" ]]; then
end=true
version=true
fi
shift
shift
for op in "${@}"; do
if $next; then
next=false;
continue;
fi
case "$op" in
--inpath)
shift
if [[ "$1" != "" ]]; then
inpath="${1/%\//}"
next=true
shift
else
echo "Explicit setting of input using other flags will override inputs found with --inpath"
shift
fi
;;
--output)
shift
if [[ "$1" != "" ]]; then
output="${1/%\//}"
next=true
shift
else
output=""
fi
;;
--pipestance)
shift
if [[ "$1" != "" ]]; then
pipestance="${1/%\//}"
next=true
shift
else
pipestance=""
fi
;;
--metrics)
shift
if [[ "$1" != "" ]]; then
metrics="${1/%\//}"
next=true
shift
else
metrics=""
fi
;;
--analysis)
shift
if [[ "$1" != "" ]]; then
analysis="${1/%\//}"
next=true
shift
else
analysis=""
fi
;;
--matrix)
shift
if [[ "$1" != "" ]]; then
matrix="${1/%\//}"
next=true
shift
else
matrix=""
fi
;;
--aggregation)
shift
if [[ "$1" != "" ]]; then
aggregation="${1/%\//}"
next=true
shift
else
aggregation=""
fi
;;
--gemgroups)
shift
if [[ "$1" != "" ]]; then
gemgroups="${1/%\//}"
next=true
shift
else
gemgroups=""
fi
;;
--contiginfo)
shift
if [[ "$1" != "" ]]; then
contiginfo="${1/%\//}"
next=true
shift
else
contiginfo=""
fi
;;
--peaks)
shift
if [[ "$1" != "" ]]; then
peaks="${1/%\//}"
next=true
shift
else
peaks=""
fi
;;
--fragmentsindex)
shift
if [[ "$1" != "" ]]; then
fragmentsindex="${1/%\//}"
next=true
shift
else
fragmentsindex=""
fi
;;
--geneannotations)
shift
if [[ "$1" != "" ]]; then
geneannotations="${1/%\//}"
next=true
shift
else
geneannotations=""
fi
;;
--geneannotationtypes)
shift
if [[ "$1" != "" ]]; then
geneannotationtypes="${1/%\//}"
next=true
shift
else
geneannotationtypes=""
fi
;;
--description)
shift
if [[ "$1" != "" ]]; then
description="${1/%\//}"
next=true
shift
else
echo "Error: value missing for --description"
exit 1
fi
;;
-v|--version)
end=true
version=true
echo "$crconverterversion"
exit 0
;;
-h|--help)
end=true
usage=true
help=true
echo "$statement"
echo "$options"
exit 0
;;
--verbose)
echo "debugging mode activated"
verbose=true
next=false
shift
;;
-*)
echo "Error: Invalid option: $op"
exit 1
;;
esac
done
##########
if [[ $end ]]; then
if [[ ! -z $help ]]; then
echo "$statement"
echo "$options"
exit 0
fi
fi
if [[ $end ]]; then
if [[ ! -z $version ]]; then
echo "$crconverterversion"
exit 0
fi
fi
##########
if [[ -z $output ]]; then
echo "An output file must be specified"
exit 1
fi
if [[ ! -f $output ]]; then
echo "#!/bin/bash" > $output
echo "echo \"Please use the supported release of cellranger if you wish to use .cloupe files\"" >> $output
chmod 755 $output
else
echo ".cloupe file already exists in $output"
fi
echo "Wrote .cloupe file to $output"
echo "Warning .cloupe file may be dysfunctional"
exit 0