bash - 在 Bash 中模拟 Gromacs 中的用户交互

标签 bash ubuntu input expect send

我目前正在 GROMACS 4.6.5 中进行并行级联模拟,并且正在使用 bash 脚本输入命令:

#!/bin/bash
pdb2gmx -f step_04_01.pdb -o step_04_01.gro -water none -ff amber99sb -ignh
grompp -f minim.mdp -c step_04_01.gro -p topol.top -o em.tpr
mdrun -v -deffnm em
grompp -f nvt.mdp -c em.gro -p topol.top -o nvt.tpr
mdrun -v -deffnm nvt
grompp -f md.mdp -c nvt.gro -t nvt.cpt -p topol.top -o step_04_01.tpr
mdrun -v -deffnm step_04_01
trjconv -s step_04_01.tpr -f step_04_01.xtc -pbc mol -o step_04_01_pbc.xtc
g_rms -s itasser_2znh.tpr -f step_04_01_pbc.xtc -o step_04_01_rmsd.xvg
trjconv 等命令和 g_rms需要用户交互来选择选项。例如在运行 trjconv 时给你:
Select group for output
Group     0 (         System) has  6241 elements
Group     1 (        Protein) has  6241 elements
Group     2 (      Protein-H) has  3126 elements
Group     3 (        C-alpha) has   394 elements
Group     4 (       Backbone) has  1182 elements
Group     5 (      MainChain) has  1577 elements
Group     6 (   MainChain+Cb) has  1949 elements
Group     7 (    MainChain+H) has  1956 elements
Group     8 (      SideChain) has  4285 elements
Group     9 (    SideChain-H) has  1549 elements
Select a group:

并且用户应该输入例如。 0进入终端选择Group 0 .我试过使用 expectsend ,例如:
trjconv -s step_04_01.tpr -f step_04_01.xtc -pbc mol -o step_04_01_pbc.xtc
expect "Select group: "
send "0"

但是,这不起作用。我也尝试过使用 -flag喜欢 http://www.gromacs.org/Documentation/How-tos/Using_Commands_in_Scripts#Within_Script但它说它不是一个公认的输入。

是我的expect\send格式正确?在 GROMACS 中还有其他方法吗?

最佳答案

我不知道 gromacs 但我认为他们只是要求您使用 bash 语法:

yourcomand ... <<EOF
1st answer to a question
2nd answer to a question
EOF

所以你可能有
trjconv -s step_04_01.tpr -f step_04_01.xtc -pbc mol -o step_04_01_pbc.xtc <<EOF
0
EOF

关于bash - 在 Bash 中模拟 Gromacs 中的用户交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45885541/

相关文章:

c++ - 没有 TTY 的 Exelp 调用 bash

linux - 错误捕获 scp 退出代码不起作用

python - 在pycharm中如何解决(*** Mininet必须以root身份运行。)?

CSS:输入充当跨度(webkit)

python - 为什么输入永无止境

c - 为什么 execvp() 使用 fork() 执行两次?

linux - bash 中的 if else 条件循环

android项目没有建立

ubuntu - AWK - 我的正则表达式不尊重大小写

javascript - 如何将文本从 html 输入推送到 AngularJS 数组?