From 1ac7a3a21e9255266942575dd16688d7e2580aae Mon Sep 17 00:00:00 2001 From: James Mathews Date: Mon, 23 Sep 2024 17:14:52 -0400 Subject: [PATCH] Commit wrapper --- data_curation/README.md | 2 +- data_curation/import_dataset.sh | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100755 data_curation/import_dataset.sh diff --git a/data_curation/README.md b/data_curation/README.md index 16f7d5bb..8608fd41 100644 --- a/data_curation/README.md +++ b/data_curation/README.md @@ -18,7 +18,7 @@ Make sure that you have installed: - [Nextflow](https://nextflow.io) ```sh -./import_datasets.sh ~/.spt_db.config.local --drop-first moldoveanu +./import_dataset.sh ~/.spt_db.config.local --drop-first moldoveanu ``` - `~/.spt_db.config.local` is an example name of a [database configuration file](https://github.com/nadeemlab/SPT/blob/main/spatialprofilingtoolbox/workflow/assets/.spt_db.config.template). diff --git a/data_curation/import_dataset.sh b/data_curation/import_dataset.sh new file mode 100755 index 00000000..45d121a7 --- /dev/null +++ b/data_curation/import_dataset.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +source convenience_scripts/verifications_and_configurations.sh +source convenience_scripts/import_functions.sh + +dbconfigargument=$1 +dbconfig=$(handle_dbconfig_argument $dbconfigargument) + +drop_first=$( if [[ "$2" == "--drop-first" ]]; then echo "yes"; else echo "no" ; fi; ) + +one_inclusion="$3" + +available_datasets=$(get_available_dataset_handles) +configured_datasets=$(get_configured_run_handles) +if [[ ! "$available_datasets" == "$configured_datasets" ]]; +then + bash convenience_scripts/configure_all_imports.sh "$dbconfigargument" "$one_inclusion" + var=$? + if [ $var -ne 0 ]; + then + echo "Configuration had some error. $var" + exit 1 + fi +fi + +SECONDS=0 +if [[ "$one_inclusion" == "" ]]; +then + configured_datasets=$(get_configured_run_handles) +else + configured_datasets=$(get_configured_run_handles | grep -o "$one_inclusion") +fi +echo "Will import from configured run directories:" +echo "$configured_datasets" | sed 's/ /\n /g' +echo "Command: import_datasets '$configured_datasets' $PWD $drop_first $dbconfig" +import_datasets "$configured_datasets" "$PWD" "$drop_first" "$dbconfig" +echo "Dataset import took $SECONDS seconds ("$(( SECONDS / 60 ))" minutes)."