-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_scan
More file actions
executable file
·121 lines (112 loc) · 4.25 KB
/
Copy pathrun_scan
File metadata and controls
executable file
·121 lines (112 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
cwd=`pwd`
if [ -e setenv ]; then source setenv; else ./setenv.sh; source setenv; fi
if [ ! ${1} ] || [ ! ${2} ] || [ ! ${3} ] || [ ! ${4} ] || [ ! ${5} ] || [ ! ${6} ]; then
printf "\n>>> Usage: ./run_scan <drude/c36> <resid> <atom1> <atom2> <atom3> <atom4>\n"
printf "\ne.g. ./run_scan c36 buta c1 c2 c3 c4\n"
printf "\nNeeds psf and crd files named: <resid>.<c36/drude>.psf & <resid>.<c36/drude>.crd\n\n"
exit
fi
mkdir -p output
resid="${2}"
a1="${3}"
a2="${4}"
a3="${5}"
a4="${6}"
mkdir -p output/${resid}_dihe_${a1}_${a2}_${a3}_${a4}
rerun=1
if [ -e output/${resid}_dihe_${a1}_${a2}_${a3}_${a4}/psi4_ready ]; then
printf "\n>>> Psi4 inputs already available! (Press ENTER to continue OR enter any key to re-run)"
read -t 10 rep
if [ $rep ]; then rerun=1; else rerun=0; fi
fi
if [ $rerun == 1 ]; then
cd output/${resid}_dihe_${a1}_${a2}_${a3}_${a4}
cp ../../scripts/0* ./
cp ../../${resid}.${1}.* ./
printf "\n>>> Generating coordinates..."
$CHARMMDIR/charmm -i 01_generate_coordinates.inp method=$1 resid=$resid a1=$a1 a2=$a2 a3=$a3 a4=$a4 > 01_generate_coordinates.out
flag=`tail -n 6 01_generate_coordinates.out | head -n 1 | awk '{print $1}'`
if [ $flag == "ABNORMAL" ]; then
printf " failed! Check 01_generate_coordinates.out for errors! \n"
exit
else
printf " success!\n"
sort -n fort.11 > mm_${resid}_dihe_${a1}_${a2}_${a3}_${a4}.txt
rm fort.11
fi
printf "\n>>> Removing high energy conformations..."
$PYTHONDIR/python 02_process_mme.py $resid $a1 $a2 $a3 $a4 > 02_process_mme.out
if [ -e ${resid}_dihe_${a1}_${a2}_${a3}_${a4}.mme ]; then
printf " success!\n"
else
printf " failed! Check 02_process_mme.out for errors! \n"
exit
fi
printf "\n>>> Generating psi4 inputs...\n "
count=0
for i in *psi4.pdb; do
if [ $count != 5 ]; then printf "${i:2:4}... "; count=$((count+1))
elif [ $count == 5 ]; then printf "${i:2:4}... \n "; count=0; fi
$PYTHONDIR/python 03_get_psi4_input.py $i $a1 $a2 $a3 $a4 > ${i:0:(-4)}.inp
done
printf " Done!\n"
echo "Ready to run psi4" > psi4_ready
else
cd output/${resid}_dihe_${a1}_${a2}_${a3}_${a4}
fi
printf "\n>>> Run psi4 now for all inputs one by one? (Press ENTER to continue OR enter any key to exit)"
read -t 30 rep
if [ $rep ]; then
printf "\n>>> Now exiting...\n"
exit
else
printf "\n>>> Now running psi4 calculations >>>"
echo 0 > status
for i in *psi4.inp; do
printf "\n > ${i:0:(-4)} ..."
if [ ! -e ${i}.dat ]; then
$PSI4DIR/psi4 -i ${i} -o ${i}.dat > /dev/null 2> /dev/null
else
flag=`grep "Final energy is" ${i}.dat | wc -l`
if [ $flag == 0 ]; then
$PSI4DIR/psi4 -i ${i} -o ${i}.dat > /dev/null 2> /dev/null
fi
fi
wait
flag=`grep "Final energy is" ${i}.dat | wc -l`
if [ $flag == 0 ]; then
echo 1 > status
printf " failed!"
elif [ $flag == 1 ]; then
printf " done!"
fi
done
if [ `cat status` == 0 ]; then
printf "\n\n>>> Now extracting qm energies..."
grep "Final energy is" d_*.dat | awk '{split($1,a,"_"); printf "%.2f %f %d\n",a[3],$5*627.5,a[2]}' > ${resid}_dihe_${a1}_${a2}_${a3}_${a4}.qme
printf " done!\n"
printf "\n>>> Now ploting the mm and qm energies..."
$PYTHONDIR/python 04_plot_energy.py $resid $a1 $a2 $a3 $a4 > 04_plot_energy.out 2> 04_plot_energy.out
if [ -e ${resid}_dihe_${a1}_${a2}_${a3}_${a4}.png ]; then
printf " done!\n\n"
printf " ===================================================================================\n"
printf " To view the results open: output/${resid}_dihe_${a1}_${a2}_${a3}_${a4}/${resid}_dihe_${a1}_${a2}_${a3}_${a4}.png\n"
printf " ===================================================================================\n"
xdg-open ${resid}_dihe_${a1}_${a2}_${a3}_${a4}.png > /dev/null 2> /dev/null
else
printf " failed! Check 04_plot_energy.out for errors!\n\n"
exit
fi
fi
cd $cwd
fi
printf "\n>>> Want to make GIF (Press ENTER to continue OR enter any key to exit) : "
read -t 20 rep
if [ $rep ]; then
printf "\n Okay! to make GIF later just run : ./make_gif ${1} $resid $a1 $a2 $a3 $a4 \n"
printf "\n Now exiting... Cheers!\n\n"
else
./make_gif ${1} $resid $a1 $a2 $a3 $a4
fi
exit