polish: use check function to check instead of setting help, check argc

This commit is contained in:
kuoi 2024-07-03 17:32:19 +10:00
parent 01729e0726
commit c0ea2c4318

View file

@ -41,10 +41,18 @@ show_help(){
-m\t--memory\tmemory settings (optional, default 16 GB)\n \
-r\t--reference\treference genome path\n \
-t\t--threads\tthreads setting (optional, default 8 threads)\n \
\t--macse\t\tMacse jarfile path\n \
\t--sortdiamond\tsortdiamond file path\n \
\t--splitfasta\tsplitfasta file path\n \
for example: bash $0 -c scaffolds -f all -l list -g genes \ \n \
\t -r Reference.exons.aa.fas \n"
}
if [ $# -eq 0 ]; then
show_help
exit 1
else
ARGS=$(getopt -o c:,f:,g:,h,l:,m:,r:,t: --long contigs:,genes:,functions:,help,list:,memory:,reference:,threads:,macse:,sortdiamond:,splitfasta: -n 'RGBEPP.sh' -- "$@")
if [ $? != 0 ]; then
echo "Failed to parse options." >&2
@ -71,7 +79,6 @@ while true; do
esac ;;
-h|--help)
show_help
HELP=true;
shift ;;
-l|--list)
case "$2" in
@ -109,8 +116,6 @@ while true; do
*) PathSplitfsata=$2; shift 2 ;;
esac ;;
--)
show_help
HELP=true
shift; break ;;
*) echo "Unknown option: $1"
exit 1
@ -118,6 +123,8 @@ while true; do
esac
done
fi
### Get and check some arguments
check_var() {
@ -139,6 +146,13 @@ check_var() {
readarray -t full_names < "$var_value"
length_fn=${#full_names[@]}
;;
"ARG_F")
check_command "cp"
check_command "cd"
check_command "mv"
check_command "find"
check_command "mkdir"
;;
esac
fi
@ -170,13 +184,6 @@ check_command() {
fi
}
if [ "$HELP" = false ]; then
check_command "cp"
check_command "cd"
check_command "mv"
check_command "find"
check_command "mkdir"
fi
### Quality control && Trimming