#!/bin/bash

# - - - - - - Set environment variables for CPUs - - - - - - -
#BL_CORES_MAX, BL_CORES_DEFAULT allow BioLegato to tell threaded programs such as BLAST
# or FASTA how many cores are available.
# BL_CORES_DEFAULT is set to 1/4 of BL_CORES_MAX, or 1, whichever is greater.
BL_CORES_MAX=`python $BIRCH/script/nproc.py`
BL_CORES_DEFAULT=$((BL_CORES_MAX/4))
if [ "$BL_CORES_DEFAULT" -lt 1 ]; then
    BL_CORES_DEFAULT=1
fi
#echo 'BL_CORES_MAX: '$BL_CORES_MAX
#echo 'BL_CORES_DEFAULT: '$BL_CORES_DEFAULT
export BL_CORES_MAX BL_CORES_DEFAULT

# Remind the user that if paired end files are used, they must be grouped in pairs by
# guesspairs.py. If user clicks on Proceed, then run bl_seqkit_sample.py

case $# in 
    0) 
       echo 'Usage: bl_seqkit_sample.sh arguments...'
       exit
       ;;
    1) 
       :
       ;;
esac


MESSAGE='If using paired-end files, paired-end files must first be grouped using File --> guesspairs.py.'$'\n''Do you wish to proceed?'
PROCEED=`java -jar $BIRCH/script/ConfirmBox2.jar "$MESSAGE"`
if [ $PROCEED == "Yes" ]
then
    bl_seqkit_sample.py $*
else
    MESSAGE='seqkit sample canceled.'
    java -jar $BIRCH/script/OkayBox2.jar "$MESSAGE"
fi
   
