/
spaceTxConversion.cwl
executable file
·480 lines (430 loc) · 14 KB
/
spaceTxConversion.cwl
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
#!/usr/bin/env cwl-runner
class: Workflow
cwlVersion: v1.2
requirements:
- class: SubworkflowFeatureRequirement
- class: InlineJavascriptRequirement
- class: StepInputExpressionRequirement
- class: MultipleInputFeatureRequirement
inputs:
tiffs:
type: Directory
doc: The directory containing all .tiff files
codebook_csv:
type: File?
doc: Flattened csv input, refer to record entry.
codebook_json:
type: File?
doc: Flattened json input, refer to record entry.
codebook:
type:
- 'null'
- type: record
name: csv
fields:
csv:
type: File
doc: The codebook for this experiment in .csv format, where the rows are barcodes and the columns are imaging rounds. Column IDs are expected to be sequential, and round identifiers are expected to be integers (not roman numerals).
- type: record
name: json
fields:
json:
type: File
doc: The codebook for this experiment, already formatted in the spaceTx defined .json format.
parameter_json:
type: File?
doc: json file with values to be read into other input variables.
round_count:
type: int?
doc: The number of imaging rounds in the experiment
zplane_count:
type: int?
doc: The number of z-planes in each image
channel_count:
type: int?
doc: The number of total channels per imaging round
fov_count:
type: int?
doc: The number of FOVs that are included in this experiment
round_offset:
type: int?
doc: The index of the first round (for file names).
default: 0
fov_offset:
type: int?
doc: The index of the first FOV (for file names).
default: 0
channel_offset:
type: int?
doc: The index of the first channel (for file names).
default: 0
zplane_offset:
type: int?
doc: The index of the first zplane (for file names).
default: 0
file_format:
type: string?
doc: String with layout for .tiff files
file_vars:
type: string[]?
doc: Variables to get substituted into the file_format string.
cache_read_order:
type: string[]?
doc: Order of non x,y dimensions within each image.
aux_tilesets:
- 'null'
- type: record
name: aux_tilesets
fields:
aux_names:
type: string[]?
doc: Names of the Auxillary tiles.
aux_file_formats:
type: string[]?
doc: String layout for .tiff files of aux views.
aux_file_vars:
type: string[]?
doc: Variables to be substituted into aux_file_formats. One entry per aux_name, with semicolon-delimited vars.
aux_cache_read_order:
type: string[]?
doc: Order of non x,y dimensions within each image. One entry per aux_name, with semicolon-delimited vars.
aux_channel_count:
type: int[]?
doc: Count of channels in each aux image
aux_channel_slope:
type: float[]?
doc: Used to convert 0-indexed channel IDs to the channel index within the image. Calculated as (image index) = int(index*slope) + intercept
aux_channel_intercept:
type: int[]?
doc: Used to convert 0-indexed channel IDs to the channel index within the image. Calculated as (image index) = int(index*slope) + intercept
fov_positioning:
- 'null'
- type: record
name: dummy
fields:
dummy:
type: string?
doc: Added to prevent cli parsing of the fov_positioning record.
- type: record
name: fov_positioning
fields:
- name: x_locs
type: string
doc: list of x-axis start locations per fov index
- name: x_shape
type: int
doc: shape of each fov item in the x-axis
- name: x_voxel
type: float
doc: size of voxels in the x-axis
- name: y_locs
type: string
doc: list of y-axis start locations per fov index
- name: y_shape
type: int
doc: shape of each fov item in the y-axis
- name: y_voxel
type: float
doc: size of voxels in the y-axis
- name: z_locs
type: string
doc: list of z-axis start locations per fov index
- name: z_shape
type: int
doc: shape of each fov item in the z-axis
- name: z_voxel
type: float
doc: size of voxels in the z-axis
add_blanks:
type: boolean?
doc: If true, will add blanks with a hamming distance 1 from the existing codes.
default: False
outputs:
spaceTx_converted:
type: Directory
outputSource: execute_conversion/spaceTx_converted
steps:
tmpname:
run: tmpdir.cwl
in: []
out: [tmp]
read_schema:
run:
class: CommandLineTool
baseCommand: cat
requirements:
DockerRequirement:
dockerPull: hubmap/starfish-custom:latest
inputs:
schema:
type: string
inputBinding:
position: 1
outputs:
data:
type: stdout
in:
schema:
valueFrom: "/opt/spaceTxConversion.json"
out: [data]
stage_conversion:
run: inputParser.cwl
in:
datafile: parameter_json
schema: read_schema/data
out: [round_count, zplane_count, channel_count, fov_count, round_offset, fov_offset, zplane_offset, channel_offset, file_format, file_vars, cache_read_order, aux_tilesets_aux_names, aux_tilesets_aux_file_formats, aux_tilesets_aux_file_vars, aux_tilesets_aux_cache_read_order, aux_tilesets_aux_channel_count, aux_tilesets_aux_channel_slope, aux_tilesets_aux_channel_intercept, fov_positioning_x_locs, fov_positioning_x_shape, fov_positioning_x_voxel, fov_positioning_y_locs, fov_positioning_y_shape, fov_positioning_y_voxel, fov_positioning_z_locs, fov_positioning_z_shape, fov_positioning_z_voxel, add_blanks]
when: $(inputs.datafile != null)
execute_conversion:
run:
class: CommandLineTool
baseCommand: /opt/spaceTxConverter.py
requirements:
DockerRequirement:
dockerPull: hubmap/starfish-custom:latest
inputs:
tmp_prefix:
type: string
inputBinding:
prefix: --tmp-prefix
tiffs:
type: Directory
inputBinding:
prefix: --input-dir
codebook:
type:
- type: record
name: csv
fields:
csv:
type: File
inputBinding:
prefix: --codebook-csv
- type: record
name: json
fields:
json:
type: File
inputBinding:
prefix: --codebook-json
round_count:
type: int
inputBinding:
prefix: --round-count
zplane_count:
type: int
inputBinding:
prefix: --zplane-count
channel_count:
type: int
inputBinding:
prefix: --channel-count
fov_count:
type: int
inputBinding:
prefix: --fov-count
round_offset:
type: int?
inputBinding:
prefix: --round-offset
fov_offset:
type: int?
inputBinding:
prefix: --fov-offset
channel_offset:
type: int?
inputBinding:
prefix: --channel-offset
zplane_offset:
type: int?
inputBinding:
prefix: --zplane-offset
file_format:
type: string
inputBinding:
prefix: --file-format
file_vars:
type: string[]
inputBinding:
prefix: --file-vars
cache_read_order:
type: string[]
inputBinding:
prefix: --cache-read-order
aux_tilesets:
type:
type: record
name: aux_tilesets
fields:
aux_names:
type: string[]?
inputBinding:
prefix: --aux-names
aux_file_formats:
type: string[]?
inputBinding:
prefix: --aux-file-formats
aux_file_vars:
type: string[]?
inputBinding:
prefix: --aux-file-vars
aux_cache_read_order:
type: string[]?
inputBinding:
prefix: --aux-cache-read-order
aux_channel_count:
type: int[]?
inputBinding:
prefix: --aux-channel-count
aux_channel_slope:
type: float[]?
inputBinding:
prefix: --aux-channel-slope
aux_channel_intercept:
type: int[]?
inputBinding:
prefix: --aux-channel-intercept
fov_positioning:
- 'null'
- type: record
name: fov_positioning
fields:
- name: x_locs
type: string
inputBinding:
prefix: --x-pos-locs
- name: x_shape
type: int
inputBinding:
prefix: --x-pos-shape
- name: x_voxel
type: float
inputBinding:
prefix: --x-pos-voxel
- name: y_locs
type: string
inputBinding:
prefix: --y-pos-locs
- name: y_shape
type: int
inputBinding:
prefix: --y-pos-shape
- name: y_voxel
type: float
inputBinding:
prefix: --y-pos-voxel
- name: z_locs
type: string
inputBinding:
prefix: --z-pos-locs
- name: z_shape
type: int
inputBinding:
prefix: --z-pos-shape
- name: z_voxel
type: float
inputBinding:
prefix: --z-pos-voxel
add_blanks:
type: boolean
inputBinding:
prefix: --add-blanks
outputs:
spaceTx_converted:
type: Directory
outputBinding:
glob: $("tmp/" + inputs.tmp_prefix + "/2_tx_converted/")
in:
tmp_prefix: tmpname/tmp
tiffs: tiffs
codebook:
source: [codebook, codebook_csv, codebook_json]
linkMerge: merge_flattened
valueFrom: |
${
if(self[0]){
return self[0];
} else if(self[1]){
return {csv: self[1]};
} else {
return {json: self[2]};
}
}
round_count:
source: [stage_conversion/round_count, round_count]
pickValue: first_non_null
zplane_count:
source: [stage_conversion/zplane_count, zplane_count]
pickValue: first_non_null
channel_count:
source: [stage_conversion/channel_count, channel_count]
pickValue: first_non_null
fov_count:
source: [stage_conversion/fov_count, fov_count]
pickValue: first_non_null
round_offset:
source: [stage_conversion/round_offset, round_offset]
pickValue: first_non_null
fov_offset:
source: [stage_conversion/fov_offset, fov_offset]
pickValue: first_non_null
channel_offset:
source: [stage_conversion/channel_offset, channel_offset]
pickValue: first_non_null
zplane_offset:
source: [stage_conversion/zplane_offset, zplane_offset]
pickValue: first_non_null
file_format:
source: [stage_conversion/file_format, file_format]
pickValue: first_non_null
file_vars:
source: [stage_conversion/file_vars, file_vars]
pickValue: first_non_null
cache_read_order:
source: [stage_conversion/cache_read_order, cache_read_order]
pickValue: first_non_null
aux_tilesets:
source: [aux_tilesets, stage_conversion/aux_tilesets_aux_names, stage_conversion/aux_tilesets_aux_file_formats, stage_conversion/aux_tilesets_aux_file_vars, stage_conversion/aux_tilesets_aux_cache_read_order, stage_conversion/aux_tilesets_aux_channel_count, stage_conversion/aux_tilesets_aux_channel_slope, stage_conversion/aux_tilesets_aux_channel_intercept]
valueFrom: |
${
if(!self[1]){
return self[0];
} else {
return {
aux_names: self[1],
aux_file_formats: self[2],
aux_file_vars: self[3],
aux_cache_read_order: self[4],
aux_channel_count: self[5],
aux_channel_slope: self[6],
aux_channel_intercept: self[7]
};
};
}
fov_positioning:
source: [fov_positioning, stage_conversion/fov_positioning_x_locs, stage_conversion/fov_positioning_x_shape, stage_conversion/fov_positioning_x_voxel, stage_conversion/fov_positioning_y_locs, stage_conversion/fov_positioning_y_shape, stage_conversion/fov_positioning_y_voxel, stage_conversion/fov_positioning_z_locs, stage_conversion/fov_positioning_z_shape, stage_conversion/fov_positioning_z_voxel]
valueFrom: |
${
if(self[1] === null){
if(!(self[0].x_locs === null) && !(self[0].x_shape === null) && !(self[0].x_voxel === null)){
return self[0];
} else {
return null;
}
} else {
return {
x_locs: self[1],
x_shape: self[2],
x_voxel: self[3],
y_locs: self[4],
y_shape: self[5],
y_voxel: self[6],
z_locs: self[7],
z_shape: self[8],
z_voxel: self[9]
};
};
}
add_blanks:
source: [stage_conversion/add_blanks, add_blanks]
pickValue: first_non_null
out: [spaceTx_converted]