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

Do not use 'old' OpenFF Toolkit API #545

Merged
merged 2 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
run: python -m pip install -e .

- name: Test (OS -> ${{ matrix.os }} / Python -> ${{ matrix.python-version }})
run: python -m pytest -v --cov=foyer --cov-report=xml --cov-append --cov-config=setup.cfg --color yes --pyargs foyer
run: python -m pytest -v -nauto --cov=foyer --cov-report=xml --cov-append --cov-config=setup.cfg --color yes --pyargs foyer

- name: Upload Coverage Report
uses: codecov/codecov-action@v2
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:

- name: Run Bleeding Edge Tests
run: |
python -m pytest -v --color yes --pyargs foyer
python -m pytest -v -nauto --color yes --pyargs foyer

docker:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions environment-dev-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
- pytest-azurepipelines
- pytest-cov
- pytest-timeout
- pytest-xdist
- python>=3.8
- requests
- requests-mock
Expand Down
1 change: 1 addition & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
- pytest-azurepipelines
- pytest-cov
- pytest-timeout
- pytest-xdist
- python>=3.8
- requests
- requests-mock
Expand Down
1 change: 1 addition & 0 deletions environment-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ dependencies:
- pytest-azurepipelines
- pytest-cov
- pytest-timeout
- pytest-xdist
- python<=3.8
56 changes: 16 additions & 40 deletions foyer/topology_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,51 +190,27 @@ def from_openff_topology(cls, openff_topology: "OpenFFTopology"):
f"Got {type(openff_topology).__name__} instead"
)

uses_old_api = hasattr(Topology(), "_topology_molecules")

top_graph = cls()

if uses_old_api:
from parmed import periodic_table as pt

for top_atom in openff_topology.atoms:
atom = top_atom.atom
element_symbol = pt.Element[atom.atomic_number]
top_graph.add_atom(
name=atom.name,
index=top_atom.topology_atom_index,
atomic_number=atom.atomic_number,
symbol=element_symbol,
)
from openff.units.elements import SYMBOLS

for top_bond in openff_topology.topology_bonds:
atoms_indices = [
atom.topology_atom_index for atom in top_bond.atoms
]
top_graph.add_bond(atoms_indices[0], atoms_indices[1])
for atom in openff_topology.atoms:
atom_index = openff_topology.atom_index(atom)
element_symbol = SYMBOLS[atom.atomic_number]
top_graph.add_atom(
name=atom.name,
index=atom_index,
atomic_number=atom.atomic_number,
symbol=element_symbol,
)

return top_graph
for bond in openff_topology.bonds:
atoms_indices = [
openff_topology.atom_index(atom) for atom in bond.atoms
]
top_graph.add_bond(*atoms_indices)

else:
from openff.units.elements import SYMBOLS

for atom in openff_topology.atoms:
atom_index = openff_topology.atom_index(atom)
element_symbol = SYMBOLS[atom.atomic_number]
top_graph.add_atom(
name=atom.name,
index=atom_index,
atomic_number=atom.atomic_number,
symbol=element_symbol,
)

for bond in openff_topology.bonds:
atoms_indices = [
openff_topology.atom_index(atom) for atom in bond.atoms
]
top_graph.add_bond(*atoms_indices)

return top_graph
return top_graph

@classmethod
def from_gmso_topology(cls, gmso_topology: "gmso.Topology"):
Expand Down
Loading