diff --git a/README.md b/README.md index ac55001..d861e40 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,28 @@ This repository is maintained by the [KNIME Team Rakete](mailto:team-rakete@knime.com). -It provides a template for creating KNIME Python extensions. +It provides a template for creating a KNIME Python extension that integrates [RDKit](https://rdkit.org/docs/index.html) functionality. ## Contents -This repository contains a template KNIME Python Extensions. +This repository contains a template KNIME Python Extension that integrates RDKit functionality. +It contains one simple example node that counts the number of carbons in molecules provided in an input table. +Note that this tutorial only works with KNIME AP version 5.6 or higher. The code is organized as follows: ``` . ├── icons -│ │── icon.png +│ └── icon.png ├── src +│ └── __init.py__ │ └── extension.py ├── demos -│ └── Example_with_Python_node.knwf +│ └── demo-chemistry-python-adapter.knwf +├── tests +│ ├── test +│ └── conftest.py +│ └── test_extension.py ├── knime.yml ├── pixi.toml ├── config.yml @@ -26,30 +33,32 @@ The code is organized as follows: └── README.md ``` -## Instructions +## General Instructions -You can find instructions on how to work with our code or develop python extensions for KNIME Analytics Platform in the KNIME documentation: +You can find general instructions on how to work with our code or develop python extensions for KNIME Analytics Platform in the KNIME documentation: * [KNIME Python Extension](https://docs.knime.com/latest/pure_python_node_extensions_guide/index.html) -## Minimal Instructions to create a KNIME Python extension +## Create a KNIME Python extension using RDKit based on this repository ### Prerequisites: * [KNIME Analytics Platform](https://www.knime.com/downloads/overview) * [git](https://git-scm.com/downloads) * [pixi](https://pixi.sh/latest/) + ### Instructions: -1. **Clone** this repository or use it as a **template** (click on the green "Use this template" button): -2. **Edit** `knime.yml` - provide your metadata, license, ... -3. _(Optional)_ Modify the `src/extension.py` file to implement your own logic. +1. **Clone** this repository or use it as a **template** (click on the green "Use this template" button). +2. **Edit** `knime.yml` to provide your metadata, license, etc. The last two lines of this file indicate that the extension created with this repository depends on the KNIME Base Chemistry Types & Nodes and the RDKit extensions. +3. **Modify** the `src/extension.py` file or **add** further files to implement your own logic. Note that every py file equivalent to one node needs to be imported in the init.py file. 4. _(Optional)_ Add python packages to the environment with the following command, or by manually editing the `pixi.toml` file: ```bash pixi add ``` + If you leave the `pixi.toml` file unchanged, the Python environment that you will create in the next step will have the RDKit package installed per default. 5. **Install** the python environment: ```bash pixi install ``` -6. **Test** the extension in the KNIME Analytics Platform with the extension in debug mode by adding the following line to the knime.ini file (adjust in the config.yml): +6. **Test** the extension in the KNIME Analytics Platform with the extension in debug mode by adding the following line to the `knime.ini` file (adjust in the `config.yml`): ``` -Dknime.python.extension.config= ``` @@ -71,6 +80,19 @@ You can find instructions on how to work with our code or develop python extensi For detailed instructions on how to create a KNIME Python extension, please refer to the [KNIME Python Extension documentation](https://docs.knime.com/latest/pure_python_node_extensions_guide/index.html). + +### Background information: +From KNIME AP version 5.6 on, the KNIME Base Chemistry Types & Nodes extension is shipped with extended adapator functionality between Python and Java. + +It also provides two functions designed to simplify the work of node developers: + +`to_rdkit_series`: convert a pandas series of KNIME chemistry types to a series of RDKit Mol objects + +`is_molecule`: True if the column holds any supported chemistry type + +The adaptor file can be found in the following location of the KNIME AP installation /plugins/org.knime.chem.types_/python/src/org/knime/types/chemistry.py. + + ## Join the Community * [KNIME Forum](https://forum.knime.com) \ No newline at end of file