From e20bd2665f9b34d2fdc8d4caf1317b30a46bffcd Mon Sep 17 00:00:00 2001 From: Marti Municoy Date: Thu, 6 Aug 2020 00:40:20 +0200 Subject: [PATCH] Fix proper and improper constructors --- offpele/main.py | 2 +- offpele/topology/molecule.py | 34 ++++++++++++++++++---------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/offpele/main.py b/offpele/main.py index 65e371b5..4aeb6df2 100644 --- a/offpele/main.py +++ b/offpele/main.py @@ -143,7 +143,7 @@ def run_offpele(pdb_file, forcefield=DEFAULT_OFF_FORCEFIELD, not """ print('-' * 60) - print('Open Force Field parameterizer for PELE v' + print('Open Force Field parameterizer for PELE ' '{}'.format(offpele.__version__)) print('-' * 60) print(' - PDB to parameterize: {}'.format(pdb_file)) diff --git a/offpele/topology/molecule.py b/offpele/topology/molecule.py index 1d091971..a5cb89e2 100644 --- a/offpele/topology/molecule.py +++ b/offpele/topology/molecule.py @@ -748,16 +748,17 @@ def _build_propers(self): ks = self.parameters.get_dihedral_ks() idivfs = self.parameters.get_dihedral_idivfs() - # idivf is a optional parameter in OpenForceField - if idivfs is not None: - if len(idivfs) == 0: - for period_by_index in periodicities: - idivfs.append(dict(zip( - period_by_index.keys(), - [1, ] * len(period_by_index.keys())))) - else: + # TODO in which situation these dicts are supposed to be None? + if periodicities is None or phases is None or ks is None: return + # idivf is a optional parameter in OpenForceField + if len(idivfs) == 0: + for period_by_index in periodicities: + idivfs.append(dict(zip( + period_by_index.keys(), + [1, ] * len(period_by_index.keys())))) + assert len(periodicities) == len(phases) and \ len(periodicities) == len(ks) and \ len(periodicities) == len(idivfs), 'Unconsistent set of ' \ @@ -823,16 +824,17 @@ def _build_impropers(self): ks = self.parameters.get_improper_ks() idivfs = self.parameters.get_improper_idivfs() - # idivf is a optional parameter in OpenForceField - if idivfs is not None: - if len(idivfs) == 0: - for period_by_index in periodicities: - idivfs.append(dict(zip( - period_by_index.keys(), - [1, ] * len(period_by_index.keys())))) - else: + # TODO in which situation these dicts are supposed to be None? + if periodicities is None or phases is None or ks is None: return + # idivf is a optional parameter in OpenForceField + if len(idivfs) == 0: + for period_by_index in periodicities: + idivfs.append(dict(zip( + period_by_index.keys(), + [1, ] * len(period_by_index.keys())))) + assert len(periodicities) == len(phases) and \ len(periodicities) == len(ks) and \ len(periodicities) == len(idivfs), 'Unconsistent set of ' \