Skip to content

Commit

Permalink
Merge pull request #389 from pangenome/check_installed_tools
Browse files Browse the repository at this point in the history
check installed tools and report issues
  • Loading branch information
AndreaGuarracino committed Apr 9, 2024
2 parents d500639 + 5612519 commit 0dfa42b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
36 changes: 35 additions & 1 deletion partition-before-pggb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,41 @@ if [ "$show_help" == true ]; then
echo
echo "Use wfmash, seqwish, smoothxg, odgi, gfaffix, and vg to build, project and display a pangenome graph."
exit
elif [ "$input_fasta" = "false" ] || [ "$output_dir" = "false" ]; then
fi

# Function to check if a tool is in PATH
check_tool_availability() {
local tool_name=$1
local tool_command=$2

if ! command -v $tool_command &> /dev/null; then
# Instead of exiting immediately, add the tool name to the array of missing tools
missing_tools+=("$tool_name")
fi
}

# Check availability of each tool
check_tool_availability "wfmash" "wfmash"
check_tool_availability "seqwish" "seqwish"
check_tool_availability "smoothxg" "smoothxg"
check_tool_availability "odgi" "odgi"
check_tool_availability "gfaffix" "gfaffix"
check_tool_availability "vg" "vg"
check_tool_availability "vcfbub" "vcfbub"
check_tool_availability "vcfwave" "vcfwave"
check_tool_availability "bcftools" "bcftools"
check_tool_availability "MultiQC" "multiqc"

# If there are missing tools, report them and exit
if [ ${#missing_tools[@]} -ne 0 ]; then
echo "[pggb] ERROR: the following tools are not installed or not in the PATH:"
for tool in "${missing_tools[@]}"; do
echo "- $tool"
done
exit 1
fi

if [ "$input_fasta" = "false" ] || [ "$output_dir" = "false" ]; then
>&2 echo "[pggb] ERROR: mandatory argument: -i/--input-fasta and -o/--output-dir"
exit
elif [ ! -f "${input_fasta}.fai" ]; then
Expand Down
36 changes: 35 additions & 1 deletion pggb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,41 @@ if [ "$show_help" == true ]; then
echo
echo "Use wfmash, seqwish, smoothxg, odgi, gfaffix, and vg to build, project and display a pangenome graph."
exit
elif [ "$input_fasta" = "false" ] || [ "$output_dir" = "false" ]; then
fi

# Function to check if a tool is in PATH
check_tool_availability() {
local tool_name=$1
local tool_command=$2

if ! command -v $tool_command &> /dev/null; then
# Instead of exiting immediately, add the tool name to the array of missing tools
missing_tools+=("$tool_name")
fi
}

# Check availability of each tool
check_tool_availability "wfmash" "wfmash"
check_tool_availability "seqwish" "seqwish"
check_tool_availability "smoothxg" "smoothxg"
check_tool_availability "odgi" "odgi"
check_tool_availability "gfaffix" "gfaffix"
check_tool_availability "vg" "vg"
check_tool_availability "vcfbub" "vcfbub"
check_tool_availability "vcfwave" "vcfwave"
check_tool_availability "bcftools" "bcftools"
check_tool_availability "MultiQC" "multiqc"

# If there are missing tools, report them and exit
if [ ${#missing_tools[@]} -ne 0 ]; then
echo "[pggb] ERROR: the following tools are not installed or not in the PATH:"
for tool in "${missing_tools[@]}"; do
echo "- $tool"
done
exit 1
fi

if [ "$input_fasta" = "false" ] || [ "$output_dir" = "false" ]; then
>&2 echo "[pggb] ERROR: mandatory argument: -i/--input-fasta and -o/--output-dir"
exit
elif [ ! -f "${input_fasta}.fai" ]; then
Expand Down

0 comments on commit 0dfa42b

Please sign in to comment.