Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
daico007 authored Oct 28, 2024
2 parents f7dcc30 + aabbab6 commit febc6c4
Show file tree
Hide file tree
Showing 25 changed files with 241 additions and 6,886 deletions.
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
111 changes: 39 additions & 72 deletions mbuild/compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,6 @@ def _visualize_py3dmol(
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 @@ def save(
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 @@ def save(
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',
'json', 'mol2', 'sdf', 'psf'. See parmed/structure.py for more
information on savers.
'gsd', 'gro', 'top', 'mcf', 'pdb', 'xyz',
'json', 'mol2', 'sdf', 'psf'. See `mbuild.conversion.save()`
for more information about writer methods.
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,50 +3004,25 @@ def save(
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`
**kwargs
See `mbuild.conversion.save()`.
Depending on the file extension these will be passed to either
`write_gsd`, `write_hoomdxml`, `write_lammpsdata`, `write_mcf`, or
`parmed.Structure.save`.
Parmed or GMSO backend writers
See https://parmed.github.io/ParmEd/html/structobj/parmed.structure.
Structure.html#parmed.structure.Structure.save
Structure.html#parmed.structure.Structure.save and
https://github.com/mosdef-hub/gmso/tree/main/gmso/formats
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
following atom styles are currently supported:
'full', 'atomic', 'charge', 'molecular'
See `LAMMPS atom style documentation
<https://lammps.sandia.gov/doc/atom_style.html>`_ for more
information.
unit_style: str, default='real'
Defines to unit style to be save in a LAMMPS data file. Defaults
to 'real' units. Current styles are supported: 'real', 'lj'. See
`LAMMPS unit style documentation_
<https://lammps.sandia.gov/doc/units.html>`_ for more information.
Notes
-----
Expand All @@ -3074,29 +3031,24 @@ def save(
* filename
* include_ports
The savers used for each supported file type are:
GMSO: .gro, .gsd, .data, .xyz, .mcf, .top
Parmed: .mol2, .pdb, .prmtop, .cif, .crd
PyBel: .sdf
See Also
--------
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
mbuild.conversion.save : Main saver logic
mbuild.formats.cassandramcf.write_mcf : Write to Cassandra MCF format
mbuild.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,
**kwargs,
)

Expand Down Expand Up @@ -3246,6 +3198,21 @@ def to_gmso(self, **kwargs):
"""
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)

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

0 comments on commit febc6c4

Please sign in to comment.