Réimplémentation du programme DSSP en Python

atom.py 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. # partial charges
  36. q1 = 0.42
  37. q2 = 0.20
  38. # r, distance between O-N atoms, in angströms
  39. r_ON = self.atoms["O"].dist_atoms(res2.atoms["N"])
  40. # r, distance between C-H atoms, in angströms
  41. r_CH = self.atoms["C"].dist_atoms(res2.atoms["H"])
  42. # r, distance between O-H atoms, in angströms
  43. r_OH = self.atoms["O"].dist_atoms(res2.atoms["H"])
  44. # r, distance between C-N atoms, in angströms
  45. r_CN = self.atoms["C"].dist_atoms(res2.atoms["N"])
  46. # Electrostatic interaction energy, in kcal/mole
  47. E = q1*q2*(1/r_ON + 1/r_CH - 1/r_OH - 1/r_CN)*f
  48. return(E)