Réimplémentation du programme DSSP en Python

atom.py 1.9KB

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