Réimplémentation du programme DSSP en Python

atom.py 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import math
  2. class Atom:
  3. def dist_atoms(self, atom2):
  4. return(math.sqrt((self.coord_x-atom2.coord_x)**2 +
  5. (self.coord_y-atom2.coord_y)**2 +
  6. (self.coord_z-atom2.coord_z)**2))
  7. def __init__(self, atom_id, atom_name, res_name, chain_id,
  8. res_seq_nb, coordinates):
  9. self.atom_id = atom_id
  10. self.atom_name = atom_name
  11. self.res_name = res_name
  12. self.chain_id = chain_id
  13. self.res_seq_nb = res_seq_nb
  14. self.coord_x = coordinates[0]
  15. self.coord_y = coordinates[1]
  16. self.coord_z = coordinates[2]
  17. self.coords = coordinates
  18. class Residue:
  19. def __init__(self, atoms_list):
  20. self.atoms = {}
  21. for atom in atoms_list:
  22. self.atoms[atom.atom_name] = atom
  23. self.resid = atom.res_seq_nb
  24. self.res_name = atom.res_name
  25. self.chain_id = atom.chain_id
  26. def h_bond(self, res2):
  27. if("H" not in res2.atoms.keys()):
  28. return(False)
  29. # elementary charge in Coulomb
  30. #e = 1.602176634 * 10*math.exp(-19)
  31. # dimensionnal factor f
  32. f = 332
  33. q1 = 0.42
  34. q2 = 0.20
  35. # r, distance between O-N atoms, in angströms
  36. r_ON = self.atoms["O"].dist_atoms(res2.atoms["N"])
  37. # r, distance between C-H atoms, in angströms
  38. r_CH = self.atoms["C"].dist_atoms(res2.atoms["H"])
  39. # r, distance between O-H atoms, in angströms
  40. r_OH = self.atoms["O"].dist_atoms(res2.atoms["H"])
  41. # r, distance between C-N atoms, in angströms
  42. r_CN = self.atoms["C"].dist_atoms(res2.atoms["N"])
  43. # Electrostatic interaction energy, in kcal/mole
  44. E = q1*q2*(1/r_ON + 1/r_CH - 1/r_OH - 1/r_CN)*f
  45. return(E)