0

I am attempting to create a variable 'a' that takes the first and only line of a file containing three coordinates with commas between each, as a line. Then, I am trying to call this variable to set is as an input to run a second program. I am attempting to do this from the same script, as follows.

a=$(cut -f 2 aver.line.comma.dat)
$MGLROOT/bin/pythonsh ~/Downloads/autodockZN_filesAndTutorial/prepare_gpf4zn.py -l ligand.pdbqt -r protein_tz.pdbqt  -o protein_tz.gpf -p npts=500,500,500 -p gridcenter=echo "$a"  -p parameter_file=AD4Zn.dat

I have all the needed input files. I want to make sure gridcenter will be equal to this variable a.

my variable a looks as follows:

95.8916,53.8569,28.052

Does someone know a way of achieving this? I tried to set gridcenter=$a, and gridcenter=(echo $a) with no luck.

Thank you!

1 Answer 1

4

You don't need to "call" or "execute" a variable. To use it, just expand it:

... -p gridcenter="$a" ...

Side note: when you have loads of arguments, it can aid readability to store them in an array

prepare="$HOME"/Downloads/autodockZN_filesAndTutorial/prepare_gpf4zn.py
args=(
    -l ligand.pdbqt
    -r protein_tz.pdbqt 
    -o protein_tz.gpf
    -p npts=500,500,500
    -p gridcenter="$(cut -f 2 aver.line.comma.dat)" 
    -p parameter_file=AD4Zn.dat
}
"$MGLROOT"/bin/pythonsh "$prepare" "${args[@]}"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.