Skip to content
Snippets Groups Projects
Unverified Commit a8523586 authored by Ruben Vorderman's avatar Ruben Vorderman Committed by GitHub
Browse files

Merge pull request #32 from biowdl/BIOWDL-40

style changes and adds task to check file md5
parents 45027f45 cda858f9
No related branches found
No related tags found
No related merge requests found
task objectMd5 { task AppendToStringArray {
Object the_object Array[String] array
String string
command { command {
cat ${write_object(the_object)} | md5sum - | sed -e 's/ -//' echo "${sep='\n' array}
${string}"
} }
output { output {
String md5sum = read_string(stdout()) Array[String] outArray = read_lines(stdout())
} }
runtime { runtime {
...@@ -14,15 +16,33 @@ task objectMd5 { ...@@ -14,15 +16,33 @@ task objectMd5 {
} }
} }
task mapMd5 { # This task will fail if the MD5sum doesn't match the file.
Map[String,String] map task CheckFileMD5 {
File file
String MD5sum
command { 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 { output {
String md5sum = read_string(stdout()) File combinedFile = combinedFilePath
} }
runtime { runtime {
...@@ -30,38 +50,32 @@ task mapMd5 { ...@@ -30,38 +50,32 @@ task mapMd5 {
} }
} }
task stringArrayMd5 { task CreateLink {
Array[String] stringArray # 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 { command {
set -eu -o pipefail ln -sf ${inputFile} ${outputPath}
echo ${sep=',' stringArray} | md5sum - | sed -e 's/ -//'
} }
output { output {
String md5sum = read_string(stdout()) File link = outputPath
}
runtime {
memory: 1
} }
} }
task concatenateTextFiles { # inspired by https://gatkforums.broadinstitute.org/wdl/discussion/9616/is-there-a-way-to-flatten-arrays
Array[File] fileList task FlattenStringArray {
String combinedFilePath Array[Array[String]] arrayList
Boolean? unzip=false
Boolean? zip=false
command { command {
set -e -o pipefail for line in $(echo ${sep=', ' arrayList}) ; \
${"mkdir -p $(dirname " + combinedFilePath + ")"} do echo $line | tr -d '"[],' ; done
${true='zcat' false= 'cat' unzip} ${sep=' ' fileList} \
${true="| gzip -c" false="" zip} > ${combinedFilePath}
} }
output { output {
File combinedFile = combinedFilePath Array[String] flattenedArray = read_lines(stdout())
} }
runtime { runtime {
...@@ -69,17 +83,15 @@ task concatenateTextFiles { ...@@ -69,17 +83,15 @@ task concatenateTextFiles {
} }
} }
# inspired by https://gatkforums.broadinstitute.org/wdl/discussion/9616/is-there-a-way-to-flatten-arrays task MapMd5 {
task flattenStringArray { Map[String,String] map
Array[Array[String]] arrayList
command { command {
for line in $(echo ${sep=', ' arrayList}) ; \ cat ${write_map(map)} | md5sum - | sed -e 's/ -//'
do echo $line | tr -d '"[],' ; done
} }
output { output {
Array[String] flattenedArray = read_lines(stdout()) String md5sum = read_string(stdout())
} }
runtime { runtime {
...@@ -87,17 +99,16 @@ task flattenStringArray { ...@@ -87,17 +99,16 @@ task flattenStringArray {
} }
} }
task appendToStringArray {
Array[String] array task ObjectMd5 {
String string Object the_object
command { command {
echo "${sep='\n' array} cat ${write_object(the_object)} | md5sum - | sed -e 's/ -//'
${string}"
} }
output { output {
Array[String] out_array = read_lines(stdout()) String md5sum = read_string(stdout())
} }
runtime { runtime {
...@@ -105,17 +116,19 @@ task appendToStringArray { ...@@ -105,17 +116,19 @@ task appendToStringArray {
} }
} }
task createLink { task StringArrayMd5 {
# Making this of type File will create a link to the copy of the file in the execution Array[String] stringArray
# folder, instead of the actual file.
String inputFile
String outputPath
command { command {
ln -sf ${inputFile} ${outputPath} set -eu -o pipefail
echo ${sep=',' stringArray} | md5sum - | sed -e 's/ -//'
} }
output { output {
File link = outputPath String md5sum = read_string(stdout())
} }
}
\ No newline at end of file runtime {
memory: 1
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment