You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用PyMOL测量多态核酸中指定原子间距离并导出结果

用PyMOL测量MD轨迹中特定原子的帧间距离并导出结果

方法一:PyMOL命令行/GUI交互式操作

适合快速验证或少量分析场景:

  1. 加载轨迹文件
    在PyMOL命令行输入:

    load your_trajectory.pdb, traj
    

    (如果是拆分的多帧PDB文件,用load frame_*.pdb, traj, state=1批量加载)

  2. 精准选中目标原子
    根据核酸分子的残基号和原子名定义选择,比如测量残基10的磷原子(P)和残基25的O3'原子:

    select atom1, traj and resi 10 and name P
    select atom2, traj and resi 25 and name O3'
    

    可通过show spheres, atom1+atom2确认选中原子是否正确,避免多选。

  3. 计算并导出每帧距离
    打开日志文件记录结果,遍历所有帧计算距离:

    log_open distance_results.txt
    for s in 1..cmd.count_states("traj"):
        dist = cmd.get_distance("atom1", "atom2", state=s)
        print(f"Frame {s}: {dist:.2f} Å")
    log_close
    

    执行后,distance_results.txt会保存每帧的距离数据。

方法二:PyMOL脚本自动化处理

适合批量分析或重复任务,步骤如下:

  1. 编写PML脚本
    创建measure_distances.pml文件,内容如下:

    # 加载轨迹
    load your_trajectory.pdb, traj
    
    # 定义目标原子(替换为你的实际残基号和原子名)
    select atom1, traj and resi 10 and name P
    select atom2, traj and resi 25 and name O3'
    
    # 打开CSV输出文件
    out_file = open("distance_data.csv", "w")
    out_file.write("Frame,Distance(Å)\n")
    
    # 遍历所有状态(帧)
    total_frames = cmd.count_states("traj")
    for frame in range(1, total_frames + 1):
        current_dist = cmd.get_distance("atom1", "atom2", state=frame)
        out_file.write(f"{frame},{current_dist:.3f}\n")
    
    # 清理资源
    out_file.close()
    cmd.delete("atom1")
    cmd.delete("atom2")
    
  2. 运行脚本

    • GUI模式:打开PyMOL,在命令行输入run measure_distances.pml
    • 无界面批量模式:在系统终端输入pymol -c measure_distances.pml(适合服务器或批量处理)

关键注意事项

  • 原子选择准确性:确保每个select命令只选中单个原子,否则get_distance会计算两组原子的质心距离,而非目标原子对的距离。可通过print(cmd.count_atoms("atom1"))检查选中数量。
  • 轨迹状态顺序:默认PyMOL会按加载顺序保留帧的顺序,若需确认可执行print(cmd.count_states("traj"))查看总帧数。
  • 可视化后续处理:导出的CSV文件可直接用Excel、Origin或Python的matplotlib/seaborn绘制距离随时间的折线图、距离分布直方图等。

内容的提问来源于stack exchange,提问作者gwarr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 05:40:22