Skip to content
Snippets Groups Projects
Commit f25df1ae authored by Ruben Vorderman's avatar Ruben Vorderman
Browse files

scatterregions always outputs ordered scatters

parent 9d62a9d9
No related branches found
No related tags found
No related merge requests found
......@@ -254,7 +254,7 @@ task ScatterRegions {
# linking does not work.
String outputDirPath = "scatters"
command {
command <<<
set -e -o pipefail
mkdir -p ~{outputDirPath}
biopet-scatterregions -Xmx~{javaXmx} \
......@@ -264,10 +264,29 @@ task ScatterRegions {
~{"-L " + regions} \
~{"--bamFile " + bamFile} \
~{true="--notSplitContigs" false="" notSplitContigs}
}
# Glob messes with order of scatters (10 comes before 1), which causes
# problems at gatherGvcfs
# Therefore we reorder the scatters with python.
# Copy all the scatter files to the CWD so the output matches paths in
# the cwd.
for file in ~{outputDirPath}/*
do cp $file .
done
python << CODE
import os
scatters = os.listdir("~{outputDirPath}")
splitext = [ x.split(".") for x in scatters]
splitnum = [x.split("-") + [y] for x,y in splitext]
ordered = sorted(splitnum, key=lambda x: int(x[1]))
merged = ["{}-{}.{}".format(x[0],x[1],x[2]) for x in ordered]
for x in merged:
print(x)
CODE
>>>
output {
Array[File] scatters = glob(outputDirPath + "/scatter-*.bed")
Array[File] scatters = read_lines(stdout())
}
runtime {
......
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