From f449083de1510cc9b6974b56c82200f166dc8778 Mon Sep 17 00:00:00 2001 From: Lee-Ping Wang Date: Mon, 4 Sep 2023 21:09:12 -0700 Subject: [PATCH] Fix g96 file reading --- src/amberio.py | 5 ++++- src/molecule.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/amberio.py b/src/amberio.py index b231859cd..10d36d4bd 100644 --- a/src/amberio.py +++ b/src/amberio.py @@ -28,7 +28,10 @@ from forcebalance.molecule import Molecule from collections import OrderedDict, defaultdict, namedtuple # Rudimentary NetCDF file usage -from scipy.io.netcdf import netcdf_file +try: + from scipy.io import netcdf_file +except ImportError: + from scipy.io.netcdf import netcdf_file import warnings try: # Some functions require the Python API to sander "pysander" diff --git a/src/molecule.py b/src/molecule.py index 736d9de06..644b05dfd 100644 --- a/src/molecule.py +++ b/src/molecule.py @@ -3432,7 +3432,10 @@ def read_g96(self, fnm, **kwargs): if len(xyzs) != len(boxes): raise IOError('in read_g96: xyzs and boxes should have the same length') if len(xyzs) != len(comms): - raise IOError('in read_g96: xyzs and comms should have the same length') + if len(comms) < len(xyzs): + comms += [comms[-1] for i in range(len(comms), len(xyzs))] + else: + raise IOError('comms is longer than xyzs') Answer = {'xyzs' : xyzs, 'boxes' : boxes, 'comms' : comms}