Advertisement
ProzacR

RMSD calculator

Jul 27th, 2011
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. #!/usr/bin/python
  2. #RMSD skaiciavimas
  3. #VR
  4. #pagal dockedpse.py is github
  5. #naudojimas: ./dockedpose.py kristalo.pdb docked.pdb
  6.  
  7. import math
  8. import pybel
  9. import sys
  10.  
  11. def squared_distance(coordsA, coordsB):
  12.     """Find the squared distance between two 3-tuples"""
  13.     sqrdist = sum( (a-b)**2 for a, b in zip(coordsA, coordsB) )
  14.     return sqrdist
  15.    
  16. def rmsd(allcoordsA, allcoordsB):
  17.     """Find the RMSD between two lists of 3-tuples"""
  18.     deviation = sum(squared_distance(atomA, atomB) for
  19.                     (atomA, atomB) in zip(allcoordsA, allcoordsB))
  20.     return math.sqrt(deviation / float(len(allcoordsA)))
  21.    
  22. #if __name__ == "__main__":
  23. crystal = next(pybel.readfile("pdb", sys.argv[1]))
  24. dockedpose = next(pybel.readfile("pdb", sys.argv[2]))
  25. xtalcoords = [atom.coords for atom in crystal if not atom.OBAtom.IsHydrogen()]    
  26. #for i, dockedpose in enumerate(pybel.readfile("pdb", sys.argv[1])):
  27. posecoords = [atom.coords for atom in dockedpose if not atom.OBAtom.IsHydrogen()]
  28. mrmsd = rmsd(posecoords, xtalcoords)
  29. print mrmsd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement