Skip to content

Commit

Permalink
Merge pull request #176 from martimunicoy/mulliken
Browse files Browse the repository at this point in the history
Mulliken charge selector
  • Loading branch information
martimunicoy committed May 8, 2023
2 parents 6ab135c + c1ebecf commit 0de7dba
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
8 changes: 8 additions & 0 deletions peleffy/forcefield/calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ class GasteigerCalculator(_PartialChargeCalculator):

_name = 'gasteiger'

class MullikenCalculator(_PartialChargeCalculator):
"""
Implementation of the Mulliken partial charge calculator (using
RDKit).
"""

_name = 'mulliken'


class OPLSChargeCalculator(_PartialChargeCalculator):
"""
Expand Down
6 changes: 4 additions & 2 deletions peleffy/forcefield/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ class ChargeCalculatorSelector(object):
from peleffy.forcefield.calculators import (OPLSChargeCalculator,
Am1bccCalculator,
GasteigerCalculator,
DummyChargeCalculator)
DummyChargeCalculator,
MullikenCalculator)

_AVAILABLE_TYPES = {'opls2005': OPLSChargeCalculator,
'am1bcc': Am1bccCalculator,
'gasteiger': GasteigerCalculator,
'dummy': DummyChargeCalculator
'dummy': DummyChargeCalculator,
'mulliken': MullikenCalculator
}

def get_by_name(self, charge_method, molecule):
Expand Down
8 changes: 7 additions & 1 deletion peleffy/tests/test_forcefields.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_charge_calculator_selector(self):
peleffy.forcefield.calculators.GasteigerCalculator), \
'Invalid custom selection 1 for the charge calculator'

# Check custom selection 1
# Check custom selection 2
openff = OpenForceField(self.FORCE_FIELD_NAME)
calculator = openff._get_charge_calculator('opls2005', dummy_mol)

Expand All @@ -67,6 +67,12 @@ def test_charge_calculator_selector(self):
peleffy.forcefield.calculators.OPLSChargeCalculator), \
'Invalid custom selection 2 for the charge calculator'

# Check custom selection 3
openff = OpenForceField(self.FORCE_FIELD_NAME)
calculator = openff._get_charge_calculator('mulliken', dummy_mol)
assert isinstance(calculator, peleffy.forcefield.calculators.MullikenCalculator), \
"Invalid custom selection 3 for the charge calculator"

def test_parameterizer(self):
"""It checks the parameterized method."""

Expand Down
14 changes: 14 additions & 0 deletions peleffy/tests/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,20 @@ def test_gasteiger_method(self):
# Check charges
check_CHO_charges(parameters)

def test_mulliken_method(self):
"""It tests the mulliken method"""
ligand_path = get_data_file_path(self.LIGAND_PATH)

# Load molecule
molecule = Molecule(ligand_path)

# Parameterize
ff = OpenForceField(FORCEFIELD_NAME)
parameters = ff.parameterize(molecule, charge_method='mulliken')

# Check charges
check_CHO_charges(parameters)

def test_OPLS_method(self):
"""It tests the OPLS method"""

Expand Down
5 changes: 3 additions & 2 deletions peleffy/utils/toolkits.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ def compute_partial_charges(self, molecule, method='am1bcc'):
molecule : an peleffy.topology.Molecule
The peleffy's Molecule object
method : str
The name of the method to use. One of ['gasteiger', 'am1bcc'].
The name of the method to use. One of ['gasteiger', 'am1bcc', 'mulliken'].
If None, 'am1bcc' will be used
Returns
Expand All @@ -1027,7 +1027,8 @@ def compute_partial_charges(self, molecule, method='am1bcc'):
"""

SUPPORTED_CHARGE_METHODS = {'am1bcc': {'antechamber_keyword': 'bcc'},
'gasteiger': {'antechamber_keyword': 'gas'}
'gasteiger': {'antechamber_keyword': 'gas'},
'mulliken': {'antechamber_keyword': 'mul'}
}

if method not in SUPPORTED_CHARGE_METHODS:
Expand Down

0 comments on commit 0de7dba

Please sign in to comment.