Skip to content

Commit

Permalink
Fix AmberParm.from_structure with CMAPs (#1233)
Browse files Browse the repository at this point in the history
* Add a test that fails with the current bug

* Fix the bug
  • Loading branch information
swails committed Feb 18, 2022
1 parent 020cf89 commit c848e17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion parmed/amber/_amberparm.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def from_structure(cls, struct, copy=False):
return struct
if struct.unknown_functional:
raise TypeError('Cannot instantiate an AmberParm from unknown functional')
if (struct.urey_bradleys or struct.impropers or struct.cmaps or
if (struct.urey_bradleys or struct.impropers or
struct.trigonal_angles or struct.pi_torsions or
struct.out_of_plane_bends or struct.stretch_bends or
struct.torsion_torsions or struct.multipole_frames):
Expand Down
7 changes: 5 additions & 2 deletions test/test_parmed_amber.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy as np
import os
import re
import sys
from io import StringIO
import parmed as pmd
from parmed.amber import (
Expand All @@ -21,6 +20,7 @@
from parmed.tools import change
import parmed.unit as u
from parmed.utils import PYPY
from parmed.gromacs import GromacsTopologyFile
import pickle
import random
import saved_outputs as saved
Expand All @@ -30,7 +30,6 @@
get_fn, FileIOTestCase, equal_atoms, create_random_structure, HAS_GROMACS,
diff_files, has_openmm
)
import warnings
from string import ascii_letters as letters

def _picklecycle(obj):
Expand Down Expand Up @@ -360,6 +359,10 @@ def check_parm_for_cmap(parm):
parm2.write_parm(f)
f.seek(0)
check_parm_for_cmap(readparm.AmberParm(f))
# Check that from_structure works correctly when reading from GROMACS with just cmap
from_struct_parm = readparm.AmberParm.from_structure(GromacsTopologyFile.from_structure(parm))
self.assertIs(type(from_struct_parm), type(parm))
check_parm_for_cmap(from_struct_parm)

def test_chamber_gas_parm(self):
"""Test the ChamberParm class with a non-periodic (gas phase) prmtop"""
Expand Down

0 comments on commit c848e17

Please sign in to comment.