{ "cells": [ { "cell_type": "markdown", "id": "728b369c", "metadata": {}, "source": [ "# Example to run MolGX with a pretrained model\n", "\n", "MolGX has been pretrained with a partial subset of the QM9 database consisting of 10 samples. This simple example shows how to generate molecules with the pretrained MolGX under GT4SD. \n", "Please check <a href=\"https://github.com/GT4SD/molgx-core/blob/main/example/jupyter_notebook/MolGX_tutorial.ipynb\">here</a> if you are interested in using the full capability of MolGX. \n" ] }, { "cell_type": "code", "execution_count": 1, "id": "fb1a7ccd-a46b-4eec-9b55-94f2f22c654c", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Using TensorFlow backend.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "INFO:toxsmi.utils.wrappers:Class weights are (1, 1).\n", "15:41:01 Class weights are (1, 1).\n", "INFO:toxsmi.utils.wrappers:Class weights are (1, 1).\n", "15:41:01 Class weights are (1, 1).\n", "INFO:tape.models.modeling_utils:Better speed can be achieved with apex installed from https://www.github.com/nvidia/apex .\n", "15:41:05 Better speed can be achieved with apex installed from https://www.github.com/nvidia/apex .\n" ] } ], "source": [ "from gt4sd.algorithms.conditional_generation.molgx.core import MolGX, MolGXQM9Generator\n", "\n", "import logging\n", "logging.disable(logging.INFO)" ] }, { "cell_type": "code", "execution_count": 2, "id": "c688965b-45f8-4814-b088-7cf6167a348f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'target_property': {'homo': (-10, 10), 'lumo': (-10, 10)}, 'use_linear_model': True, 'num_candidate': 2, 'max_candidate': 5, 'max_solution': 10, 'max_node': 50000, 'beam_size': 2000, 'without_estimate': True, 'use_specific_rings': True, 'use_fragment_const': False}\n", "['c1cocn1', 'c1cnoc1', 'c1ccoc1']\n" ] } ], "source": [ "configuration = MolGXQM9Generator()\n", "algorithm = MolGX(configuration=configuration)\n", "items = list(algorithm.sample(3))\n", "print(items)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.13" } }, "nbformat": 4, "nbformat_minor": 5 }