This repository is maintained by the KNIME Team Rakete.
It provides a template for creating a KNIME Python extension that integrates RDKit functionality.
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
├── src
│ └── __init.py__
│ └── extension.py
├── demos
│ └── demo-chemistry-python-adapter.knwf
├── tests
│ ├── test
│ └── conftest.py
│ └── test_extension.py
├── knime.yml
├── pixi.toml
├── config.yml
│── LICENSE.TXT
└── README.md
You can find general instructions on how to work with our code or develop python extensions for KNIME Analytics Platform in the KNIME documentation:
- Clone this repository or use it as a template (click on the green "Use this template" button).
- 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. - 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. - (Optional) Add python packages to the environment with the following command, or by manually editing the
pixi.toml
file:If you leave thepixi add <package_name>
pixi.toml
file unchanged, the Python environment that you will create in the next step will have the RDKit package installed per default. - Install the python environment:
pixi install
- 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 <path_to_this_repository> in theconfig.yml
):This will start the KNIME Analytics Platform with your extension installed. You can now test your extension in the KNIME Analytics Platform (e.g. demo workflow).-Dknime.python.extension.config=<path/to/your/config.yml>
- Bundle your extension:
or if you want the extension's local update site in a specific location (default is
pixi run build
./local_update_site
):pixi run build dest=<path_to_your_update_site>
- Install the update site in KNIME via
and enter the path to your update site (by default
File > Install KNIME Extensions... > Available Software Sites > Add...
./local_update_site
). After that, you can install your extension. - To publish on KNIME Hub, follow the KNIME Hub documentation.
For detailed instructions on how to create a KNIME Python extension, please refer to the KNIME Python Extension documentation.
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.