Sunday, May 25, 2014

Bash script for calculationg binding energy with APBS

Spending over two days just to figure out how to extract the energy binding build from many PQR files and take a sum of them. Arggg, Bash is so harsh to work out. After I finish my dissertation, I won't use it for heavy scripting again.

I have a protein files (3B7V) and need to find the binding energy between it's two chains. I build PQR files for each then calculate their energy. Minus them to the total energy we get the binding energy.

Here my script in Bash.
#!/bin/bash
rm Energy.txt
cd APBS
for i in A B 3B7V
do
  cd $i
  E=$(sed -n '/Global/p' log$i | awk '{print $6}')
  Erray=$(python -c "print float('$E')")
  echo $i = $Erray kJ/mol$'\n' >> ../../Energy.txt
  A[j]=$Erray;
  let j=j+1
  cd .. #at APBS folder
done
cd ..
Esum=`echo "${A[2]} - ${A[1]} - ${A[0]}" | bc`
echo Energy binding$'\n'$Esum >> Energy.txt
cat Energy.txt
Turn back in 5 minutes. I don't think posting this blog is sooooooooooooooooo smart. I just, oops, delete my script. LOL

2 comments: