Skip to content

marc-lehner/knime_rdkit_python_demo

Repository files navigation

Image KNIME® - KNIME PYTHON EXTENSION TEMPLATE

CI

This repository is maintained by the KNIME Team Rakete.

It provides a template for creating a KNIME Python extension that integrates RDKit functionality.

Contents

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

General Instructions

You can find general instructions on how to work with our code or develop python extensions for KNIME Analytics Platform in the KNIME documentation:

Create a KNIME Python extension using RDKit based on this repository

Prerequisites:

Instructions:

  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:
    pixi add <package_name>
    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:
    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 <path_to_this_repository> in the config.yml):
    -Dknime.python.extension.config=<path/to/your/config.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).
  7. Bundle your extension:
    pixi run build
    or if you want the extension's local update site in a specific location (default is ./local_update_site):
    pixi run build dest=<path_to_your_update_site>
  8. Install the update site in KNIME via
    File > Install KNIME Extensions... > Available Software Sites > Add... 
    and enter the path to your update site (by default ./local_update_site). After that, you can install your extension.
  9. 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.

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

About

This is a demo/test repo to test chemistry types as a python knime extension, using rdkit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages