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

Remove deprecated formats, update reader and writer backends #1191

Merged
merged 46 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0b0f0b6
remove hoomdxml
chrisjonesBSU Jul 2, 2024
e65c823
remove protobuf
chrisjonesBSU Jul 2, 2024
90c42dd
remove hoomd3 force writers
chrisjonesBSU Jul 2, 2024
8fd26d4
change backend for mol2 and xyz to gmso
chrisjonesBSU Jul 2, 2024
90d77b6
remove protobuf from dev environments
chrisjonesBSU Jul 2, 2024
dda2160
add some TODO notes
chrisjonesBSU Jul 3, 2024
904eba7
Merge branch 'main' of github.com:mosdef-hub/mbuild into remove-dep
chrisjonesBSU Aug 7, 2024
b42fd4c
Merge branch 'main' of github.com:mosdef-hub/mbuild into remove-dep
chrisjonesBSU Aug 19, 2024
afa108f
Merge branch 'main' of github.com:mosdef-hub/mbuild into remove-dep
chrisjonesBSU Aug 19, 2024
9b2536a
Merge branch 'main' of github.com:mosdef-hub/mbuild into remove-dep
chrisjonesBSU Aug 20, 2024
7602f35
change behavior of xyz test
chrisjonesBSU Aug 22, 2024
99e8146
Merge branch 'remove-dep' of github.com:chrisjonesBSU/mbuild into rem…
chrisjonesBSU Aug 22, 2024
1ed5413
Merge branch 'main' of github.com:mosdef-hub/mbuild into remove-dep
chrisjonesBSU Aug 26, 2024
a36825a
comment out test for elements
chrisjonesBSU Aug 26, 2024
5079233
fix test based on expected behavior for xyz files, remove wrong n ato…
chrisjonesBSU Aug 26, 2024
11b385e
remove lammpsdata and tests
chrisjonesBSU Aug 29, 2024
8c417bf
Merge branch 'remove-dep' of github.com:chrisjonesBSU/mbuild into rem…
chrisjonesBSU Aug 29, 2024
98ac3c3
remove duplicate benzene fixture that reads benzene from a mol2 file
chrisjonesBSU Sep 9, 2024
aa3e726
update benzene naming to fix failing rigid tests
CalCraven Sep 13, 2024
6f82f71
Merge branch 'main' of github.com:mosdef-hub/mbuild into remove-dep
chrisjonesBSU Sep 13, 2024
95ab814
add hoomd_writer file that has GSD and snapshot writer
chrisjonesBSU Sep 13, 2024
4edad91
fix typo
chrisjonesBSU Sep 13, 2024
bc06bec
add else statement
chrisjonesBSU Sep 13, 2024
b8b123b
move to_hoomdsnapshot to conversion, add method in Compound class. De…
chrisjonesBSU Sep 13, 2024
1767c84
fix import
chrisjonesBSU Sep 13, 2024
fb25fe4
remove hoomd writer file, add TODO flags to conversion
chrisjonesBSU Sep 13, 2024
47d8012
add TODO notes, pass in overwrite to Topology.save(), comment out fil…
chrisjonesBSU Sep 16, 2024
595455c
remove tests for gsd, hoomd, cassandra and par writers, move tests fo…
chrisjonesBSU Sep 16, 2024
b4d333a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 16, 2024
3b02288
add check for charges back in save method
chrisjonesBSU Sep 16, 2024
2d148d3
Merge branch 'remove-dep' of github.com:chrisjonesBSU/mbuild into rem…
chrisjonesBSU Sep 16, 2024
885daee
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 16, 2024
06c3c59
add if statement before checking charge is neutral
chrisjonesBSU Sep 16, 2024
053310a
remove .top from unit test
chrisjonesBSU Sep 17, 2024
af08a07
remove lammps and lammpsdata files from tests and support in conversi…
chrisjonesBSU Oct 3, 2024
5a60080
Don't use gmso mol2 backend
chrisjonesBSU Oct 5, 2024
955d999
Don't use gmso mol2 backend
chrisjonesBSU Oct 5, 2024
f5bdaf6
remove gmso as backend for mol2 saver
chrisjonesBSU Oct 6, 2024
b358ca4
remove Hoomd V3 test from CI
chrisjonesBSU Oct 6, 2024
d24c889
remove par writer and xyz reader/write
chrisjonesBSU Oct 6, 2024
b625c6b
pin gmso to latest ver in window env file
chrisjonesBSU Oct 21, 2024
e51631b
add has_hoomd back to io.py, handle tests that use hoomd via gmso
chrisjonesBSU Oct 25, 2024
d50d101
fix syntax
chrisjonesBSU Oct 25, 2024
e42cd01
remove unused import
chrisjonesBSU Oct 25, 2024
ef0b34f
update doc strings with new links, correct file types and methods
chrisjonesBSU Oct 26, 2024
bbffe82
add saver mapping to compound.save doc strings
chrisjonesBSU Oct 26, 2024
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
6 changes: 0 additions & 6 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ jobs:
- name: Test (OS -> ${{ matrix.os }} / Python -> ${{ matrix.python-version }})
run: python -m pytest -v --cov=mbuild --cov-report=xml --cov-append --cov-config=setup.cfg --color yes --pyargs mbuild

- name: Tests for HOOMD-blue (V3)
run: |
micromamba install -c conda-forge "hoomd>3"
python -m pytest -v --cov=mbuild --cov-report=xml --cov-append --cov-config=setup.cfg --color yes mbuild/tests/test_hoomd.py
if: runner.os == 'Linux'

- name: Upload Coverage Report
uses: codecov/codecov-action@v4
with:
Expand Down
3 changes: 1 addition & 2 deletions environment-dev-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
- bump2version
- codecov
- ele
- gmso>=0.9.0
- gmso>=0.12.4
- foyer>=0.11.0
- garnett>=0.7.1
- gsd>=2.9
Expand All @@ -20,7 +20,6 @@ dependencies:
- parmed>=3.4.3
- pip
- pre-commit
- protobuf
- py3Dmol
- pycifrw
- pytest
Expand Down
1 change: 0 additions & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ dependencies:
- parmed>=3.4.3
- pip
- pre-commit
- protobuf
- py3Dmol
- pycifrw
- pytest
Expand Down
77 changes: 27 additions & 50 deletions mbuild/compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,6 @@
os.path.join(tmp_dir, "tmp.mol2"),
include_ports=show_ports,
overwrite=True,
parmed_kwargs={"infer_residues": False},
)

view = py3Dmol.view()
Expand Down Expand Up @@ -2979,15 +2978,9 @@
self,
filename,
include_ports=False,
forcefield_name=None,
forcefield_files=None,
forcefield_debug=False,
box=None,
overwrite=False,
residues=None,
combining_rule="lorentz",
foyer_kwargs=None,
parmed_kwargs=None,
**kwargs,
):
"""Save the Compound to a file.
Expand All @@ -2997,22 +2990,11 @@
filename : str
Filesystem path in which to save the trajectory. The extension or
prefix will be parsed and control the format. Supported extensions:
'hoomdxml', 'gsd', 'gro', 'top', 'lammps', 'lmp', 'mcf', 'pdb', 'xyz',
'gsd', 'gro', 'top', 'lammps', 'lmp', 'mcf', 'pdb', 'xyz',
'json', 'mol2', 'sdf', 'psf'. See parmed/structure.py for more
information on savers.
include_ports : bool, optional, default=False
Save ports contained within the compound.
forcefield_files : str, optional, default=None
Apply a forcefield to the output file using a forcefield provided
by the `foyer` package.
forcefield_name : str, optional, default=None
Apply a named forcefield to the output file using the `foyer`
package, e.g. 'oplsaa'. `Foyer forcefields
<https://github.com/mosdef-hub/foyer/tree/master/foyer/forcefields>`_
forcefield_debug : bool, optional, default=False
Choose verbosity level when applying a forcefield through `foyer`.
Specifically, when missing atom types in the forcefield xml file,
determine if the warning is condensed or verbose.
box : mb.Box, optional, default=self.boundingbox (with buffer)
Box information to be written to the output file. If 'None', a
bounding box is used with 0.25nm buffers at each face to avoid
Expand All @@ -3022,37 +3004,24 @@
residues : str of list of str
Labels of residues in the Compound. Residues are assigned by
checking against Compound.name.
combining_rule : str, optional, default='lorentz'
Specify the combining rule for nonbonded interactions. Only relevant
when the `foyer` package is used to apply a forcefield. Valid
options are 'lorentz' and 'geometric', specifying Lorentz-Berthelot
and geometric combining rules respectively.
foyer_kwargs : dict, optional, default=None
Keyword arguments to provide to `foyer.Forcefield.apply`.
Depending on the file extension these will be passed to either
`write_gsd`, `write_hoomdxml`, `write_lammpsdata`,
`write_mcf`, or `parmed.Structure.save`.
See `parmed structure documentation
<https://parmed.github.io/ParmEd/html/structobj/parmed.structure.Structure.html#parmed.structure.Structure.save>`_
parmed_kwargs : dict, optional, default=None
Keyword arguments to provide to :meth:`mbuild.Compound.to_parmed`
#TODO 1.0: Update this kwargs, pass link to GMSO
chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved
**kwargs
Depending on the file extension these will be passed to either
`write_gsd`, `write_hoomdxml`, `write_lammpsdata`, `write_mcf`, or
`write_gsd`, `write_lammpsdata`, `write_mcf`, or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to pass the following conversion mapping in the documentation. Then we just link to

def save(
for more details?

`{GMSO: {".gro", ".gsd". ".data", ".xyz", ".mcf", ".top"},
ParmEd: {".mol2", ".pdb", ".prmtop", ".cif", ".crd"},
PyBel:{".sdf"}}`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. This should be done, along with the other suggestions.

chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved
`parmed.Structure.save`.
See https://parmed.github.io/ParmEd/html/structobj/parmed.structure.
Structure.html#parmed.structure.Structure.save

Other Parameters
----------------
ref_distance : float, optional, default=1.0
Normalization factor used when saving to .gsd and .hoomdxml formats
Normalization factor used when saving to the .gsd format
for converting distance values to reduced units.
ref_energy : float, optional, default=1.0
Normalization factor used when saving to .gsd and .hoomdxml formats
Normalization factor used when saving to the .gsd format
for converting energy values to reduced units.
ref_mass : float, optional, default=1.0
Normalization factor used when saving to .gsd and .hoomdxml formats
Normalization factor used when saving to the .gsd format
for converting mass values to reduced units.
atom_style: str, default='full'
Defines the style of atoms to be saved in a LAMMPS data file. The
Expand All @@ -3078,25 +3047,18 @@
--------
conversion.save : Main saver logic
formats.gsdwrite.write_gsd : Write to GSD format
formats.hoomdxml.write_hoomdxml : Write to Hoomd XML format
formats.xyzwriter.write_xyz : Write to XYZ format
formats.lammpsdata.write_lammpsdata : Write to LAMMPS data format
formats.cassandramcf.write_mcf : Write to Cassandra MCF format
formats.json_formats.compound_to_json : Write to a json file
"""
conversion.save(
self,
filename,
include_ports,
forcefield_name,
forcefield_files,
forcefield_debug,
box,
overwrite,
residues,
combining_rule,
foyer_kwargs,
parmed_kwargs,
compound=self,
filename=filename,
include_ports=include_ports,
box=box,
overwrite=overwrite,
residues=residues,
chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved
**kwargs,
)

Expand Down Expand Up @@ -3246,6 +3208,21 @@
"""
return conversion.to_gmso(self, **kwargs)

def to_hoomdsnapshot(self, **kwargs):
"""Create a HOOMD-Blue snapshot from an mBuild Compound.

Parameters
----------
compound : mb.Compound
The mb.Compound to be converted.

Returns
-------
snapshot : gsd.hoomd.Frame
HOOMD-Blue compatible topology.
"""
return conversion.to_hoomdsnapshot(self, **kwargs)

Check warning on line 3224 in mbuild/compound.py

View check run for this annotation

Codecov / codecov/patch

mbuild/compound.py#L3224

Added line #L3224 was not covered by tests

# Interface to Trajectory for reading/writing .pdb and .mol2 files.
# -----------------------------------------------------------------
def from_trajectory(
Expand Down
Loading
Loading