计算两个蛋白或小分子之间的RMSD

# Root-mean-square deviation (RMSD) for proteins and/or ligands
# in PDB files.
#class Pdb(object):""" Object that allows operations with protein files in PDB format. """def __init__(self, file_cont = [], pdb_code = ""):self.cont = []self.atom = []self.hetatm = []self.fileloc = ""if isinstance(file_cont, list):self.cont = file_cont[:]elif isinstance(file_cont, str):try:with open(file_cont, 'r') as pdb_file:self.cont = [row.strip() for row in pdb_file.read().split('\n') if row.strip()]except FileNotFoundError as err:print(err)if self.cont:self.atom = [row for row in self.cont if row.startswith('ATOM')]self.hetatm = [row for row in self.cont if row.startswith('HETATM')]self.conect = [row for row in self.cont if row.startswith('CONECT')]def rmsd(self, sec_molecule, ligand=False, atoms="no_h"):"""Calculates the Root Mean Square Deviation (RMSD) between twoprotein or ligand molecules in PDB format.Requires that both molecules have the same number of atoms in thesame numerical order.Keyword arguments:sec_molecule (PdbObj): the second molecule as PdbObj object.ligand (bool): If true, calculates the RMSD between twoligand molecules (based on HETATM entries), else RMSDbetween two protein molecules (ATOM entries) is calculated.hydrogen (bool): If True, hydrogen atoms will be included in theRMSD calculation.atoms (string) [all/c/no_h/ca]: "all" includes all atoms in the RMSD calculation,"c" only considers carbon atoms, "no_h" considers all but hydrogen atoms,and "ca" compares only C-alpha protein atoms.Returns:Calculated RMSD value as float or None if RMSD not becalculated."""rmsd = Noneif not ligand:coords1, coords2 = self.atom, sec_molecule.atomelse:coords1, coords2 = self.hetatm, sec_molecule.hetatmif atoms == "c":coords1 = [row for row in coords1 if row[77:].startswith('C')]coords2 = [row for row in coords2 if row[77:].startswith('C')]elif atoms == "no_h":coords1 = [row for row in coords1 if not row[77:].startswith('H')]coords2 = [row for row in coords2 if not row[77:].startswith('H')]elif atoms == "ca":coords1 = self.calpha()coords2 = sec_molecule.calpha()if all((coords1, coords2, len(coords1) == len(coords2))):total = 0for (i, j) in zip(coords1, coords2):total += ( float(i[30:38]) - float(j[30:38]) )**2 +\( float(i[38:46]) - float(j[38:46]) )**2 +\( float(i[46:54]) - float(j[46:54]) )**2      rmsd = round(( total / len(coords1) )**0.5, 4)return rmsdif __name__ == '__main__':import argparseparser = argparse.ArgumentParser(description='The RMSD measures the average distance between atoms \n'\'of 2 protein or ligand structures.\n'\'By default, all atoms but hydrogen atoms of the protein are included in the RMSD calculation.\n'\'NOTE: Both structures must contain the same number of atoms in similar order.',epilog='Example:\n'\'rmsd.py ~/Desktop/pdb1.pdb ~/Desktop/pdb2.pdb\n'\'0.7377',formatter_class=argparse.RawTextHelpFormatter)parser.add_argument('PDBfile1')parser.add_argument('PDBfile2')parser.add_argument('-l', '--ligand', action='store_true', help='Calculates RMSD between ligand (HETATM) atoms.')parser.add_argument('-c', '--carbon', action='store_true', help='Calculates the RMSD between carbon atoms only.')parser.add_argument('-ca', '--calpha', action='store_true', help='Calculates the RMSD between alpha-carbon atoms only.')parser.add_argument('-v', '--version', action='version', version='rmsd v. 1.0')args = parser.parse_args()pdb1 = Pdb(args.PDBfile1)pdb2 = Pdb(args.PDBfile2)if args.carbon and args.calpha:print('\nERROR: Please provide EITHER -c OR -ca, not both.\n')parser.print_help()quit()if args.ligand and args.carbon:print(pdb1.rmsd(sec_molecule=pdb2, ligand=True, atoms="c"))elif args.ligand and args.calpha:print(pdb1.calpha())print(pdb1.rmsd(sec_molecule=pdb2, ligand=True, atoms="ca"))elif args.ligand:print(pdb1.rmsd(sec_molecule=pdb2, ligand=True, atoms="no_h"))elif args.calpha:print(pdb1.rmsd(sec_molecule=pdb2, ligand=False, atoms="ca"))elif args.carbon:print(pdb1.rmsd(sec_molecule=pdb2, ligand=False, atoms="c"))else:print(pdb1.rmsd(sec_molecule=pdb2, ligand=False, atoms="no_h"))
if __name__ == '__main__':pass## python rmsd.py protein1.pdb protein2.pdb

计算两个蛋白或小分子之间的RMSD相关推荐

  1. Python:计算两个蛋白或小分子之间的RMSD

    Python脚本:计算两个蛋白或小分子之间的RMSD 用法: python rmsd.py protein1.pdb protein2.pdb rmsd.py # Root-mean-square d ...

  2. 计算小分子之间的RMSD

    一.代码来源: 计算rmsd参考:GitHub - 0ut0fcontrol/isoRMSD: calculating RMSD between 2 conformers with different ...

  3. 来一场蛋白和小分子的风花雪月

    分子对接(Molecular Docking)理论 所谓分子对接就是两个或多个分子之间通过几何匹配和能量匹配相互识别找到最佳匹配模式的过程.分子对接对酶学研究和药物设计中有重要的应用意义. 分子对接计 ...

  4. RDKit:计算不同小分子构象之间的RMSD

    计算两个小分子之间的RMSD,可以用来判断两个构象的接近程度. RDKit:计算不同分子或构象之间的RMSD点击打开链接 第一步:安装Anaconda Win或者Linux系统下Anaconda安装, ...

  5. Java计算两个时间的小时差

    /**** 计算两段时间的小时差* @module* @author SJT* @date 2022/12/28* @param startTime* @param endTime* @return: ...

  6. 小分子php蛋白,小分子-蛋白相互作用关系——简单的docking介绍

    前两天,老板突然QQ发了我一张截图 附言"糖苷类化合物涉及水解和二相代谢,原型成分很少",然后我立马回"好的-我来关注一下,我之前看文章的时候注意到了,在中药给药到细胞的 ...

  7. 使用face_recognition:摄像头实时给人脸打马赛克、疲劳检测、活体检测(张嘴检测)、计算两张人脸之间的相似度、人脸校准

    日萌社 人工智能AI:Keras PyTorch MXNet TensorFlow PaddlePaddle 深度学习实战(不定时更新) 使用face_recognition进行摄像头实时给人脸打马赛 ...

  8. RDKit:计算不同分子或构象之间的RMSD

    RDKit:计算不同分子或构象之间的RMSD Linux(CentOS 7_x64位)系统下安装RDkit(修正)点击打开链接 有时我们需要计算两个(或更多)分子之间的RMSD,可以用来判断两个构象的 ...

  9. 计算两个日期相差的小时差

    计算出:两个日期之间的相差天数,乘小时数 <%@ page language="java" import="java.util.*" pageEncodi ...

最新文章

  1. Pandas常见的性能优化方法
  2. Apache Kafka-CMAK(kafka manager)安装部署使用
  3. [Luogu] 1600
  4. Shell命令-文件及目录操作之chattr、lsattr
  5. html多语言国际化,gMIS吉密斯i18n多语言国际化更新
  6. MongoDB的高级语法
  7. KVM虚拟机共享存储动态迁移与冷迁移
  8. linux执行.sql脚本 db2,DB2 如何执行sql脚本
  9. 2、运行WordCount程序
  10. python知识汇总,python一期
  11. 设计模式之禅之设计模式-组合模式
  12. 有序二叉树c语言,二叉搜索树(BST)的实现(C语言)(原创)
  13. access成绩为非负数_初一数学期末复习,有理数应用题专训,正负数实际意义是关键...
  14. 小程序modal控件(显示为弹框) 可有输入框
  15. linux运维中的中间件,linux中间件Nginx的安装过程
  16. Linux课程笔记 Day05 命令总结
  17. 解决支持双面打印的打印机不能双面打印PDF
  18. 协同多智能体学习的价值分解网络的原理与代码复现
  19. CG佬的20年:行走于行业的过去与未来
  20. zyf sql语句

热门文章

  1. QQ可以直接在微信登陆了
  2. 北通无线游戏手柄不识别
  3. 爬取网易财经全部A股上市公司年报
  4. HP1213tx笔记本电脑不触发维修
  5. 1225:金银岛——贪心
  6. 树莓派下载gedit
  7. 省钱小妙招之50行python代码给你制作一个证件照
  8. 浅谈淘宝类目属性体系:商品搜索背后的逻辑架构
  9. 适配国产数据库 GBase(南大通用mysql版)
  10. 量价分析之毕生经验之谈