def test_ammonium_formal_charge(objkey, request):
    mol = request.getfixturevalue(objkey)
    mdt.assign_formal_charges(mol)
    assert mol.charge == 1 * u.q_e

    for atom in mol.atoms:
        if atom.atnum == 7:
            assert atom.formal_charge == 1 * u.q_e
        else:
            assert atom.atnum == 1
            assert atom.formal_charge == 0 * u.q_e
def test_ammonium_formal_charge(objkey, request):
    mol = request.getfixturevalue(objkey)
    mdt.assign_formal_charges(mol)
    assert mol.charge == 1 * u.q_e

    for atom in mol.atoms:
        if atom.atnum == 7:
            assert atom.formal_charge == 1 * u.q_e
        else:
            assert atom.atnum == 1
            assert atom.formal_charge == 0 * u.q_e
Esempio n. 3
0
def set_protonation(mol, ph=7.4):
    """ Adjust protonation according to the OpenBabel pka model.

    This routine will return a copy of the molecule with the new protonation state and adjusted
    formal charges

    Args:
        mol (moldesign.Molecule): Molecule to adjust
        ph (float): assign protonation state for this pH value

    Returns:
        moldesign.Molecule: New molecule with adjusted protonation
    """
    # TODO: this doesn't appear to do anything for most molecules!!!
    # TODO: this renames hydrogens!!!

    pbmol = mol_to_pybel(mol)
    pbmol.OBMol.AddHydrogens(False, True, ph)

    newmol = pybel_to_mol(pbmol, reorder_atoms_by_residue=True)
    mdt.helpers.assign_unique_hydrogen_names(newmol)
    mdt.assign_formal_charges(newmol, ignore_nonzero=False)
    return newmol
def set_protonation(mol, ph=7.4):
    """ Adjust protonation according to the OpenBabel pka model.

    This routine will return a copy of the molecule with the new protonation state and adjusted
    formal charges

    Args:
        mol (moldesign.Molecule): Molecule to adjust
        ph (float): assign protonation state for this pH value

    Returns:
        moldesign.Molecule: New molecule with adjusted protonation
    """
    # TODO: this doesn't appear to do anything for most molecules!!!
    # TODO: this renames hydrogens!!!

    pbmol = mol_to_pybel(mol)
    pbmol.OBMol.AddHydrogens(False, True, ph)

    newmol = pybel_to_mol(pbmol, reorder_atoms_by_residue=True)
    mdt.helpers.assign_unique_hydrogen_names(newmol)
    mdt.assign_formal_charges(newmol, ignore_nonzero=False)
    return newmol