Newer
Older
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
task objectMd5 {
Object the_object
command {
cat ${write_object(the_object)} | md5sum - | sed -e 's/ -//'
}
output {
String md5sum = read_string(stdout())
}
}
task mapMd5 {
Map[String,String] map
command {
cat ${write_map(map)} | md5sum - | sed -e 's/ -//'
}
output {
String md5sum = read_string(stdout())
}
}
task stringArrayMd5 {
Array[String] stringArray
command {
set -eu -o pipefail
echo ${sep=',' stringArray} | md5sum - | sed -e 's/ -//'
}
output {
String md5sum = read_string(stdout())
}
}
task concatenateTextFiles {
Array[File] fileList
String combinedFilePath
Boolean? unzip=false
command {
mkdir -p ${combinedFilePath}
rm -d ${combinedFilePath}
${true='zcat' false= 'cat' unzip} ${sep=' ' fileList} \
> ${combinedFilePath}
}
output {
File combinedFile = combinedFilePath
}
}
# inspired by https://gatkforums.broadinstitute.org/wdl/discussion/9616/is-there-a-way-to-flatten-arrays
task flattenStringArray {
Array[Array[String]] arrayList
command {
for line in $(echo ${sep=', ' arrayList}) ; \
do echo $line | tr -d '"[],' ; done
}
output {
Array[String] flattenedArray = read_lines(stdout())
}
}
task appendToStringArray {
Array[String] array
String string
command {
echo "${sep='\n' array}
${string}"
}
output {
Array[String] out_array = read_lines(stdout())
}
}