python - 使用 mdtraj 计算二面角
问题描述
import numpy as np
import mdtraj as md
import matplotlib.pyplot as plt
import nglview as ngl
traj0 = md.iterload('xtc_file', chunk=1000, top='pdb_file')
def xyz_gen(traj):
for chunk in traj:
yield chunk.xyz
dihedrals = md.compute_dihedrals(traj0, indices)
一切运行良好,但是当我尝试执行最后一步时,我得到:
AttributeError: 'generator' object has no attribute 'xyz'.
这是什么原因造成的?
解决方案
推荐阅读
- identityserver4 - Identity Server 4 Access Token Lifetime 将在其生命周期之后到期
- firebase - 如何获取 FireBase 的 TOKEN 或 API_KEY?
- powerbi - 在 Power BI 中创建年度列的最佳做法是什么?
- java - 在 Spring Boot 中接收 JSON 参数包含 ${} 导致错误
- maven - Maven Enforcer:如何从 beanshell 规则访问 Maven 属性
- javascript - ReactJS:嵌套导航不起作用,未到达预期页面
- typescript - 如何使用 TypeScript 中的命令模式获得通用推理?
- android - 如何在 Android Manifest 中声明 Fragment
- qt - cgo 依赖项的构建时间很慢
- node.js - 无法下载 node-sass HTTP 错误 404 Not found --- Node Gyp 错误