Skip to content

Commit

Permalink
Last update for soibean
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaavogel committed Apr 10, 2024
1 parent e67d85d commit f38e87a
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 61 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ soibean is a tool crafted for identifying and placing ancient environmental DNA
For fastq mapped to the taxon of bears (Ursidae):
```
wget https://github.com/grenaud/vgan/raw/main/test/input_files/soibean/k1.fq.gz
cd $HOME/vgan/share/vgan/soibean_dir/tree_dir
unzip trees.zip
./make_graph_files.sh taxa
./make_graph_files.sh Ursidae
vgan soibean -fq1 k1.fq.gz --dbprefix Ursidae -t 20
Expand Down
130 changes: 69 additions & 61 deletions share/vgan/soibean_dir/make_graph_files.sh
Original file line number Diff line number Diff line change
@@ -1,92 +1,100 @@
#!/bin/bash

# Function to display help message
# Function to show help
show_help() {
echo "Usage: $0 [options] <input_name>"
echo "Usage: $0 <taxon_name> [options]"
echo ""
echo "Options:"
echo " -h, --help Show this help message and exit."
echo " --vg-path <path> Explicitly specify the path to the VG executable."
echo " taxa Overview of all available taxa in the soibean database."
echo ""
echo "Arguments:"
echo " input_name Taxon of interest. This taxon will be extracted from the soibean database."
echo "First argument must be the taxon name."
echo "Then, options can be specified."
echo ""
echo "Examples:"
echo " $0 taxa Provides a list of all available taxa in the soibean database"
echo " $0 taxon_name --vg-path /path/to/vg Extracts the taxon of interest from the soibean database and creates all index files needed for soibean."
echo "Options:"
echo " -h, --help Show this help message"
echo " --vg-path <path> Specify the VG executable path (optional)"
echo ""
echo "Example:"
echo "$0 Ursidae --vg-path /usr/local/bin/"
}

# Set the script's working directory to $HOME/vgan/share/vgan/soibean_dir/
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"


# No arguments, show help
if [ $# -eq 0 ]; then
show_help
exit 0
fi

# Check for help option
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
show_help
exit 0
fi

# Initialize VG_EXECUTABLE_PATH variable
VG_EXECUTABLE_PATH=""

# Parse options
while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do case $1 in
--vg-path )
shift
# Check if the path ends with "vg" or "/", and adjust accordingly
if [[ "${1}" == */vg ]]; then
VG_EXECUTABLE_PATH="${1}"
elif [[ "${1}" == */ ]]; then
VG_EXECUTABLE_PATH="${1}vg"
else
VG_EXECUTABLE_PATH="${1}/vg"
fi
;;
* )
show_help
exit 1
;;
esac; shift; done
if [[ "$1" == '--' ]]; then shift; fi


input_name=$1

# Function to check for vg binary or download it
find_or_download_vg_binary() {
# If a VG path is specified, check if 'vg' exists there.
if [[ -n "$VG_EXECUTABLE_PATH" ]]; then
# Append "/vg" if the path does not end with it, assuming it's a directory.
if [[ ! "$VG_EXECUTABLE_PATH" =~ vg$ ]]; then
VG_EXECUTABLE_PATH="${VG_EXECUTABLE_PATH}/vg"
fi
# Check if the vg binary exists and is executable.
if [[ ! -x "$VG_EXECUTABLE_PATH" ]]; then
# VG path specified but executable not found, download it
echo "VG executable not found at $VG_EXECUTABLE_PATH. Downloading..."
# Download directly to the specified path (considering VG_EXECUTABLE_PATH includes '/vg').
wget -O "$VG_EXECUTABLE_PATH" https://github.com/vgteam/vg/releases/download/v1.44.0/vg
chmod +x "$VG_EXECUTABLE_PATH"
echo "VG executable downloaded to: $VG_EXECUTABLE_PATH"
else
echo "Using specified VG executable path: $VG_EXECUTABLE_PATH"
echo "Using VG executable found at $VG_EXECUTABLE_PATH"
fi
else
# No VG path specified, check the current working directory.
if [[ -x "./vg" ]]; then
VG_EXECUTABLE_PATH="./vg"
echo "Using VG executable found in the current directory."
else
echo "VG executable not found in the current directory. Downloading..."
VG_EXECUTABLE_PATH="./vg"
wget -O "$VG_EXECUTABLE_PATH" https://github.com/vgteam/vg/releases/download/v1.44.0/vg
chmod +x "$VG_EXECUTABLE_PATH"
echo "VG executable downloaded to the current directory."
fi
return 0
fi

# VG path not specified, search for it
# (You can add default search locations and logic here)
}

# Call find_or_download_vg_binary to handle VG executable path logic

# Check for help option
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
show_help
exit 0
fi

input_name="$1" # The first argument is always the input/taxa name.
shift # Remove the first argument so we can process the rest.

# Initialize VG_EXECUTABLE_PATH variable with an empty value indicating not set.
VG_EXECUTABLE_PATH=""

# Now process the rest of the arguments for options.
while [[ "$1" =~ ^- ]]; do
case "$1" in
--vg-path)
shift # Move past the option to get its value.
VG_EXECUTABLE_PATH="$1"
# Ensure the path ends with "vg" or is a directory.
if [[ ! "$VG_EXECUTABLE_PATH" == */vg && ! -d "$VG_EXECUTABLE_PATH" ]]; then
VG_EXECUTABLE_PATH="$VG_EXECUTABLE_PATH/vg"
fi
;;
*)
show_help
exit 1
;;
esac
shift # Move to the next option.
done

# Call the function to check for the VG executable or download it.
find_or_download_vg_binary

echo "Processing input name: $input_name"

SCRIPT_DIR=$(readlink -f "$(dirname "$0")")


CLADE_FILE="${SCRIPT_DIR}/soibean_db.clade"
# Check for the soibean_db.clade file, download if not exists
if [ ! -f "$CLADE_FILE" ]; then
echo "soibean_db.clade file not found. Downloading..."
wget -nc --recursive --no-parent -P "${SCRIPT_DIR}" ftp://ftp.healthtech.dtu.dk:/public/soibean_files/soibean_db.clade
mv ftp.healthtech.dtu.dk/public/soibean_files/soibean_db.clade ${SCRIPT_DIR}
rm -r ftp.healthtech.dtu.dk/public/soibean_files/
else
echo ""
fi
Expand Down
1 change: 1 addition & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ eukafiles eukafilesmade: vgmade
mv -fv ../share/vgan/ftp.healthtech.dtu.dk/public/euka_files/* ../share/vgan/euka_dir && rm -rf ../share/ftp.healthtech.dtu.dk && touch eukafilesmade

soibeanfiles soibeanfilesmade: vgmade
rm -rf ../share/vgan/soibean_dir/tree_dir
wget -nc -l0 --recursive --no-parent -P ../share/vgan/ ftp://ftp.healthtech.dtu.dk:/public/soibean_files/ && \
mv -fv ../share/vgan/ftp.healthtech.dtu.dk/public/soibean_files/* ../share/vgan/soibean_dir && rm -rf ../share/vgan/ftp.healthtech.dtu.dk && touch soibeanfilesmade

Expand Down

0 comments on commit f38e87a

Please sign in to comment.