Skip to content

Commit 29ac2e3

Browse files
author
eeko-kon
committed
fix arguments
1 parent e7a46e2 commit 29ac2e3

File tree

3 files changed

+44
-33
lines changed

3 files changed

+44
-33
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is a collection of scripts to install [umetaflow](https://github.com/biosus
44
## Usage
55
- Get the latest release of the script
66
```bash
7-
SCRIPT_VERSION="0.1.4"
7+
SCRIPT_VERSION="0.1.5"
88
wget -O setup_scripts.zip https://github.com/NBChub/umetaflow_tutorial/archive/refs/tags/$SCRIPT_VERSION.zip
99
unzip setup_scripts.zip && mv umetaflow_tutorial-$SCRIPT_VERSION/ setup_scripts
1010
```

download_models.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ default_folder="resources/ms2query"
55

66
# Help function
77
function display_help {
8-
echo "Usage: script.sh [folder]"
8+
echo "Usage: script.sh [options]"
99
echo "Download resources required for running umetaflow."
1010
echo ""
11-
echo "Arguments:"
12-
echo "folder: (Optional) The folder where the files will be downloaded. Default: $default_folder"
13-
echo "ion_mode: (Optional) The ionization mode of the data ("positive" or "negative"). Default: $default_mode"
14-
echo "MY_OS: (Optional) The operating system that is used ("osx64" for macOS and "linux64" for linux). Default: $default_OS"
11+
echo "Options:"
12+
echo "-f, --folder <folder> (Optional) The folder where the files will be downloaded. Default: $default_folder"
13+
echo "-m, --ion_mode <ion_mode> (Optional) The ionization mode of the data ('positive' or 'negative'). Default: $default_mode"
14+
echo "-o, --MY_OS <MY_OS> (Optional) The operating system that is used ('osx64' for macOS and 'linux64' for Linux). Default: $default_MY_OS"
1515
echo ""
1616
}
1717

setup.sh

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,49 @@ default_OS="linux64"
77

88
# Help function
99
function display_help {
10-
echo "Usage: script.sh [folder]"
10+
echo "Usage: script.sh [options]"
1111
echo "Download resources required for running umetaflow."
1212
echo ""
13-
echo "Arguments:"
14-
echo "folder: (Optional) The folder where the files will be downloaded. Default: $default_folder"
15-
echo "ion_mode: (Optional) The ionization mode of the data ("positive" or "negative"). Default: $default_mode"
16-
echo "MY_OS: (Optional) The operating system that is used ("osx64" for macOS and "linux64" for linux). Default: $default_OS"
13+
echo "Options:"
14+
echo "-f, --folder <folder> (Optional) The folder where the files will be downloaded. Default: $default_folder"
15+
echo "-m, --ion_mode <ion_mode> (Optional) The ionization mode of the data ('positive' or 'negative'). Default: $default_mode"
16+
echo "-o, --MY_OS <MY_OS> (Optional) The operating system that is used ('osx64' for macOS and 'linux64' for Linux). Default: $default_MY_OS"
1717
echo ""
1818
}
1919

20-
# Check if help option is provided
21-
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
22-
display_help
23-
exit 0
24-
fi
25-
26-
# Specify the folder where the files will be downloaded
27-
folder=${1:-$default_folder}
28-
29-
# Specify the ion mode
30-
ion_mode=${1:-$default_mode}
31-
32-
# Specify the operating system
33-
MY_OS=${1:-$default_OS}
34-
35-
# get the SIRIUS executable
36-
(cd ${default_folder} && curl -s https://api.github.com/repos/boecker-lab/sirius/releases/latest | tr -d '"' | grep "browser_download_url.*${MY_OS}.zip$"| cut -d : -f 2,3 | wget -i- && unzip *.zip)
37-
38-
# get the ThermoRawFileParser executable
39-
(mkdir ${default_folder}/ThermoRawFileParser && cd ${default_folder}/ThermoRawFileParser && wget https://github.com/compomics/ThermoRawFileParser/releases/download/v1.3.4/ThermoRawFileParser.zip && unzip ThermoRawFileParser.zip)
20+
# Default option values
21+
folder=$default_folder
22+
ion_mode=$default_mode
23+
MY_OS=$default_MY_OS
24+
25+
# Parse command-line options
26+
while getopts ":f:m:o:-:" opt; do
27+
case $opt in
28+
f) folder=$OPTARG ;;
29+
m) ion_mode=$OPTARG ;;
30+
o) MY_OS=$OPTARG ;;
31+
-)
32+
case $OPTARG in
33+
folder) folder="${!OPTIND}" ;;
34+
ion_mode) ion_mode="${!OPTIND}" ;;
35+
MY_OS) MY_OS="${!OPTIND}" ;;
36+
help) display_help; exit 0 ;;
37+
*) echo "Invalid option: --$OPTARG"; exit 1 ;;
38+
esac
39+
OPTIND=$((OPTIND + 1))
40+
;;
41+
\?) echo "Invalid option: -$OPTARG"; exit 1 ;;
42+
:) echo "Option -$OPTARG requires an argument."; exit 1 ;;
43+
esac
44+
done
45+
46+
# Get the SIRIUS executable
47+
(cd "$folder" && curl -s "https://api.github.com/repos/boecker-lab/sirius/releases/latest" | tr -d '"' | grep "browser_download_url.*${MY_OS}.zip$" | cut -d : -f 2,3 | wget -i- && unzip *.zip)
48+
49+
# Get the ThermoRawFileParser executable
50+
(mkdir -p "$folder/ThermoRawFileParser" && cd "$folder/ThermoRawFileParser" && wget "https://github.com/compomics/ThermoRawFileParser/releases/download/v1.3.4/ThermoRawFileParser.zip" && unzip ThermoRawFileParser.zip)
4051

4152
# Get the directory of the current script
4253
script_directory=$(dirname "$0")
43-
echo $script_directory
44-
bash $script_directory/download_models.sh $script_directory/zenodo_${default_mode}.txt
54+
echo "$script_directory"
55+
bash "$script_directory/download_models.sh" "$script_directory/zenodo_${ion_mode}.txt"

0 commit comments

Comments
 (0)