mirror of
https://github.com/Electrostatics/apbs-pdb2pqr.git
synced 2026-06-04 14:49:37 +08:00
Remove bond-order guessing.
Remove guess_bond_order function and associated tests. Bond orders are already specified in the MOL2 file and the existing code wasn't very good at guessing them.
This commit is contained in:
@@ -24,25 +24,6 @@ PARSE_RADII = {
|
||||
"F": 1.20, "P": 1.90, "Cl": 1.75}
|
||||
|
||||
|
||||
# TODO - this belongs in a configuration file somewhere other than here.
|
||||
# Bond lengths from
|
||||
# http://www.chem.swin.edu.au/modules/mod2/bondlen.html
|
||||
# We should get a better reference
|
||||
_BOND_LENGTH_DICTS = [
|
||||
{"atom1": 'C', "atom2": 'C', "length": 1.54, "type": "single"},
|
||||
{"atom1": 'C', "atom2": 'C', "length": 1.34, "type": "double"},
|
||||
{"atom1": 'C', "atom2": 'C', "length": 1.20, "type": "triple"},
|
||||
{"atom1": 'C', "atom2": 'C', "length": 1.40, "type": "aromatic"},
|
||||
{"atom1": 'C', "atom2": 'O', "length": 1.43, "type": "single"},
|
||||
{"atom1": 'C', "atom2": 'O', "length": 1.21, "type": "double"},
|
||||
{"atom1": 'C', "atom2": 'N', "length": 1.47, "type": "single"},
|
||||
{"atom1": 'C', "atom2": 'N', "length": 1.25, "type": "double"},
|
||||
{"atom1": 'C', "atom2": 'N', "length": 1.16, "type": "triple"},
|
||||
{"atom1": 'C', "atom2": 'N', "length": 1.34, "type": "aromatic"},
|
||||
{"atom1": 'N', "atom2": 'N', "length": 1.35, "type": "aromatic"}
|
||||
]
|
||||
BOND_LENGTHS = pandas.DataFrame(_BOND_LENGTH_DICTS)
|
||||
|
||||
# Numbers of valence electrons for the groups of the periodic table
|
||||
VALENCE_BY_GROUP = {1: 1, 2: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8}
|
||||
# Groups of the periodic table
|
||||
|
||||
@@ -8,7 +8,7 @@ from collections import OrderedDict
|
||||
from itertools import combinations
|
||||
from numpy import array
|
||||
from numpy.linalg import norm
|
||||
from . import BOND_LENGTHS, VALENCE_BY_ELEMENT, NONBONDED_BY_TYPE
|
||||
from . import VALENCE_BY_ELEMENT, NONBONDED_BY_TYPE
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -53,29 +53,6 @@ class Mol2Bond:
|
||||
fmt = "{b.atoms[0].name:s} {b.type:s}-bonded to {b.atoms[1].name:s}"
|
||||
return fmt.format(b=self)
|
||||
|
||||
@property
|
||||
def guess_bond_order(self):
|
||||
"""Attempt to determine the order of this bond.
|
||||
|
||||
Return:
|
||||
string with order of bond or None
|
||||
"""
|
||||
_LOGGER.warning("Ignoring bond type: %s", self.type)
|
||||
type1 = self.atoms[0].type.split(".")[0]
|
||||
type2 = self.atoms[1].type.split(".")[0]
|
||||
types = sorted(type1, type2)
|
||||
bond_lengths = BOND_LENGTHS.loc[
|
||||
(BOND_LENGTHS["atom1"] == types[0])
|
||||
& (BOND_LENGTHS["atom2"] == types[1])]
|
||||
best_type = None
|
||||
best_fit = BOND_DIST
|
||||
for _, row in bond_lengths.iterrows():
|
||||
if abs(self.length - row["length"]) < best_fit:
|
||||
best_fit = abs(self.length - row["length"])
|
||||
best_type = row["type"]
|
||||
return best_type
|
||||
|
||||
|
||||
class Mol2Atom:
|
||||
"""MOL2 molecule atoms."""
|
||||
def __init__(self):
|
||||
|
||||
@@ -69,27 +69,6 @@ RING_RESULTS = {
|
||||
}
|
||||
|
||||
|
||||
BOND_RESULTS = {
|
||||
"cyclohexane.mol2": 6 * ["single"],
|
||||
"ethanol.mol2": [
|
||||
"single", "single", None, "single", "single"],
|
||||
"glycerol.mol2": [
|
||||
None, "single", "single", "single", "single", None, "single", None],
|
||||
"acetylcholine.mol2": [
|
||||
"single", "double", "single", "single", "single", "single", "single",
|
||||
"single", "single"],
|
||||
"acetonitrile.mol2": [
|
||||
"triple", "single"],
|
||||
"pyrrole.mol2": [
|
||||
"aromatic", "aromatic", "aromatic", "aromatic", "aromatic", None],
|
||||
"fatty-acid.mol2": [
|
||||
"double", "double", "single", "single", "single", "single", "double",
|
||||
"single", "single", "single", "single"],
|
||||
"tetramethylammonium.mol2": ["single", None, "single", "single"],
|
||||
"naphthalene.mol2": 11 * ["aromatic"]
|
||||
}
|
||||
|
||||
|
||||
FORMAL_CHARGE_RESULTS = {
|
||||
"1HPX-ligand.mol2": 87*[0],
|
||||
"1QBS-ligand.mol2": 80*[0],
|
||||
|
||||
@@ -7,7 +7,7 @@ import pandas as pd
|
||||
from numpy.testing import assert_almost_equal
|
||||
from pdb2pqr.ligand import parameterize
|
||||
import common
|
||||
from ligand_results import TORSION_RESULTS, RING_RESULTS, BOND_RESULTS
|
||||
from ligand_results import TORSION_RESULTS, RING_RESULTS
|
||||
from ligand_results import FORMAL_CHARGE_RESULTS, PARTIAL_CHARGE_RESULTS
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ _LOGGER.warning("Need functional and regression test coverage for --ligand")
|
||||
_LOGGER.error("Still haven't figured out radii")
|
||||
|
||||
|
||||
ALL_LIGANDS = set(TORSION_RESULTS) | set(BOND_RESULTS) | set(RING_RESULTS)
|
||||
ALL_LIGANDS = set(TORSION_RESULTS) | set(RING_RESULTS)
|
||||
ALL_LIGANDS |= {
|
||||
"1HPX-ligand.mol2", "1QBS-ligand.mol2", "1US0-ligand.mol2", "adp.mol2",
|
||||
"acetate.mol2"}
|
||||
@@ -154,26 +154,6 @@ def test_rings(input_mol2):
|
||||
_LOGGER.debug(str_)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("input_mol2", ALL_LIGANDS)
|
||||
def test_bonds(input_mol2):
|
||||
"""Test detection of bond types."""
|
||||
ligand = parameterize.ParameterizedMolecule()
|
||||
mol2_path = Path("tests/data") / input_mol2
|
||||
with open(mol2_path, "rt") as mol2_file:
|
||||
ligand.read(mol2_file)
|
||||
results = BOND_RESULTS[input_mol2]
|
||||
for ibond, bond in enumerate(ligand.bonds):
|
||||
try:
|
||||
if bond.bond_order != results[ibond]:
|
||||
err = "Incorrect order for %s. Got %s, expected %s" % (
|
||||
str(bond), bond.bond_order, results[ibond])
|
||||
raise ValueError(err)
|
||||
except IndexError:
|
||||
err = "Add test for %s -- %s (%s)" % (
|
||||
input_mol2, str(bond), bond.bond_order)
|
||||
raise IndexError(err)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("input_pdb", ["1HPX", "1QBS", "1US0"], ids=str)
|
||||
def test_ligand_protein(input_pdb, tmp_path):
|
||||
"""PROPKA non-regression tests on proteins without ligands."""
|
||||
|
||||
Reference in New Issue
Block a user