Skip to content
Snippets Groups Projects

style changes and adds task to check file md5

Merged Ruben Vorderman requested to merge BIOWDL-40 into develop
1 file
+ 12
0
Compare changes
  • Side-by-side
  • Inline
+ 60
47
task objectMd5 {
Object the_object
task AppendToStringArray {
Array[String] array
String string
command {
cat ${write_object(the_object)} | md5sum - | sed -e 's/ -//'
echo "${sep='\n' array}
${string}"
}
output {
String md5sum = read_string(stdout())
Array[String] outArray = read_lines(stdout())
}
runtime {
@@ -14,15 +16,33 @@ task objectMd5 {
}
}
task mapMd5 {
Map[String,String] map
# This task will fail if the MD5sum doesn't match the file.
task CheckFileMD5 {
File file
String MD5sum
command {
cat ${write_map(map)} | md5sum - | sed -e 's/ -//'
set -e -o pipefail
MD5SUM=$(md5sum ${file} | cut -d ' ' -f 1)
[ $MD5SUM = ${MD5sum} ]
}
}
task ConcatenateTextFiles {
Array[File] fileList
String combinedFilePath
Boolean? unzip = false
Boolean? zip = false
command {
set -e -o pipefail
${"mkdir -p $(dirname " + combinedFilePath + ")"}
${true='zcat' false= 'cat' unzip} ${sep=' ' fileList} \
${true="| gzip -c" false="" zip} > ${combinedFilePath}
}
output {
String md5sum = read_string(stdout())
File combinedFile = combinedFilePath
}
runtime {
@@ -30,38 +50,32 @@ task mapMd5 {
}
}
task stringArrayMd5 {
Array[String] stringArray
task CreateLink {
# Making this of type File will create a link to the copy of the file in the execution
# folder, instead of the actual file.
String inputFile
String outputPath
command {
set -eu -o pipefail
echo ${sep=',' stringArray} | md5sum - | sed -e 's/ -//'
ln -sf ${inputFile} ${outputPath}
}
output {
String md5sum = read_string(stdout())
}
runtime {
memory: 1
File link = outputPath
}
}
task concatenateTextFiles {
Array[File] fileList
String combinedFilePath
Boolean? unzip=false
Boolean? zip=false
# inspired by https://gatkforums.broadinstitute.org/wdl/discussion/9616/is-there-a-way-to-flatten-arrays
task FlattenStringArray {
Array[Array[String]] arrayList
command {
set -e -o pipefail
${"mkdir -p $(dirname " + combinedFilePath + ")"}
${true='zcat' false= 'cat' unzip} ${sep=' ' fileList} \
${true="| gzip -c" false="" zip} > ${combinedFilePath}
for line in $(echo ${sep=', ' arrayList}) ; \
do echo $line | tr -d '"[],' ; done
}
output {
File combinedFile = combinedFilePath
Array[String] flattenedArray = read_lines(stdout())
}
runtime {
@@ -69,17 +83,15 @@ task concatenateTextFiles {
}
}
# inspired by https://gatkforums.broadinstitute.org/wdl/discussion/9616/is-there-a-way-to-flatten-arrays
task flattenStringArray {
Array[Array[String]] arrayList
task MapMd5 {
Map[String,String] map
command {
for line in $(echo ${sep=', ' arrayList}) ; \
do echo $line | tr -d '"[],' ; done
cat ${write_map(map)} | md5sum - | sed -e 's/ -//'
}
output {
Array[String] flattenedArray = read_lines(stdout())
String md5sum = read_string(stdout())
}
runtime {
@@ -87,17 +99,16 @@ task flattenStringArray {
}
}
task appendToStringArray {
Array[String] array
String string
task ObjectMd5 {
Object the_object
command {
echo "${sep='\n' array}
${string}"
cat ${write_object(the_object)} | md5sum - | sed -e 's/ -//'
}
output {
Array[String] out_array = read_lines(stdout())
String md5sum = read_string(stdout())
}
runtime {
@@ -105,17 +116,19 @@ task appendToStringArray {
}
}
task createLink {
# Making this of type File will create a link to the copy of the file in the execution
# folder, instead of the actual file.
String inputFile
String outputPath
task StringArrayMd5 {
Array[String] stringArray
command {
ln -sf ${inputFile} ${outputPath}
set -eu -o pipefail
echo ${sep=',' stringArray} | md5sum - | sed -e 's/ -//'
}
output {
File link = outputPath
String md5sum = read_string(stdout())
}
}
\ No newline at end of file
runtime {
memory: 1
}
}
Loading