Skip to content

Commit 2d48f4d

Browse files
mikesiodamsioda
authored andcommitted
AWS Gui + ImportMetadata Bug Fix (#127)
1 parent 9087dd5 commit 2d48f4d

4 files changed

Lines changed: 108 additions & 97 deletions

File tree

script/biolockj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ docker_args() {
4141
[ ${#gui} -gt 0 ] && args="g"
4242
[ ${#config} -gt 0 ] && args="c=${config}" && [ ${#newPass} -gt 0 ] && args="${args} p=${newPass}"
4343
[ ${#restart} -gt 0 ] && args="${args} r=${restart}"
44-
[ ${#overrideBLJ} -gt 0 ] && args="${args} blj=${overrideBLJ}"
45-
[ ${#overrideBLJ_SUP} -gt 0 ] && args="${args} blj_sup=${overrideBLJ_SUP}"
44+
[ ${#blj} -gt 0 ] && args="${args} blj=${blj}"
45+
[ ${#blj_sup} -gt 0 ] && args="${args} blj_sup=${blj_sup}"
4646
echo "${args}"
4747
}
4848

@@ -75,13 +75,17 @@ parse_input_args() {
7575
config=$(named_arg $args c)
7676
newPass=$(named_arg $args p)
7777
restart=$(named_arg $args r)
78-
overrideBLJ=$(named_arg $args blj)
79-
overrideBLJ_SUP=$(named_arg $args blj_sup)
78+
blj=$(named_arg $args blj)
79+
blj_sup=$(named_arg $args blj_sup)
80+
[ ${#runDocker} -eq 0 ] && [ ${#blj} -gt 0 ] && echo "Arg \"blj\" is only applicable in Docker mode so will be ignored"
81+
[ ${#runDocker} -eq 0 ] && [ ${#blj_sup} -gt 0 ] && echo "Arg \"blj_sup\" is only applicable in Docker mode so will be ignored"
82+
[ ${#runDocker} -eq 0 ] && [ ${#runGui} -gt 0 ] && runDocker="d" && echo "Arg \"gui\" is only applicable in Docker mode --> starting Docker biolockj_controller container"
8083
[ ${#runGui} -eq 0 ] && [ ${#restart} -eq 0 ] && [ ! -f "${config}" ] && ${BLJ}/script/biolockj -h && exit_script "Error [ biolockj ]: \"$config\" is not a valid file \n"
8184
}
8285

8386
# Run biolockj by locally, on AWS, or in Docker mode based on script args
8487
run_biolockj() {
88+
[ ${#gui} -gt 0 ]
8589
[ ${#runAws} -gt 0 ] && run_aws "${config}" && return
8690
[ ${#runDocker} -gt 0 ] && dockblj $(docker_args) && return
8791
[ ! -d "${BLJ_PROJ}" ] && exit_script "Error [ biolockj ]: Required env variable BLJ_PROJ undefined: \"${BLJ_PROJ}\""

script/blj_test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## ##
66
## Script requires valid BioLockJ Config file passed as a parameter. ##
77
## ##
8-
## Pass optional param "-c" as 1st param to continue after any failure. ##
8+
## Pass optional param "-x" as 1st param to continue after any failure. ##
99
## Otherwise exit script if any pipeline fails. ##
1010
## ##
1111
###########################################################################
@@ -53,5 +53,5 @@ verify_params() {
5353
[ ! -d "$BLJ_PROJ" ] && exit_script "Error [ blj_test ]: Required env variable undefined --> \"BLJ_PROJ\""
5454
}
5555

56-
verify_params
57-
run_tests
56+
verify_params $@
57+
run_tests $@

script/dockblj

Lines changed: 82 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,53 @@
11
#!/bin/bash
2-
##################################################################################
3-
## Script launches BioLockJ via Docker + creates $DOCKER_CLONE_SCRIPT ##
4-
## Bash env must include pipeline base directory: ${BLJ_PROJ} ##
5-
## ##
6-
## Required Parameters (If -gui arg passed, no other args required) ##
7-
## Config file path: -c <file-path> ##
8-
## ##
9-
## Optional Parameters: ##
10-
## Aws flag: -aws ##
11-
## Use local BLJ flag: -blj ##
12-
## Use local BLJ_SUP flag: -blj_sup ##
13-
## Run GUI flag: -gui ##
14-
## New email password: -p <new_password> ##
15-
## Restart flag: -r <directory-path> ##
16-
## ##
17-
##################################################################################
2+
###############################################################################
3+
## Script launches BioLockJ via Docker + creates $DOCKER_CLONE_SCRIPT ##
4+
## Bash env must include pipeline base directory: ${BLJ_PROJ} ##
5+
## ##
6+
## Required Parameters (If g arg passed, no other args required) ##
7+
## Config file path: c <file_path> ##
8+
## ##
9+
## Optional Parameters: ##
10+
## Aws flag: a ##
11+
## Use local BLJ flag: -blj ##
12+
## Use local BLJ_SUP flag: -blj_sup ##
13+
## Run GUI flag: g ##
14+
## New email password: p <new_password> ##
15+
## Restart flag: r <dir_path> ##
16+
## ##
17+
###############################################################################
1818
. "${DOCKER_LIB}"
1919

20-
DOCKER_ENV_FLAG="/.dockerenv"
2120
GUI_PORT=8080
2221

2322
# Populate docker run env variable $BLJ_OPTIONS
2423
# Always include vars to map Host paths: Config, $BLJ_PROJ, and $HOME.
25-
# In AWS mode, add -aws indicator, otherwise include the Host path for pipeline input.
24+
# In AWS mode, add a indicator, otherwise include the Host path for pipeline input.
2625
# These paths are used by biolockj_controller to map Docker volumes for java_module containers
2726
blj_options() {
2827
options="-u ${HOME} -b $(blj_proj) -h $(hostname)"
29-
$(var_not_null $overrideBLJ) && options="${options} -blj ${overrideBLJ}"
30-
$(var_not_null $overrideBLJ_SUP) && options="${options} -blj_sup ${overrideBLJ_SUP}"
31-
$(var_not_null $launchGui) && echo "${options}" && return
32-
33-
$(var_not_null $restartDir) && options="${options} -r ${BLJ_PROJ}/${restartDir#$(blj_proj)/}"
34-
$(var_not_null $newPass) && options="${options} -p $newPass"
35-
$(var_not_null $metaPath) && options="${options} -m $metaPath"
36-
$(var_not_null $primerPath) && options="${options} -t $primerPath"
37-
38-
echo ${options} -i ${inputDir} -c ${config} ${runAws}
28+
! $(null_var $blj) && options="${options} -blj ${blj}"
29+
! $(null_var $blj_sup) && options="${options} -blj_sup ${blj_sup}"
30+
! $(null_var $runGui) && echo "${options}" && return
31+
! $(null_var $restartDir) && options="${options} r ${BLJ_PROJ}/${restartDir#$(blj_proj)/}"
32+
! $(null_var $newPass) && options="${options} p $newPass"
33+
! $(null_var $metaPath) && options="${options} -m $metaPath"
34+
! $(null_var $primerPath) && options="${options} -t $primerPath"
35+
echo "${options} -i ${inputDir} c ${config} ${runAws}"
3936
}
4037

4138
# If dockblj called by biolockj_controller Docker container in GUI mode, set BLJ_PROJ based on the $BLJ_OPTIONS
4239
# env var, otherwise return $BLJ_PROJ if called from a host machine. If dir ends with "/" trim it off
4340
blj_proj() {
44-
if [ -f "${DOCKER_ENV_FLAG}" ] && $(var_exists BLJ_OPTIONS); then
41+
if [ -f "/.dockerenv" ] && $(var_exists BLJ_OPTIONS); then
4542
bljProj=$(named_arg "${BLJ_OPTIONS}" -b)
4643
else
4744
bljProj="${BLJ_PROJ}"
4845
fi
49-
5046
if [ "${bljProj: -1}" == "/" ]; then
5147
len=$((${#bljProj}-1))
5248
bljProj="${bljProj:0:len}"
5349
fi
54-
! $(var_not_null $bljProj) && exit_script "Error [ dockblj.blj_proj ]: Required env variable BLJ_PROJ undefined"
50+
$(null_var $bljProj) && exit_script "Error [ dockblj.blj_proj ]: Required env variable BLJ_PROJ undefined"
5551
echo "${bljProj}"
5652
}
5753

@@ -60,8 +56,7 @@ blj_proj() {
6056
build_clone_script() {
6157
img="$(dock_id)/biolockj_controller"
6258
cmd=${@/$img/-ti $img /bin/bash}
63-
$(var_not_null $launchGui) && cmd=${cmd/ npm start}
64-
59+
! $(null_var $runGui) && cmd=${cmd/npm start}
6560
echo "#!/bin/bash" > "${DOCKER_CLONE_SCRIPT}"
6661
echo "# This script launches a clone of the last biolockj_controller (same env vars + volumes)" >> "${DOCKER_CLONE_SCRIPT}"
6762
echo "${cmd}" >> "${DOCKER_CLONE_SCRIPT}"
@@ -73,57 +68,72 @@ build_clone_script() {
7368
# Get Docker image - add port, entrypoint, anc command if launching GUI
7469
get_docker_img() {
7570
cmd=$(dock_id)/biolockj_controller
76-
$(var_not_null $launchGui) && echo "-p ${GUI_PORT}:3000 --expose ${GUI_PORT} -w /app/biolockj/web_app ${cmd} npm start"
77-
! $(var_not_null $launchGui) && echo "${cmd}"
71+
$(null_var $runGui) && echo "${cmd}"
72+
! $(null_var $runGui) && echo "-p ${GUI_PORT}:3000 --expose ${GUI_PORT} -w /app/biolockj/web_app ${cmd} npm start"
7873
}
7974

8075
# Get mapped Docker volumes
8176
get_volumes() {
8277
vols="-v ${DOCK_SOCK}:${DOCK_SOCK} -v ${HOME}:${BLJ_HOST_HOME}:delegated"
83-
if $(var_not_null $runAws); then
84-
vols="${vols} -v ${EFS}:${EFS}:delegated"
85-
else
78+
if $(null_var $runAws); then
8679
vols="${vols} -v $(blj_proj):${EFS_PROJ}:delegated"
87-
if $(var_not_null $launchGui); then
88-
vols="${vols} -v ${BLJ}/resources/config/gui:${BLJ_CONFIG}:delegated"
89-
else
80+
if $(null_var $runGui); then
9081
vols="${vols} -v $inputDir:${BLJ_INPUT}:ro -v $(dirname $config):${BLJ_CONFIG}:ro"
91-
$(var_not_null $metaPath) && vols="${vols} -v $metaPath:${BLJ_META}:ro"
92-
$(var_not_null $primerPath) && vols="${vols} -v $primerPath:${BLJ_PRIMER}:ro"
82+
$(null_var $metaPath) && vols="${vols} -v $metaPath:${BLJ_META}:ro"
83+
$(null_var $primerPath) && vols="${vols} -v $primerPath:${BLJ_PRIMER}:ro"
84+
else
85+
vols="${vols} -v ${BLJ}/resources/config/gui:${BLJ_CONFIG}:delegated"
9386
fi
94-
95-
$(var_not_null $overrideBLJ) && vols="${vols} -v ${overrideBLJ}:/app/biolockj:ro"
96-
$(var_not_null $overrideBLJ_SUP) && vols="${vols} -v ${overrideBLJ_SUP}:/app/blj_support:ro"
87+
! $(null_var $blj) && vols="${vols} -v ${blj}:/app/biolockj:ro"
88+
! $(null_var $blj_sup) && vols="${vols} -v ${blj_sup}:/app/blj_support:ro"
89+
else
90+
vols="${vols} -v ${EFS}:${EFS}:delegated"
9791
fi
9892
echo "${vols}"
9993
}
10094

95+
# Boolean evaluation if single argument passed exists with a non-zero size
96+
# Param 1 - Script arg
97+
null_var() {
98+
[ ${#1} -eq 0 ]
99+
}
100+
101101
# Print and execute the docker run command with the correct volumes and env variables
102102
run_docker() {
103-
cmd="docker run --rm -e \"BLJ_OPTIONS=$(blj_options)\" $(get_volumes) $(get_docker_img)"
103+
! $(null_var $runGui) && runInBak=" &"
104+
cmd="docker run --rm -e \"BLJ_OPTIONS=$(blj_options)\" $(get_volumes) $(get_docker_img)${runInBak}"
104105
printf "\n---------> Execute CMD [ ${cmd} ] \n\n"
105106
build_clone_script "${cmd}"
106-
docker run --rm -e "BLJ_OPTIONS=$(blj_options)" $(get_volumes) $(get_docker_img)
107+
if $(null_var $runGui); then
108+
docker run --rm -e "BLJ_OPTIONS=$(blj_options)" $(get_volumes) $(get_docker_img)
109+
else
110+
docker run --rm -e "BLJ_OPTIONS=$(blj_options)" $(get_volumes) $(get_docker_img) &
111+
fi
107112
}
108113

109114
# Read script args and bash env vars
110115
# Param 1 - Array of dockblj script args
111116
scan_script_and_env_args() {
112-
launchGui=$(arg_exists "$@" -gui)
113-
runAws=$(arg_exists "$@" -aws)
114-
overrideBLJ=$(named_arg "$@" -blj)
115-
overrideBLJ_SUP=$(named_arg "$@" -blj_sup)
116-
! $(var_not_null $overrideBLJ) && overrideBLJ=$(arg_exists "$@" -blj) && [ ${#overrideBLJ} -eq 0 ] && overrideBLJ="${BLJ}"
117-
! $(var_not_null $overrideBLJ_SUP) && overrideBLJ_SUP=$(arg_exists "$@" -blj_sup) && [ ${#overrideBLJ_SUP} -eq 0 ] && overrideBLJ_SUP="${BLJ_SUP}"
118-
config=$(named_arg "$@" -c)
119-
newPass=$(named_arg "$@" -p)
120-
restartDir=$(named_arg "$@" -r)
121-
inputDir=$(named_arg "$@" -i)
122-
metaPath=$(named_arg "$@" -m)
123-
primerPath=$(named_arg "$@" -t)
124-
#inputDir="$(get_property $config input.dirPaths)"
125-
#metaPath="$(get_property $config metadata.filePath)" && [ ${#metaPath} -gt 0 ] && metaPath="$(dirname $metaPath)"
126-
#primerPath="$(get_property $config trimPrimers.filePath)" && [ ${#primerPath} -gt 0 ] && primerPath="$(dirname $primerPath)"
117+
runGui=$(arg_exists "$@" g)
118+
runAws=$(arg_exists "$@" a)
119+
config=$(named_arg "$@" c)
120+
newPass=$(named_arg "$@" p)
121+
restartDir=$(named_arg "$@" r)
122+
blj=$(named_arg "$@" -blj)
123+
blj_sup=$(named_arg "$@" -blj_sup)
124+
125+
if $(null_var $blj) && blj=$(arg_exists "$@" -blj); then
126+
blj="${BLJ}" && $(null_var $blj) && echo "Arg \"blj\" will be ignored because environment variable \"BLJ\" is undefined"
127+
fi
128+
if $(null_var $blj_sup) && blj_sup=$(arg_exists "$@" -blj_sup); then
129+
blj_sup="${BLJ_SUP}" && $(null_var $blj_sup) && echo "Arg \"blj_sup\" will be ignored because environment variable \"BLJ_SUP\" is undefined"
130+
fi
131+
132+
if $(null_var $runGui); then
133+
inputDir="$(get_property $config input.dirPaths)"
134+
metaPath="$(get_property $config metadata.filePath)" && [ ${#metaPath} -gt 0 ] && metaPath="$(dirname $metaPath)"
135+
primerPath="$(get_property $config trimPrimers.filePath)" && [ ${#primerPath} -gt 0 ] && primerPath="$(dirname $primerPath)"
136+
fi
127137
}
128138

129139
# Start the local browswer
@@ -141,12 +151,6 @@ startBrowser() {
141151
fi
142152
}
143153

144-
# Boolean evaluation if single argument passed exists with a non-zero size
145-
# Param 1 - Script arg
146-
var_not_null() {
147-
[ ${#1} -gt 0 ]
148-
}
149-
150154
# Verify host directory exists, if dockblj is not deployed inside a Docker container
151155
# Param 1 - System path
152156
verify_dir() {
@@ -161,24 +165,18 @@ verify_file() {
161165

162166
# Verify paths are valid, if dockblj is not run inside a Docker container
163167
verify_inputs() {
164-
$(var_not_null $inputDir) && dirPath=( ${inputDir//, } )
165-
! $(var_not_null $inputDir) || [ ${#dirPath[@]} -gt 1 ] && exit_script "Error [ dockblj ]: The -i parameter must reference a single input directory"
168+
! $(null_var $inputDir) && dirPath=( ${inputDir//, } )
169+
$(null_var $inputDir) || [ ${#dirPath[@]} -gt 1 ] && exit_script "Error [ dockblj ]: The -i parameter must reference a single input directory"
166170
verify_dir $dirPath
167171
verify_dir $BLJ_PROJ
168-
$(var_not_null $restartDir) && verify_dir $restartDir
169-
$(var_not_null $config) && verify_file $config
170-
$(var_not_null $metaPath) && verify_dir $metaPath
171-
$(var_not_null $primerPath) && verify_file $primerPath
172+
! $(null_var $restartDir) && verify_dir $restartDir
173+
! $(null_var $config) && verify_file $config
174+
! $(null_var $metaPath) && verify_dir $metaPath
175+
! $(null_var $primerPath) && verify_file $primerPath
172176
}
173177

174178
printf "\n ---------> Execute CMD [ dockblj $(echo ${@}) ]\n\n"
175179
scan_script_and_env_args $@
176-
177-
if $(var_not_null $launchGui); then
178-
# Execute run_docker in background to startBrowser
179-
run_docker &
180-
startBrowser
181-
else
182-
verify_inputs
183-
run_docker
184-
fi
180+
$(null_var $runGui) && verify_inputs
181+
run_docker
182+
! $(null_var $runGui) && startBrowser

src/biolockj/module/implicit/ImportMetadata.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,30 @@ protected void buildNewMetadataFile() throws MetadataException {
135135
* @return Formatted Sample ID column name
136136
*/
137137
protected String formatMetaId( final String sampleIdColumnName ) {
138-
String colName = sampleIdColumnName;
139-
final char c = colName.trim().toCharArray()[ 0 ];
138+
String id = sampleIdColumnName;
139+
final char c = id.trim().toCharArray()[ 0 ];
140140
if( c == 65279 ) {
141141
Log.warn( getClass(),
142142
"Removed ZERO WIDTH NO-BREAK invisible character [ASCII 65279] from 1st cell in metadata file. " +
143143
"For more details, see http://www.fileformat.info/info/unicode/char/feff/index.htm" );
144144

145-
final char[] chars = colName.trim().toCharArray();
145+
final char[] chars = id.trim().toCharArray();
146146
for( int i = 0; i < chars.length; i++ )
147147
Log.debug( getClass(), "ID[" + i + "] = " + chars[ i ] );
148148

149-
colName = colName.substring( 1 );
150-
Log.info( getClass(), "Updated ID = " + colName );
149+
id = id.substring( 1 );
150+
Log.info( getClass(), "Updated ID = " + id );
151151
}
152-
return colName;
152+
153+
if( id.endsWith( Constants.FASTA ) || id.endsWith( Constants.FASTQ ) ) {
154+
id = id.substring( 0, id.length() - 6 );
155+
Log.info( getClass(), "Updated ID = " + id );
156+
}
157+
if( id.endsWith( Constants.GZIP_EXT ) ) {
158+
id = id.substring( 0, id.length() - 3 );
159+
Log.info( getClass(), "Updated ID = " + id );
160+
}
161+
return id;
153162
}
154163

155164
/**

0 commit comments

Comments
 (0)