Skip to content

Commit

Permalink
Merge branch 'main' into rdkit_vis
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjonesBSU committed Oct 18, 2023
2 parents acba7c3 + 7142f41 commit 0e8cbe7
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
runs-on: ubuntu-latest
needs: test
name: Build Docker Image
if: ${{ false }}
if: github.event_name != 'pull_request'

steps:
- name: Set up Docker Buildx
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ ci:
submodules: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: setup.cfg
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black
args: [--line-length=80]
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PY_VERSION=3.8
ARG PY_VERSION=3.10
FROM continuumio/miniconda3:4.10.3-alpine AS builder

EXPOSE 8888
Expand All @@ -17,6 +17,9 @@ WORKDIR /mbuild
# Create a group and user
RUN addgroup -S anaconda && adduser -S anaconda -G anaconda

# install the libarchive package needed by mamba
RUN apk update && apk add libarchive

RUN conda update conda -yq && \
conda config --set always_yes yes --set changeps1 no && \
. /opt/conda/etc/profile.d/conda.sh && \
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@
# built documents.
#

version = "0.16.3"
release = "0.16.3"
version = "0.16.4"
release = "0.16.4"


# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down
1 change: 1 addition & 0 deletions docs/docs-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ dependencies:
- lxml
- numpydoc
- widgetsnbextension
- mock
2 changes: 1 addition & 1 deletion mbuild/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
from mbuild.port import Port
from mbuild.recipes import recipes

__version__ = "0.16.3"
__version__ = "0.16.4"
4 changes: 3 additions & 1 deletion mbuild/compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -2904,7 +2904,9 @@ 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'
'hoomdxml', 'gsd', 'gro', 'top', 'lammps', 'lmp', 'mcf', 'pdb', 'xyz',
'json', 'mol2', 'sdf', 'psf'. See parmed/structure.py for more
information on savers.
show_ports : bool, optional, default=False
Save ports contained within the compound.
forcefield_files : str, optional, default=None
Expand Down
4 changes: 3 additions & 1 deletion mbuild/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,9 @@ 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 are:
'hoomdxml', 'gsd', 'gro', 'top', 'lammps', 'lmp', 'mcf'.
'hoomdxml', 'gsd', 'gro', 'top', 'lammps', 'lmp', 'mcf', 'xyz', 'pdb',
'sdf', 'mol2', 'psf'. See parmed/structure.py for more information on
savers.
show_ports : bool, optional, default=False
Save ports contained within the compound.
forcefield_files : str, optional, default=None
Expand Down
5 changes: 4 additions & 1 deletion mbuild/formats/xyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def read_xyz(filename, compound=None):

guessed_elements = set()

compound_list = []
with open(filename, "r") as xyz_file:
n_atoms = int(xyz_file.readline())
xyz_file.readline()
Expand Down Expand Up @@ -74,7 +75,7 @@ def read_xyz(filename, compound=None):
element = None

particle = mb.Compound(pos=coords[row], name=name, element=element)
compound.add(particle)
compound_list.append(particle)

# Verify we have read the last line by ensuring the next line in blank
line = xyz_file.readline().split()
Expand All @@ -86,6 +87,8 @@ def read_xyz(filename, compound=None):
)
raise MBuildError(msg.format(n_atoms))

compound.add(compound_list)

return compound


Expand Down
14 changes: 11 additions & 3 deletions mbuild/packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ def solvate(
fix_orientation=False,
temp_file=None,
update_port_locations=False,
center_solute=True,
):
"""Solvate a compound in a box of solvent using PACKMOL.
Expand Down Expand Up @@ -701,6 +702,8 @@ def solvate(
update_port_locations : bool, default=False
After packing, port locations can be updated, but since compounds can be
rotated, port orientation may be incorrect.
center_solute : bool, optional, default=True
Move solute center of mass to the center of the `mb.Box` used.
Returns
-------
Expand All @@ -724,8 +727,10 @@ def solvate(
box_mins = np.asarray(min_tmp) * 10
box_maxs = np.asarray(max_tmp) * 10
overlap *= 10
center_solute = (box_maxs + box_mins) / 2

if center_solute:
center_solute = (box_maxs + box_mins) / 2
else:
center_solute = solute.pos * 10
# Apply edge buffer
box_maxs = np.subtract(box_maxs, edge * 10)
box_mins = np.add(box_mins, edge * 10)
Expand Down Expand Up @@ -888,9 +893,12 @@ def _create_topology(container, comp_to_add, n_compounds):
container : mb.Compound
Compound with added compounds from PACKMOL.
"""
container_list = []
for comp, m_compound in zip(comp_to_add, n_compounds):
for _ in range(m_compound):
container.add(clone(comp))
container_list.append(clone(comp))

container.add(container_list)
return container


Expand Down
2 changes: 1 addition & 1 deletion mbuild/tests/test_compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def test_show_hierarchy(self, capsys):
temp_particle.print_hierarchy()

captured = capsys.readouterr()
assert captured.out.strip() == "C, 1 particles, 0 bonds, 0 children"
assert "C, 1 particles, 0 bonds, 0 children" in captured.out.strip()

temp_particle.print_hierarchy(show_tree=False)
captured = capsys.readouterr()
Expand Down
21 changes: 18 additions & 3 deletions mbuild/tests/test_packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,24 @@ def test_fill_box_multiple(self, ethane, h2o):

def test_solvate(self, ethane, h2o):
n_solvent = 100
solvated = mb.solvate(ethane, h2o, n_solvent=n_solvent, box=[4, 4, 4])
assert solvated.n_particles == 8 + n_solvent * 3
assert solvated.n_bonds == 7 + n_solvent * 2
ethane_pos = ethane.pos
solvated1 = mb.solvate(
ethane, h2o, n_solvent=n_solvent, box=[4, 4, 4], center_solute=True
)
solvated2 = mb.solvate(
ethane, h2o, n_solvent=n_solvent, box=[4, 4, 4], center_solute=False
)

print(ethane.xyz)
print(solvated2.children[0].xyz)

assert (
solvated1.n_particles == solvated2.n_particles == 8 + n_solvent * 3
)
assert solvated1.n_bonds == solvated2.n_bonds == 7 + n_solvent * 2
assert not np.isclose(solvated1.children[0].pos, ethane_pos).all()
assert np.isclose(solvated2.children[0].pos, ethane_pos).all()

assert ethane.parent == None

def test_solvate_multiple(self, methane, ethane, h2o):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.16.3
current_version = 0.16.4
commit = True
tag = True
message = Bump to version {new_version}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#####################################
NAME = "mbuild"
VERSION = "0.16.3"
VERSION = "0.16.4"
ISRELEASED = True
if ISRELEASED:
__version__ = VERSION
Expand Down

0 comments on commit 0e8cbe7

Please sign in to comment.