Skip to content

Commit

Permalink
dirname: missing operand error in SCXA loading due to undefined $BASH…
Browse files Browse the repository at this point in the history
…_SOURCE (#68)

* Update load_db_scxa_dimred.sh

* using ${BASH_SOURCE:-$0}  to avoid cases where BASH_SOURCE is not defined

* edit SCRATCH_DIR in bin/load_db_scxa_dimred.sh

* Related to PR #66
  • Loading branch information
pmb59 authored Oct 10, 2023
1 parent 699b74e commit 6326500
Show file tree
Hide file tree
Showing 18 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion bin/add_exps_to_collection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/db_scxa_common.sh

dbConnection=${dbConnection:-$1}
Expand Down
2 changes: 1 addition & 1 deletion bin/create_collection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/db_scxa_common.sh

dbConnection=${dbConnection:-$1}
Expand Down
2 changes: 1 addition & 1 deletion bin/delete_collection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/db_scxa_common.sh

dbConnection=${dbConnection:-$1}
Expand Down
2 changes: 1 addition & 1 deletion bin/delete_exp_from_collection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/db_scxa_common.sh

dbConnection=${dbConnection:-$1}
Expand Down
2 changes: 1 addition & 1 deletion bin/get_experiment_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/db_scxa_common.sh

postgres_scripts_dir=$scriptDir/../postgres_routines
Expand Down
2 changes: 1 addition & 1 deletion bin/load_db_scxa_analytics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# - Postprocess table and attach it to the main scxa-analytics table.
set -e

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/db_scxa_common.sh

postgres_scripts_dir=$scriptDir/../postgres_routines
Expand Down
2 changes: 1 addition & 1 deletion bin/load_db_scxa_analytics_pg9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# PG10, which loads each experiment into a different partition.
set -e

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/db_scxa_common.sh

dbConnection=${dbConnection:-$1}
Expand Down
2 changes: 1 addition & 1 deletion bin/load_db_scxa_cell_clusters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# scxa_cell_group_membership table of AtlasProd.
set -e

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/db_scxa_common.sh

dbConnection=${dbConnection:-$1}
Expand Down
5 changes: 3 additions & 2 deletions bin/load_db_scxa_dimred.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
# parameterisations, and loads it into the scxa_coords table of AtlasProd.
set -e

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/db_scxa_common.sh

dbConnection=${dbConnection:-$1}
EXP_ID=${EXP_ID:-$2}
DIMRED_TYPE=${DIMRED_TYPE:-$3}
DIMRED_FILE_PATH=${DIMRED_FILE_PATH:-$4}
DIMRED_PARAM_JSON=${DIMRED_PARAM_JSON:-$5}
SCRATCH_DIR=${SCRATCH_DIR:-"$(dirname ${DIMRED_FILE_PATH})"}
#SCRATCH_DIR=${SCRATCH_DIR:-"$(dirname ${DIMRED_FILE_PATH})"}
SCRATCH_DIR=${SCRATCH_DIR:-"$DIMRED_FILE_PATH"}

# Check that necessary environment variables are defined.
[ -n ${dbConnection+x} ] || (echo "Env var dbConnection for the database connection needs to be defined. This includes the database name." && exit 1)
Expand Down
2 changes: 1 addition & 1 deletion bin/load_db_scxa_marker_genes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# scxa_cell_groups_marker_genes table of AtlasProd.
set -e

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/db_scxa_common.sh

dbConnection=${dbConnection:-$1}
Expand Down
2 changes: 1 addition & 1 deletion bin/load_exp_design.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

scriptDir=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
scriptDir=$(cd "$( dirname "${BASH_SOURCE[0]:-$0}" )" && pwd )
source $scriptDir/db_scxa_common.sh

dbConnection=${dbConnection:-$1}
Expand Down
2 changes: 1 addition & 1 deletion bin/load_experiment_web_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

jar_dir=$CONDA_PREFIX/share/atlas-cli

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/common_routines.sh

echo "CONDA_PREFIX: $CONDA_PREFIX"
Expand Down
2 changes: 1 addition & 1 deletion bin/modify_collection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/db_scxa_common.sh

dbConnection=${dbConnection:-$1}
Expand Down
2 changes: 1 addition & 1 deletion bin/update_experiment_web_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

jar_dir=$CONDA_PREFIX/share/atlas-cli

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
source $scriptDir/common_routines.sh

echo "CONDA_PREFIX: $CONDA_PREFIX"
Expand Down
2 changes: 1 addition & 1 deletion fixtures/generate-fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# https://stackoverflow.com/questions/59895/how-can-i-get-the-source-directory-of-a-bash-script-from-within-the-script-itsel
# https://stackoverflow.com/a/246128
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )"

export POSTGRES_HOST=${POSTGRES_HOST:-localhost}
export POSTGRES_PORT=${POSTGRES_PORT:-5432}
Expand Down
2 changes: 1 addition & 1 deletion fixtures/generate-tsv-fixture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# We choose 100 genes that are expressed in those cells via analytics table

set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )"

source ${SCRIPT_DIR}/utils.sh

Expand Down
4 changes: 2 additions & 2 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
scriptDir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}" )" &> /dev/null && pwd )
export testsDir=$scriptDir
export PATH=$scriptDir/../bin:$scriptDir/../tests:$PATH

Expand Down Expand Up @@ -29,7 +29,7 @@ chmod -R a+w /tmp/fixtures/experiment_files/expdesign


if [ "$#" -eq 0 ]; then
bats --tap "$(dirname "${BASH_SOURCE[0]}")"
bats --tap "$(dirname "${BASH_SOURCE[0]:-$0}")"
else
bats random-data-set.bats
fi
4 changes: 2 additions & 2 deletions tests/test_dimred_load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ delete_db_scxa_dimred.sh
# do it just for testing

ls ${EXPERIMENT_DIMRED_PATH}/${EXP_ID}.tsne*.tsv | while read -r l; do
export DIMRED_TYPE=tsne
export DIMRED_TYPE=t-SNE
export DIMRED_FILE_PATH=$l
paramval=$(echo "$l" | sed 's/.*[^0-9]\([0-9]*\).tsv/\1/g')
export DIMRED_PARAM_JSON='[{"perplexity": '$paramval'}]'
load_db_scxa_dimred.sh
done

ls ${EXPERIMENT_DIMRED_PATH}/${EXP_ID}.umap*.tsv | while read -r l; do
export DIMRED_TYPE=umap
export DIMRED_TYPE=UMAP
export DIMRED_FILE_PATH=$l
paramval=$(echo "$l" | sed 's/.*[^0-9]\([0-9]*\).tsv/\1/g')
export DIMRED_PARAM_JSON='[{"n_neighbors": '$paramval'}]'
Expand Down

0 comments on commit 6326500

Please sign in to comment.