diff --git a/CAT/__version__.py b/CAT/__version__.py index 3f404c4f..c691e27f 100644 --- a/CAT/__version__.py +++ b/CAT/__version__.py @@ -1,3 +1,3 @@ """The **CAT** version.""" -__version__ = '0.11.0' +__version__ = '0.11.1' diff --git a/CAT/base.py b/CAT/base.py index 0e7071bf..ebeca012 100644 --- a/CAT/base.py +++ b/CAT/base.py @@ -59,6 +59,7 @@ from nanoCAT.cdft import init_cdft if Version(nanoCAT.__version__) >= Version("0.7.2"): from nanoCAT.cone_angle import init_cone_angle + from nanoCAT.bulk.mol_graph2 import init_branch_distance NANO_CAT: Optional[ImportError] = None except ImportError as ex: @@ -258,6 +259,7 @@ def prep_ligand(ligand_df: SettingsDataFrame) -> SettingsDataFrame: crs = ligand_df.settings.optional.ligand.crs cdft = ligand_df.settings.optional.ligand.cdft cone_angle = ligand_df.settings.optional.ligand.cone_angle + branch_distance = ligand_df.settings.optional.ligand.branch_distance # Identify functional groups within the ligand. ligand_df = init_ligand_anchoring(ligand_df) @@ -278,6 +280,12 @@ def prep_ligand(ligand_df: SettingsDataFrame) -> SettingsDataFrame: for lig in ligand_df[MOL]: allign_axis(lig) + if branch_distance: + val_nano_cat("The ligand branch-distance workflow requires the nano-CAT package") + if Version(nanoCAT.__version__) < Version("0.7.2"): + raise ImportError("The `cone_angle` workflow require Nano-CAT 0.7.2") + init_branch_distance(ligand_df) + # Perform a COSMO-RS calculation on the ligands if crs: val_nano_cat("Ligand COSMO-RS calculations require the nano-CAT package") diff --git a/CAT/data_handling/validation_schemas.py b/CAT/data_handling/validation_schemas.py index 962286bb..2bd2d2c3 100644 --- a/CAT/data_handling/validation_schemas.py +++ b/CAT/data_handling/validation_schemas.py @@ -517,6 +517,12 @@ def _get_crsjob() -> type: And(bool, Use(lambda n: {'job1': 'ADFJob'} if n else False)), error='optional.ligand.cdft expects a boolean or dictionary' ), + + Optional_('branch_distance', default=False): + Or( + bool, + error='optional.ligand.branch_distance expects a boolean' + ), }) diff --git a/CAT/workflows/__init__.pyi b/CAT/workflows/__init__.pyi index 1dd7bbca..b7cc0c55 100644 --- a/CAT/workflows/__init__.pyi +++ b/CAT/workflows/__init__.pyi @@ -42,3 +42,5 @@ SETTINGS_BDE2: Tuple[str, str] = ... SETTINGS_CDFT: Tuple[str, str] = ... V_BULK: Tuple[str, str] = ... CONE_ANGLE: Tuple[str, str] = ... +BRANCH_DISTANCE: Tuple[str, str] = ... +BRANCH_SIZE: Tuple[str, str] = ... diff --git a/CAT/workflows/key_map.py b/CAT/workflows/key_map.py index 52a389d2..f97d403e 100644 --- a/CAT/workflows/key_map.py +++ b/CAT/workflows/key_map.py @@ -55,6 +55,8 @@ 'SETTINGS_CDFT': ('settings', 'cdft 1'), 'V_BULK': ('V_bulk', ''), 'CONE_ANGLE': ('cone_angle', 'dist=0.0'), + 'BRANCH_DISTANCE': ('branch_distance', ''), + 'BRANCH_SIZE': ('branch_size', ''), }) globals().update(KEY_MAP) diff --git a/CAT/workflows/key_map.pyi b/CAT/workflows/key_map.pyi index 46dba8b9..f588a7db 100644 --- a/CAT/workflows/key_map.pyi +++ b/CAT/workflows/key_map.pyi @@ -41,3 +41,5 @@ SETTINGS_BDE2: Tuple[str, str] = ... SETTINGS_CDFT: Tuple[str, str] = ... V_BULK: Tuple[str, str] = ... CONE_ANGLE: Tuple[str, str] = ... +BRANCH_DISTANCE: Tuple[str, str] = ... +BRANCH_SIZE: Tuple[str, str] = ... diff --git a/CAT/workflows/workflow.py b/CAT/workflows/workflow.py index 8c3e6885..da9e17cc 100644 --- a/CAT/workflows/workflow.py +++ b/CAT/workflows/workflow.py @@ -413,12 +413,12 @@ def __call__(self, func: Callable, df: pd.DataFrame, else: try: df.loc[slice2] = value - except ValueError as ex: + except ValueError: logger.debug(f"df = {aNDRepr.repr(df)}") logger.debug(f"index = {aNDRepr.repr(slice2[0])}") logger.debug(f"columns = {aNDRepr.repr(slice2[1])}") logger.debug(f"value = {aNDRepr.repr(value)}") - raise ex + raise logger.info(f"Finishing {self.description}\n") def from_db(self, df: pd.DataFrame, inplace: bool = True, get_mol: bool = False, @@ -624,7 +624,7 @@ def _isnull(df: pd.DataFrame, columns: list) -> pd.DataFrame: np.dtype(bool): operator.invert, np.dtype(int): _lt_0, np.dtype(float): pd.isnull, - np.dtype(object): pd.isnull + np.dtype(object): lambda i: pd.isnull(i) | (i == ""), } ret = pd.DataFrame(index=df.index) diff --git a/CAT/workflows/workflow_dicts.py b/CAT/workflows/workflow_dicts.py index 423f7eaa..8b50c06e 100644 --- a/CAT/workflows/workflow_dicts.py +++ b/CAT/workflows/workflow_dicts.py @@ -44,6 +44,8 @@ CDFT_MU_MINUS, CDFT_MU_PLUS, CONE_ANGLE, + BRANCH_DISTANCE, + BRANCH_SIZE, ) if TYPE_CHECKING: @@ -113,6 +115,8 @@ def finalize_templates(): CDFT_MU_MINUS, CDFT_MU_PLUS)}, 'cone_angle': {'import_columns': {CONE_ANGLE: np.nan}, 'export_columns': (CONE_ANGLE,)}, + 'branch_distance': {'import_columns': {BRANCH_DISTANCE: "", BRANCH_SIZE: ""}, + 'export_columns': (BRANCH_DISTANCE, BRANCH_SIZE)}, } templates = _load_templates() diff --git a/CAT/workflows/workflow_yaml.yaml b/CAT/workflows/workflow_yaml.yaml index 12640152..4d1e11e2 100644 --- a/CAT/workflows/workflow_yaml.yaml +++ b/CAT/workflows/workflow_yaml.yaml @@ -192,3 +192,13 @@ cdft: keep_files: [optional, ligand, cdft, keep_files] job1: [optional, ligand, cdft, job1] s1: [optional, ligand, cdft, s1] + +branch_distance: + description: Ligand branch size & distance computation + mol_type: ligand + template: + db: [optional, database, db] + read: [optional, database, read] + write: [optional, database, write] + overwrite: [optional, database, overwrite] + thread_safe: [optional, database, thread_safe] diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f6a55c68..8cee2175 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,11 @@ All notable changes to this project will be documented in this file. This project adheres to `Semantic Versioning `_. +0.11.1 +****** +* Lay the groundwork for the new Nano-CAT ligand branching workflow. + + 0.11.0 ****** * Add the `remove_anchor_hydrogens` option to the cone-angle workflow diff --git a/docs/4_optional.rst b/docs/4_optional.rst index bc31f266..09c67e5d 100644 --- a/docs/4_optional.rst +++ b/docs/4_optional.rst @@ -36,6 +36,7 @@ Option Description :attr:`optional.ligand.cosmo-rs` Perform a property calculation with COSMO-RS on the ligand. :attr:`optional.ligand.cdft` Perform a conceptual DFT calculation with ADF on the ligand. :attr:`optional.ligand.cone_angle` Compute the smallest enclosing cone angle within a ligand. +:attr:`optional.ligand.branch_distance` Compute the size of branches and their distance w.r.t. to the anchor within a ligand. :attr:`optional.qd.dirname` The name of the directory where all quantum dots will be stored. :attr:`optional.qd.construct_qd` Whether or not the quantum dot should actually be constructed or not. @@ -588,6 +589,7 @@ Ligand cosmo-rs: False cdft: False cone_angle: False + branch_distance: False | @@ -943,6 +945,14 @@ Ligand Accepts one or more distances. + + .. attribute:: optional.ligand.branch_distance + + :Parameter: * **Type** - :class:`bool` + * **Default value** – ``False`` + + Compute the size of branches and their distance w.r.t. to the anchor within a ligand. + | QD diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 256402ca..f3b62085 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -129,6 +129,7 @@ def test_ligand_schema() -> None: 'cosmo-rs': False, 'cdft': False, 'cone_angle': False, + 'branch_distance': False, } assertion.eq(ligand_schema.validate(lig_dict), ref) diff --git a/tests/test_validate_input.py b/tests/test_validate_input.py index 8008928f..1f81acae 100644 --- a/tests/test_validate_input.py +++ b/tests/test_validate_input.py @@ -68,6 +68,7 @@ def test_validate_input() -> None: ref.ligand.split = True ref.ligand.cdft = False ref.ligand.cone_angle = False + ref.ligand.branch_distance = False ref.qd.bulkiness = False ref.qd.construct_qd = True