forked from HopkinsIDD/flepimop_sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cromwell_workflow.sh
executable file
·147 lines (134 loc) · 5.69 KB
/
cromwell_workflow.sh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
echo ""
echo "******************************************************************************"
echo "* MIDAS Cromwell / Flexible Epidemic Modeling Pipeline(“FlepiMoP”) *"
echo "* *"
echo "* This script demonstrates the execution of the *"
echo "* Flexible Epidemic Modeling Pipeline(“FlepiMoP”, formerly the *"
echo "* COVID Scenario Pipeline, “CSP”), a flexible modeling framework that *"
echo "* projects epidemic trajectories and healthcare impacts under different *"
echo "* suites of interventions in order to aid in scenario planning. *"
echo "* *"
echo "* Cromwell: https://github.com/broadinstitute/cromwell *"
echo "* FlepiMoP: https://github.com/HopkinsIDD/flepiMoP.git *"
echo "* MIDAS Network: *"
echo "* https://github.com/midas-network/cromwell_flepimop_project.git *"
echo "* *"
echo "* author: Jeff Stazer, jbs82@pitt.edu *"
echo "******************************************************************************"
echo ""
# https://stackoverflow.com/questions/7334754/correct-way-to-check-java-version-from-bash-script
# returns the JDK version.
# 8 for 1.8.0_nn, 9 for 9-ea etc, and "no_java" for undetected
jdk_version() {
local result
local java_cmd
if [[ -n $(type -p java) ]]
then
java_cmd=java
elif [[ (-n "$JAVA_HOME") && (-x "$JAVA_HOME/bin/java") ]]
then
java_cmd="$JAVA_HOME/bin/java"
fi
local IFS=$'\n'
# remove \r for Cygwin
local lines=$("$java_cmd" -Xms32M -Xmx32M -version 2>&1 | tr '\r' '\n')
if [[ -z $java_cmd ]]
then
result=no_java
else
for line in $lines; do
if [[ (-z $result) && ($line = *"version \""*) ]]
then
local ver=$(echo $line | sed -e 's/.*version "\(.*\)"\(.*\)/\1/; 1q')
# on macOS, sed doesn't support '?'
if [[ $ver = "1."* ]]
then
result=$(echo $ver | sed -e 's/1\.\([0-9]*\)\(.*\)/\1/; 1q')
else
result=$(echo $ver | sed -e 's/\([0-9]*\)\(.*\)/\1/; 1q')
fi
fi
done
fi
echo "$result"
}
echo "Checking JAVA installation and version..."
java_ver="$(jdk_version)"
if (( $java_ver > 10 ))
then
java_installed=true
echo " JAVA installed and acceptable version found"
else
echo " Error: This application requires a minimum JAVA version of 11."
exit 1
fi
echo "Checking DOCKER installation and version..."
if [[ $(which docker) && $(docker --version) ]]
then
docker_installed=true
echo " Docker installation found"
else
echo " Error: This application requires Docker to be installed."
echo " Please install Docker using the installation instructions from:"
echo " https://docs.docker.com/get-docker/"
echo " Rerun this script once you've installed Docker."
exit 1
fi
#echo "java " + $java_installed
#echo "docker " + $docker_installed
echo "Pulling Docker library ..."
docker pull python
checksum="f9581657e0484c90b5ead0f699d8d791f94e3cabe87d8cb0c5bfb21d1fdb6592 cromwell-86.jar"
echo "Looking for cromwell-86.jar..."
if [[ -f "cromwell-86.jar" ]]; then
echo " cromwell-86.jar found."
else
echo " cromwell-86.jar not found..."
if which wget >/dev/null; then
echo " Downloading cromwell-86.jar via wget."
wget -q --show-progress https://github.com/broadinstitute/cromwell/releases/download/86/cromwell-86.jar
else
echo " Error: Cannot download cromwell-86.jar, wget is not available."
echo " Please install wget or download the following file to this directory:"
echo " https://github.com/broadinstitute/cromwell/releases/download/86/cromwell-86.jar "
echo " Rerun this script once you've either installed wget or downloaded cromwell-86.jar"
exit 1
fi
fi
echo "Verifying cromwell-86.jar..."
if [[ $(shasum -a 256 cromwell-86.jar) = $checksum ]]; then
echo " cromwell-86.jar verified!";
else
echo " Error: Couldn't verify cromwell-86.jar, please delete the .jar and run this script again."
exit 1
fi
echo "Verifying model input folder exists..."
if [[ -d model_input ]];
then
echo " model_input folder found!";
else
echo " Error: Couldn't find model_input folder. Please create the folder and place your input files in the folder."
exit 1
fi
echo "Verifying model definition file provided as modelWorkflow_inputs.json..."
if [[ -f modelWorkflow_inputs.json ]]; then
echo " modelWorkflow_inputs.json found."
else
echo " modelWorkflow_inputs.json not found..."
echo " Please specify the model configuation yml and "
echo " the model executable in the modelWorkflow_inputs.json file."
exit 1
fi
echo "Running Cromwell workflow ..."
# java -Dconfig.file=cromwell_config.conf -jar cromwell-86.jar run idmWorkflow.wdl --metadata-output metadata-output.json
java -Dconfig.file=cromwell_config.conf -jar cromwell-86.jar run modelWorkflow.wdl --inputs modelWorkflow_inputs.json
echo ""
echo "******************************************************************************"
echo "* MIDAS Cromwell / Flexible Epidemic Modeling Pipeline(“FlepiMoP”) *"
echo "* *"
echo "* Cromwell workflow has completed. Model output can be found at: *"
echo "$(pwd)/model_output"
echo "* *"
echo "******************************************************************************"
echo ""