Skip to content

Commit

Permalink
Add more element valence (#169)
Browse files Browse the repository at this point in the history
* Add valence electrons for all elements
* fix: add unknown element valence to 4
* fix: group None bug
  • Loading branch information
Aunity authored Oct 20, 2023
1 parent d1d3b37 commit 33158d1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
6 changes: 6 additions & 0 deletions propka/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
32 changes: 26 additions & 6 deletions propka/protonate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]))
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 33158d1

Please sign in to comment.