From 33158d1172ff4ec670c1f0a1aa63db77162ebd40 Mon Sep 17 00:00:00 2001 From: Maohua Yang Date: Sat, 21 Oct 2023 05:20:51 +0800 Subject: [PATCH] Add more element valence (#169) * Add valence electrons for all elements * fix: add unknown element valence to 4 * fix: group None bug --- propka/energy.py | 6 ++++++ propka/protonate.py | 32 ++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/propka/energy.py b/propka/energy.py index af18f8c..8b54163 100644 --- a/propka/energy.py +++ b/propka/energy.py @@ -440,6 +440,12 @@ def check_coo_arg_exception(group_coo, group_arg, version): [closest_coo_atom, dist, closest_arg_atom] = get_smallest_distance( atoms_coo, atoms_arg ) + if closest_coo_atom is None: + _LOGGER.warning(f"COO interaction atoms missing for {group_coo}") + continue + if closest_arg_atom is None: + _LOGGER.warning(f"ARG interaction atoms missing for {group_arg}") + continue [dpka_max, cutoff] = version.get_hydrogen_bond_parameters( closest_coo_atom, closest_arg_atom ) diff --git a/propka/protonate.py b/propka/protonate.py index 412d9a3..93306cb 100644 --- a/propka/protonate.py +++ b/propka/protonate.py @@ -28,12 +28,24 @@ def __init__(self, verbose=False): """ self.verbose = verbose self.valence_electrons = { - 'H': 1, 'He': 2, 'Li': 1, 'Be': 2, 'B': 3, 'C': 4, 'N': 5, - 'O': 6, 'F': 7, 'Ne': 8, 'Na': 1, 'Mg': 2, 'Al': 3, 'Si': 4, - 'P': 5, 'S': 6, 'Cl': 7, 'Ar': 8, 'K': 1, 'Ca': 2, 'Sc': 2, - 'Ti': 2, 'V': 2, 'Cr': 1, 'Mn': 2, 'Fe': 2, 'Co': 2, 'Ni': 2, - 'Cu': 1, 'Zn': 2, 'Ga': 3, 'Ge': 4, 'As': 5, 'Se': 6, 'Br': 7, - 'Kr': 8, 'I': 7} + "H": 1, "He": 2, "Li": 1, "Be": 2, "B": 3, "C": 4, "N": 5, + "O": 6, "F": 7, "Ne": 8, "Na": 1, "Mg": 2, "Al": 3, "Si": 4, + "P": 5, "S": 6, "Cl": 7, "Ar": 8, "K": 1, "Ca": 2, "Sc": 2, + "Ti": 2, "V": 2, "Cr": 1, "Mn": 2, "Fe": 2, "Co": 2, "Ni": 2, + "Cu": 1, "Zn": 2, "Ga": 3, "Ge": 4, "As": 5, "Se": 6, "Br": 7, + "Kr": 8, "Rb": 1, "Sr": 2, "Y": 2, "Zr": 2, "Nb": 1, "Mo": 1, + "Tc": 2, "Ru": 1, "Rh": 1, "Pd": 8, "Ag": 1, "Cd": 2, "In": 3, + "Sn": 4, "Sb": 5, "Te": 6, "I": 7, "Xe": 8, "Cs": 1, "Ba": 2, + "La": 2, "Ce": 2, "Pr": 2, "Nd": 2, "Pm": 2, "Sm": 2, "Eu": 2, + "Gd": 2, "Tb": 2, "Dy": 2, "Ho": 2, "Er": 2, "Tm": 2, "Yb": 2, + "Lu": 2, "Hf": 2, "Ta": 2, "W": 2, "Re": 2, "Os": 2, "Ir": 2, + "Pt": 1, "Au": 1, "Hg": 2, "Tl": 3, "Pb": 4, "Bi": 5, "Po": 6, + "At": 7, "Rn": 8, "Fr": 1, "Ra": 2, "Ac": 2, "Th": 2, "Pa": 2, + "U": 2, "Np": 2, "Pu": 2, "Am": 2, "Cm": 2, "Bk": 2, "Cf": 2, + "Es": 2, "Fm": 2, "Md": 2, "No": 2, "Lr": 3, "Rf": 2, "Db": 2, + "Sg": 2, "Bh": 2, "Hs": 2, "Mt": 2, "Ds": 2, "Rg": 2, "Cn": 2, + "Nh": 3, "Fl": 4, "Mc": 5, "Lv": 6, "Ts": 7, "Og": 8, "Uue": 1 + } # TODO - consider putting charges in a configuration file self.standard_charges = { 'ARG-NH1': 1.0, 'ASP-OD2': -1.0, 'GLU-OE2': -1.0, 'HIS-ND1': 1.0, @@ -137,6 +149,10 @@ def set_number_of_protons_to_add(self, atom): _LOGGER.debug('Setting number of protons to add for %s', atom) atom.number_of_protons_to_add = 8 _LOGGER.debug(" 8") + if atom.element not in self.valence_electrons: + _LOGGER.warning( + f'Unknown valence electron for element {atom.element}') + self.valence_electrons[atom.element] = 4 atom.number_of_protons_to_add -= self.valence_electrons[atom.element] _LOGGER.debug('Valence electrons: {0:>4d}'.format( -self.valence_electrons[atom.element])) @@ -165,6 +181,10 @@ def set_steric_number_and_lone_pairs(self, atom): _LOGGER.debug('='*10) _LOGGER.debug('Setting steric number and lone pairs for %s', atom) atom.steric_number = 0 + if atom.element not in self.valence_electrons: + self.valence_electrons[atom.element] = 4 + _LOGGER.warning( + f"Not found valence for element {atom.element}, use 4") _LOGGER.debug('{0:>65s}: {1:>4d}'.format( 'Valence electrons', self.valence_electrons[atom.element])) atom.steric_number += self.valence_electrons[atom.element]