Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenFF Toolkit 0.7.0 Compatability #31

Merged
merged 1 commit into from
Jun 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions nonbonded/library/curation/components/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,9 @@ class FilterByCharged(Component):
def _apply(
cls, data_frame: pandas.DataFrame, schema: FilterByChargedSchema, n_processes
) -> pandas.DataFrame:

from simtk import unit as simtk_unit

def filter_function(data_row):

n_components = data_row["N Components"]
Expand All @@ -651,10 +654,15 @@ def filter_function(data_row):
smiles = data_row[f"Component {index + 1}"]
molecule = Molecule.from_smiles(smiles, allow_undefined_stereo=True)

if numpy.isclose(
sum([atom.formal_charge for atom in molecule.atoms]), 0.0
):
# noinspection PyUnresolvedReferences
atom_charges = [
atom.formal_charge
if isinstance(atom.formal_charge, int)
else atom.formal_charge.value_in_unit(simtk_unit.elementary_charge)
for atom in molecule.atoms
]

if numpy.isclose(sum(atom_charges), 0.0):
continue

return False
Expand Down