计算两个小分子之间的rmsd,可以用来判断两个构象的接近程度. 第一步:安装anaconda win或者lin x系统下anaconda安装,不赘述,网上很多教程. 第二步:安装rdkit 通过conda安装rdkit conda install -c rdkit rdkit python  mol1.pdb mol2.pdb rmsd.txt #! srbinpython calc lates rmsd differences between 2 conformation with different atom names. @a thor: jc  import os import sys import math # rdkit imports from rdkit import chem from rdkit.chem import allchem from rdkit.chem.allchem import alignmol def getbestrmsd(probe,ref,refconf-1,probeconf-1,maps=none):  ret rns the optimal rms for aligning two molec les, taking symmetry into acco nt. as a side-effect, the probe molec le is left in the aligned state. arg ments: - ref: the reference molec le - probe: the molec le to be aligned to the reference - refconfid: (optional) reference conformation to se - probeconfid: (optional) probe conformation to se - maps: (optional) a list of lists of (probeatomid,refatomid) t ples with the atom-atom mappings of the two molec les. if not provided, these will be generated sing a s bstr ct re search. note: this f nction will attempt to align all perm tations of matching atom orders in both molec les, for some molec les it will lead to combinatorial explosion especially if hydrogens are present. use rdkit.chem.allchem.alignmol to align molec les witho t changing the atom order.  # when mapping the coordinate of probe will changed!!! ref.pos = orginxyz(ref) probe.pos = orginxyz(probe) if not maps: matches = ref.gets bstr ctmatches(probe, niq ify=false) if not matches: raise val eerror( mol %s does not match mol %s %(ref.getprop( _name ), probe.getprop( _name  if len(matches)  1e6: warnings.warn("{} matches detected for molec le {}, this may lead to a performance slowdown.".format(len(matches), probe.getprop( _name  maps = [list(en merate(match)) for match in matches] bestrms=1000.0 bestrmsd = 1000.0 for amap in maps: rms=alignmol(probe,ref,probeconfid,refconfid,atommap=amap) rmsd = rmsd(probe,ref,amap) if rmsdbestrmsd: bestrmsd = rmsd if rmsbestrms: bestrms=rms bestmap = amap # finally repeate the best alignment : if bestmap != amap: alignmol(probe,ref,probeconfid,refconfid,atommap=bestmap) ret rn bestrms, bestrmsd # map is probe - ref # [(1:3),(2:5)..,(10,1)] def rmsd(probe,ref,amap): rmsd = 0.0 # print(amap) atomn m = ref.getn matoms + 0.0 for (pi,ri) in amap: posp = probe.pos[pi] posf = ref.pos[ri] rmsd += dist_2(posp,posf) rmsd = math.sqrt(rmsdatomn m) ret rn rmsd def dist_2(atoma_xyz, atomb_xyz): dis2 = 0.0 for i, j in zip(atoma_xyz,atomb_xyz): dis2 += (i -j)**2 ret rn dis2 def orginxyz(mol): mol_pos={} for i in range(0,mol.getn matoms): pos = mol.getconformer.getatomposition(i) mol_pos[i] = pos ret rn mol_pos if __name__ == "__main__": sage=  will o tp t two rmsd, one is fitted, another is no fit. not fit rmsd mean no change in molec les coordinates.   mol1.pdb mol2.pdb rmsd.txt  if len(sys.argv)  4: print( sage) sys.exit ref = chem.molfrompdbfile(sys.argv[1]) probe = chem.molfrompdbfile(sys.argv[2]) # here, rms is fitted, rmsd is not fit!!!