From 51c602ec79e75b0ffa4061d045dde07523ebe841 Mon Sep 17 00:00:00 2001 From: "mlehner@ethz.ch" Date: Fri, 18 Mar 2022 13:24:34 +0100 Subject: [PATCH] adding in_mol2 to amber --- .../files/forcefield/_generic_force_field.py | 6 +++--- pygromos/files/forcefield/amber/amberff.py | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/pygromos/files/forcefield/_generic_force_field.py b/pygromos/files/forcefield/_generic_force_field.py index 7ebcc084..f1ca2e91 100644 --- a/pygromos/files/forcefield/_generic_force_field.py +++ b/pygromos/files/forcefield/_generic_force_field.py @@ -28,11 +28,11 @@ def __init__( if auto_import: self.auto_import_ff() - def auto_import_ff(self): + def auto_import_ff(self, **kwargs): raise NotImplementedError("This is a template class! It'should be used as a super class for all forcefields!") - def create_top(self, mol: str, in_top: Top = None) -> Top: + def create_top(self, mol: str, in_top: Top = None, **kwargs) -> Top: raise NotImplementedError("This is a template class! It'should be used as a super class for all forcefields!") - def create_cnf(self, mol: str, in_cnf: Cnf = None) -> Cnf: + def create_cnf(self, mol: str, in_cnf: Cnf = None, **kwargs) -> Cnf: raise NotImplementedError("This is a template class! It'should be used as a super class for all forcefields!") diff --git a/pygromos/files/forcefield/amber/amberff.py b/pygromos/files/forcefield/amber/amberff.py index a53f18c3..d66e9993 100644 --- a/pygromos/files/forcefield/amber/amberff.py +++ b/pygromos/files/forcefield/amber/amberff.py @@ -46,9 +46,13 @@ def auto_import_ff(self): if not os.path.isfile(frcmod): raise ImportError("could not find ff file " + frcmod) - def create_top(self, mol: str, in_top: Top = None) -> Top: + def create_top(self, mol: str, in_top: Top = None, in_mol2_file: str = None) -> Top: + self.mol = mol + self.in_mol2_file = in_mol2_file + if self.amber is None: - self.create_mol2() + if in_mol2_file is None: + self.create_mol2() self.amber = amber2gromos( in_mol2_file=self.in_mol2_file, mol=self.mol, @@ -56,7 +60,14 @@ def create_top(self, mol: str, in_top: Top = None) -> Top: gromosPP=self.gromosPP, work_folder=self.work_folder, ) - self.top = Top(self.amber.get_gromos_topology()) + if in_top is None: + self.top = Top(self.amber.get_gromos_topology()) + elif isinstance(in_top, Top): + self.top = in_top + Top(self.amber.get_gromos_topology()) + elif isinstance(in_top, str): + self.top = Top(in_top) + Top(self.amber.get_gromos_topology()) + else: + raise TypeError("in_top is of wrong type") def create_cnf(self, mol: str, in_cnf: Top = None) -> Cnf: if self.amber is None: