|
本帖最后由 zsu007 于 2016-5-9 19:17 编辑
我的工作中需要将ZINC文件分割,形成g09计算用的gjf文件,最后提交到超算中心进行批量计算。自己亲测在红帽和Ubuntu中可以使用。通过论坛学习了很多东西,希望这个自己编写的shell脚本能够使得大家提高工作效率。
理解了本脚本,又有一定的shell编程经验的人可以在此基础上进行修改来适合自己的工作和习惯。
Have a fun!
————————————————
mol2pbs.sh
#!/bin/bash
dos2unix -q *.mol2
declare -i m
declare -i l
declare -i j
declare -i start
declare -i end
for inf in *.mol2
do
grep -n '@<TRIPOS>MOLECULE' ${inf} |cut -d ":" -f 1 > ${inf%.mol2}.tmp
cat ${inf} |wc -l >> ${inf%.mol2}.tmp
cat ${inf%.mol2}.tmp |tr "\n" ' ' > ${inf}.dat
mv ${inf}.dat ${inf%.mol2}.tmp
read -a SHELLS < ${inf%.mol2}.tmp
m=$(grep -c '@<TRIPOS>MOLECULE' ${inf})
for (( j=0;j<$m;j++))
do
l=${SHELLS[j]}+1
filename=$(echo "${inf%.mol2}""$j")
start=${SHELLS[j]}
end=${SHELLS[j+1]}-1
cat ${inf} |sed -n ''$start','$end' p' > ${filename}.dat
done
done
for inf in *.dat
do
start=$(grep -n '@<TRIPOS>ATOM' ${inf} |cut -d ":" -f 1)+1
end=$(grep -n '@<TRIPOS>BOND' ${inf} |cut -d ":" -f 1)-1
cat ${inf} |sed -n ''$start','$end' p'|awk '{print $2"\t"$3"\t"$4"\t"$5}' > ${inf%.dat}.xyz
done
for inf in *.xyz
do
cat ~/sh/opt.gjf > ${inf%.xyz}.dat
cat ${inf} >> ${inf%.xyz}.dat
cat ~/sh/ecd.gjf >> ${inf%.xyz}.dat
cat ${inf%.xyz}.dat |sed "s/xxx/${inf%.xyz}/g" > ${inf%.xyz}.gjf
done
for inf in *.gjf
do
cat ~/sh/g09pbs.sh | sed "s/xxx/${inf%.gjf}/g" > ${inf%.gjf}.pbs
done
for inf in *.pbs
do
qsub ${inf}
done
——————————————————————————————————————————————
说明:
0 假设用户已经设置好g09的.bashrc,安装了bashshell、sed、awk等。
1 cat ~/sh/opt.gjf > ${inf%.xyz}.dat
2 cat ~/sh/ecd.gjf >> ${inf%.xyz}.dat
3 cat ~/sh/g09pbs.sh | sed "s/xxx/${inf%.gjf}/g" > ${inf%.gjf}.pbs
_________________________________
opt.gjf
%nprocshared=8
%mem=4gb
%chk=xxx.chk
# pm6 opt test
LCY-OptFreqECD-PCM-MO
0 1
--------------------------------------------------
ecd.gjf
--link1--
%nprocshared=8
%mem=4gb
%chk=xxx.chk
# b3lyp/6-31g** opt scrf(solvent=methanol) geom=allcheck
guess=read test
--link1--
%nprocshared=4
%mem=4gb
%chk=xxx.chk
# pbe1pbe/6-311g** td(singlets,nstates=100) scrf(solvent=methanol)
geom=allcheck guess=read scf(novaracc) test
--link1--
%nprocshared=4
%mem=4gb
%chk=xxx.chk
# b3lyp/6-31g** freq scrf(solvent=methanol) geom=allcheck
guess=read test
-----------------------------------------------
g09pbs.sh
#!/bin/bash
#PBS -S /bin/bash
#PBS -N g09
#PBS -j oe
#PBS -q Acb85
#pbs -l nodes=1:ppn=4
INPUT=xxx.gjf
OUTPUT=xxx.out
export g09root=/public/users/hg_chy
source $g09root/g09/bsd/g09.profile
export GAUSS_SCRDIR=/checkpoints/home/hg_chy/"$PBS_JOBNAME"."$PBS_JOBID"
[ -d $GAUSS_SCRDIR ] || mkdir -p $GAUSS_SCRDIR
cd $PBS_O_WORKDIR
g09 <"$INPUT" > $OUTPUT
rm -rf /checkpoints/home/hg_chy/"$PBS_JOBNAME"."$PBS_JOBID"
# end g09pbs.sh
-------------------------------------------------------------------------------
|
-
-
myg09sh.zip
1.33 KB, 阅读权限: 30, 下载次数 Times of downloads: 7
以上文件压缩
评分 Rate
-
查看全部评分 View all ratings
|