#! /bin/bash

if [ $# -eq 0 ]; then
    echo "Script to dock arginine, histidine, and lysine to 6XTV and 6XTV_A219L with Autodock Vina"
    echo "Requires a working Autodock Vina installation."
    echo "Must be run for each ligand/receptor combo separately."
    echo -e "Originally performed with Autodock Vina 1.1.2\n"
    echo -e "Usage:"
    echo "[-l path]: Path to ligand in pdbqt format"
    echo "[-r receptorPath]: Path to receptor in pdbqt format"
    exit
else
    #get user input for the receptor and ligand
    IFS=' ' read -r -a allArgs <<< "$@"
    for ((idx=0; idx<$#; idx++)); do
        if [ ${allArgs[${idx}]} == "-l" ]; then
            ligandPath=${allArgs[$(($idx+1))]}
        elif [ ${allArgs[${idx}]} == "-r" ]; then
            receptorPath=${allArgs[$(($idx+1))]}
        fi
    done
fi
    

ligBase=$(basename $ligandPath .pdbqt)
recBase=$(basename $receptorPath .pdbqt)


#run the vina command 10 times for 200 poses
for x in {1..10}
do
    echo Processing ligand $ligBase
    vina --config vina_config --ligand ${ligandPath} --receptor ${receptorPath} --out ${recBase}_${ligBase}_${x}.out
done

