Skip to content

Commit 6463e8a

Browse files
Remove dormant API points (#1058)
* Remove dead API points * Remove _networkx_to_hill_formula, replace _to_mdtraj, update release notes * Fix typo
1 parent 881c29a commit 6463e8a

File tree

4 files changed

+8
-140
lines changed

4 files changed

+8
-140
lines changed

docs/releasehistory.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w
3636
created through the [`Molecule.to_rdkit()`](openff.toolkit.topology.Molecule.to_rdkit)
3737
method have the `NoImplicit` property set to `True` on all atoms. This prevents RDKit from
3838
incorrectly adding hydrogen atoms to to molecule.
39+
- [PR #1058](https://github.com/openforcefield/openforcefield/pull/1058): Removes the unimplemented methods
40+
[`ForceField.create_parmed_structure`](openff.toolkit.typing.engines.smirnoff.ForceField.create_parmed_structure),
41+
[`Topology.to_parmed`](openff.toolkit.topology.Topology.to_parmed), and
42+
[`Topology.from_parmed`](openff.toolkit.topology.Topology.from_parmed).
3943

4044
### Tests updated
4145

openff/toolkit/tests/test_forcefield.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,27 +1641,6 @@ def test_parameterize_mol_missing_stereo_openeye(self):
16411641
force_field = ForceField("test_forcefields/test_forcefield.offxml")
16421642
force_field.create_openmm_system(topology, toolkit_registry=toolkit_registry)
16431643

1644-
@pytest.mark.skip(
1645-
reason="We will not support going directly to ParmEd for now."
1646-
"We will instead feed OpenMM System objects to ParmEd "
1647-
"for further processing."
1648-
)
1649-
def test_parameterize_ethanol_to_parmed(self):
1650-
from simtk.openmm import app
1651-
1652-
forcefield = ForceField("test_forcefields/test_forcefield.offxml")
1653-
pdbfile = app.PDBFile(get_data_file_path("systems/test_systems/1_ethanol.pdb"))
1654-
# toolkit_wrapper = RDKitToolkitWrapper()
1655-
molecules = [
1656-
Molecule.from_file(get_data_file_path(name))
1657-
for name in ("molecules/ethanol.mol2",)
1658-
]
1659-
topology = Topology.from_openmm(pdbfile.topology, unique_molecules=molecules)
1660-
1661-
parmed_system = forcefield.create_parmed_structure(
1662-
topology, positions=pdbfile.getPositions()
1663-
)
1664-
16651644
@pytest.mark.parametrize(
16661645
"toolkit_registry,registry_description", toolkit_registries
16671646
)

openff/toolkit/topology/topology.py

Lines changed: 4 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,57 +2110,6 @@ def from_dict(cls, d):
21102110
# Implement abstract method Serializable.to_dict()
21112111
raise NotImplementedError() # TODO
21122112

2113-
# TODO: Merge this into Molecule.from_networkx if/when we implement that.
2114-
# TODO: can we now remove this as we have the ability to do this in the Molecule class?
2115-
@staticmethod
2116-
def _networkx_to_hill_formula(mol_graph):
2117-
"""
2118-
Convert a networkX representation of a molecule to a molecule formula. Used in printing out
2119-
informative error messages when a molecule from an openmm topology can't be matched.
2120-
2121-
Parameters
2122-
----------
2123-
mol_graph : a networkX graph
2124-
The graph representation of a molecule
2125-
2126-
Returns
2127-
-------
2128-
formula : str
2129-
The molecular formula of the graph molecule
2130-
"""
2131-
from simtk.openmm.app import Element
2132-
2133-
# Make a flat list of all atomic numbers in the molecule
2134-
atom_nums = []
2135-
for idx in mol_graph.nodes:
2136-
atom_nums.append(mol_graph.nodes[idx]["atomic_number"])
2137-
2138-
# Count the number of instances of each atomic number
2139-
at_num_to_counts = dict([(unq, atom_nums.count(unq)) for unq in atom_nums])
2140-
2141-
symbol_to_counts = {}
2142-
# Check for C and H first, to make a correct hill formula (remember dicts in python 3.6+ are ordered)
2143-
if 6 in at_num_to_counts:
2144-
symbol_to_counts["C"] = at_num_to_counts[6]
2145-
del at_num_to_counts[6]
2146-
2147-
if 1 in at_num_to_counts:
2148-
symbol_to_counts["H"] = at_num_to_counts[1]
2149-
del at_num_to_counts[1]
2150-
2151-
# Now count instances of all elements other than C and H, in order of ascending atomic number
2152-
sorted_atom_nums = sorted(at_num_to_counts.keys())
2153-
for atom_num in sorted_atom_nums:
2154-
symbol_to_counts[
2155-
Element.getByAtomicNumber(atom_num).symbol
2156-
] = at_num_to_counts[atom_num]
2157-
2158-
# Finally format the formula as string
2159-
formula = ""
2160-
for ele, count in symbol_to_counts.items():
2161-
formula += f"{ele}{count}"
2162-
return formula
2163-
21642113
@classmethod
21652114
def from_openmm(cls, openmm_topology, unique_molecules=None):
21662115
"""
@@ -2477,65 +2426,21 @@ def from_mdtraj(mdtraj_topology, unique_molecules=None):
24772426
mdtraj_topology.to_openmm(), unique_molecules=unique_molecules
24782427
)
24792428

2480-
# TODO: Jeff prepended an underscore on this before 0.2.0 release to remove it from the API.
2481-
# Before exposing this, we should look carefully at the information that is preserved/lost during this
2482-
# conversion, and make it clear what would happen to this information in a round trip. For example,
2483-
# we should know what would happen to formal and partial bond orders and charges, stereochemistry, and
2484-
# multi-conformer information. It will be important to document these risks to users, as all of these
2485-
# factors could lead to unintended behavior during system parameterization.
2429+
# Avoid removing this method, even though it is private and would not be difficult for most
2430+
# users to replace. Also avoid making it public as round-trips with MDTraj are likely
2431+
# to not preserve necessary information.
24862432
def _to_mdtraj(self):
24872433
"""
24882434
Create an MDTraj Topology object.
2489-
24902435
Returns
24912436
----------
24922437
mdtraj_topology : mdtraj.Topology
24932438
An MDTraj Topology object
2494-
#"""
2439+
"""
24952440
import mdtraj as md
24962441

24972442
return md.Topology.from_openmm(self.to_openmm())
24982443

2499-
@staticmethod
2500-
def from_parmed(parmed_structure, unique_molecules=None):
2501-
"""
2502-
.. warning:: This functionality will be implemented in a future toolkit release.
2503-
2504-
Construct an OpenFF Topology object from a ParmEd Structure object.
2505-
2506-
Parameters
2507-
----------
2508-
parmed_structure : parmed.Structure
2509-
A ParmEd structure object
2510-
unique_molecules : iterable of objects that can be used to construct unique Molecule objects
2511-
All unique molecules must be provided, in any order, though multiple copies of each molecule are allowed.
2512-
The atomic elements and bond connectivity will be used to match the reference molecules
2513-
to molecule graphs appearing in the structure's ``topology`` object. If bond orders are present in the
2514-
structure's ``topology`` object, these will be used in matching as well.
2515-
2516-
Returns
2517-
-------
2518-
topology : openff.toolkit.topology.Topology
2519-
An OpenFF Topology object
2520-
"""
2521-
# TODO: Implement functionality
2522-
raise NotImplementedError
2523-
2524-
def to_parmed(self):
2525-
"""
2526-
2527-
.. warning:: This functionality will be implemented in a future toolkit release.
2528-
2529-
Create a ParmEd Structure object.
2530-
2531-
Returns
2532-
----------
2533-
parmed_structure : parmed.Structure
2534-
A ParmEd Structure objecft
2535-
"""
2536-
# TODO: Implement functionality
2537-
raise NotImplementedError
2538-
25392444
# TODO: Jeff prepended an underscore on this before 0.2.0 release to remove it from the API.
25402445
# This function is deprecated and expects the OpenEye toolkit. We need to discuss what
25412446
# to do with this functionality in light of our move to the ToolkitWrapper architecture.

openff/toolkit/typing/engines/smirnoff/forcefield.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,26 +1370,6 @@ def create_openmm_system(self, topology, **kwargs):
13701370
else:
13711371
return system
13721372

1373-
def create_parmed_structure(self, topology, positions, **kwargs):
1374-
"""Create a ParmEd Structure object representing the interactions for the specified Topology with the current force field
1375-
1376-
This method creates a `ParmEd <http://github.com/parmed/parmed>`_ ``Structure`` object containing a topology, positions, and parameters.
1377-
1378-
Parameters
1379-
----------
1380-
topology : openff.toolkit.topology.Topology
1381-
The ``Topology`` corresponding to the OpenMM ``System`` object to be created.
1382-
positions : simtk.unit.Quantity of dimension (natoms,3) with units compatible with angstroms
1383-
The positions corresponding to the ``System`` object to be created
1384-
1385-
Returns
1386-
-------
1387-
structure : parmed.Structure
1388-
The newly created ``parmed.Structure`` object
1389-
1390-
"""
1391-
raise NotImplementedError
1392-
13931373
@requires_package("openff.interchange")
13941374
@requires_package("mdtraj")
13951375
def _to_interchange(self, topology, box=None):

0 commit comments

Comments
 (0)