Skip to content

Commit

Permalink
ENH: Lay the groundwork fork for the Nano-CAT ligand branching workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Bas van Beek committed Jun 27, 2022
1 parent 141d4cc commit e837976
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CAT/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""The **CAT** version."""

__version__ = '0.11.0'
__version__ = '0.11.1'
8 changes: 8 additions & 0 deletions CAT/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions CAT/data_handling/validation_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
),
})


Expand Down
2 changes: 2 additions & 0 deletions CAT/workflows/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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] = ...
2 changes: 2 additions & 0 deletions CAT/workflows/key_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions CAT/workflows/key_map.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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] = ...
6 changes: 3 additions & 3 deletions CAT/workflows/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions CAT/workflows/workflow_dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
CDFT_MU_MINUS,
CDFT_MU_PLUS,
CONE_ANGLE,
BRANCH_DISTANCE,
BRANCH_SIZE,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions CAT/workflows/workflow_yaml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ All notable changes to this project will be documented in this file.
This project adheres to `Semantic Versioning <http://semver.org/>`_.


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
Expand Down
10 changes: 10 additions & 0 deletions docs/4_optional.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -588,6 +589,7 @@ Ligand
cosmo-rs: False
cdft: False
cone_angle: False
branch_distance: False
|
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e837976

Please sign in to comment.