Skip to content
Snippets Groups Projects
Commit 9b9fd26a authored by Cats's avatar Cats
Browse files

style

parent 26e020d6
No related branches found
No related tags found
1 merge request!32style changes and adds task to check file md5
This commit is part of merge request !32. Comments created here will be created in the context of that merge request.
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] out_array = read_lines(stdout())
} }
runtime { runtime {
...@@ -14,15 +16,21 @@ task objectMd5 { ...@@ -14,15 +16,21 @@ task objectMd5 {
} }
} }
task mapMd5 { task ConcatenateTextFiles {
Map[String,String] map Array[File] fileList
String combinedFilePath
Boolean? unzip=false
Boolean? zip=false
command { command {
cat ${write_map(map)} | md5sum - | sed -e 's/ -//' 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 +38,32 @@ task mapMd5 { ...@@ -30,38 +38,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 +71,15 @@ task concatenateTextFiles { ...@@ -69,17 +71,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 +87,16 @@ task flattenStringArray { ...@@ -87,17 +87,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 +104,19 @@ task appendToStringArray { ...@@ -105,17 +104,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