Skip to content

Commit

Permalink
Merge branch 'main' into 561-layered-dihedrals
Browse files Browse the repository at this point in the history
  • Loading branch information
daico007 committed May 10, 2022
2 parents 6140f01 + 3a387c7 commit ca1afa1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions gmso/formats/mol2.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def _parse_lj(top, section):
warnings.warn(
f"No charge was detected for site {content[1]} with index {content[0]}"
)
charge = None

atom = Atom(
name=content[1],
Expand Down
12 changes: 12 additions & 0 deletions gmso/tests/files/methane_missing_charge.mol2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@<TRIPOS>MOLECULE
RES
1 0 1 0 1
SMALL
NO_CHARGES
@<TRIPOS>CRYSIN
5.0000 5.0000 5.0000 90.0000 90.0000 90.0000 1 1
@<TRIPOS>ATOM
1 _CH4 0.0000 0.0000 0.0000 CH4 1 RES
@<TRIPOS>BOND
@<TRIPOS>SUBSTRUCTURE
1 RES 1 RESIDUE 0 **** ROOT 0
10 changes: 10 additions & 0 deletions gmso/tests/test_mol2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from gmso import Topology
from gmso.formats.mol2 import from_mol2
from gmso.tests.base_test import BaseTest
from gmso.tests.utils import get_path
from gmso.utils.io import get_fn


Expand Down Expand Up @@ -102,6 +103,15 @@ def test_lj_system(self):
top = Topology.load(get_fn("methane.mol2"), site_type="lj")
assert np.all([site.element == None for site in top.sites])

def test_no_charge_lj(self):
with pytest.warns(
UserWarning,
match="No charge was detected for site .* with index \d+$",
):
top = Topology.load(
get_path("methane_missing_charge.mol2"), site_type="lj"
)

def test_wrong_path(self):
with pytest.raises(
OSError, match=r"Provided path to file that does not exist"
Expand Down

0 comments on commit ca1afa1

Please sign in to comment.