Réimplémentation du programme DSSP en Python

atom.py 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. class Residue:
  18. def __init__(self, atoms_list):
  19. self.atoms = {}
  20. for atom in atoms_list:
  21. self.atoms[atom.atom_name] = atom
  22. self.resid = atom.res_seq_nb
  23. self.res_name = atom.res_name
  24. self.chain_id = atom.chain_id
  25. def h_bond(self, res2):
  26. if("H" not in res2.atoms.keys()):
  27. return(False)
  28. # elementary charge in Coulomb
  29. #e = 1.602176634 * 10*math.exp(-19)
  30. # dimensionnal factor f
  31. f = 332
  32. q1 = 0.42
  33. q2 = 0.20
  34. # r, distance between O-N atoms, in angströms
  35. r_ON = self.atoms["O"].dist_atoms(res2.atoms["N"])
  36. # r, distance between C-H atoms, in angströms
  37. r_CH = self.atoms["C"].dist_atoms(res2.atoms["H"])
  38. # r, distance between O-H atoms, in angströms
  39. r_OH = self.atoms["O"].dist_atoms(res2.atoms["H"])
  40. # r, distance between C-N atoms, in angströms
  41. r_CN = self.atoms["C"].dist_atoms(res2.atoms["N"])
  42. # Electrostatic interaction energy, in kcal/mole
  43. E = q1*q2*(1/r_ON + 1/r_CH - 1/r_OH - 1/r_CN)*f
  44. return(E)