{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to load new libraries to Chemical Checker infrastructure" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## Load library files to datasource table\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "import sys\n", "sys.path.append(\"/aloy/home/oguitart/projects/source/chemical_checker/chemicalchecker\")\n", "\n", "os.environ[\"CC_CONFIG\"] = '/aloy/home/oguitart/projects/source/chemical_checker/chemicalchecker/tests/data/config.json'\n", "\n", "\n", "from chemicalchecker.util import Config\n", "\n", "from chemicalchecker.database import Datasource\n", "\n", "\n", "\n", "biur_real = {'name':\"biur_real\",'url':\"file:///aloy/scratch/sbnb-adm/checker/local_downloads/BIUR_20100326.sdf\",\n", " 'permanent':True,'enabled':False,'user':\"\",'password':\"\",'description':\"ChemistryX Biur real library\",\n", " 'molrepo_name':\"biur_real\",'molrepo_file':\"BIUR_20100326.sdf\",'is_db':False}\n", "biur_virtual = {'name':\"biur_virtual\",'url':\"file:///aloy/scratch/sbnb-adm/checker/local_downloads/VIRTUAL_BIUR_POR_MW.tar.gz\",\n", " 'permanent':True,'enabled':False,'user':\"\",'password':\"\",'description':\"ChemistryX Biur virtual library\",\n", " 'molrepo_name':\"biur_virtual\",'molrepo_file':\"VIRTUAL_BIUR_POR_MW\",'is_db':False}\n", "\n", "\n", "Datasource.add(biur_real)\n", "Datasource.add(biur_virtual)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Add Library parser\n", "\n", "Check the *package/chemicalchecker/util/parser/parser.py* file and add a method for each one of the new libraries to parse those libraries. \n", "The new method to parse the library should have the same name as the **molrepo_name** used in the datasource table. The output of the method should be the same as the other methods used in the **parser.py** file." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download & parse datasource associated to library \"biur_real\"\n", "\n", "1. Download the datasource files\n", "2. Parse downloaded files and load it to the molrepo table" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "import os\n", "import sys\n", "sys.path.append(\"/aloy/home/oguitart/projects/source/chemical_checker/chemicalchecker\")\n", "\n", "os.environ[\"CC_CONFIG\"] = '/aloy/home/oguitart/projects/source/chemical_checker/chemicalchecker/tests/data/config.json'\n", "\n", "\n", "from chemicalchecker.util import Config\n", "\n", "from chemicalchecker.database import Datasource, Molrepo\n", "\n", "# This method downloads all datasources related to this library \n", "# and parse the files to load the new data to the molrepo table\n", "\n", "Molrepo.from_molrepo_name(\"biur_real\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download datasource associated to library \"biur_virtual\"\n", "\n", "1. Download the datasource files\n", "2. Parse downloaded files and load it to the molrepo table" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "import os\n", "import sys\n", "sys.path.append(\"/aloy/home/oguitart/projects/source/chemical_checker/chemicalchecker\")\n", "\n", "os.environ[\"CC_CONFIG\"] = '/aloy/home/oguitart/projects/source/chemical_checker/chemicalchecker/tests/data/config.json'\n", "\n", "\n", "from chemicalchecker.util import Config\n", "\n", "from chemicalchecker.database import Datasource, Molrepo\n", "\n", "# This method downloads all datasources related to this library \n", "# and parse the files to load the new data to the molrepo table\n", "\n", "Molrepo.from_molrepo_name(\"biur_virtual\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Calculate the molecular properties and store them for library \"biur_real\"\n", "\n", "It will also add the missing molecules to the structure table\n", "It will create jobs to do this task in the cluster. \n", "It waits for a molecular property calculation to finish before submitting another one. \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "import os\n", "import sys\n", "import shutil\n", "\n", "sys.path.append(\"/aloy/home/oguitart/projects/source/chemical_checker/chemicalchecker\")\n", "\n", "os.environ[\"CC_CONFIG\"] = '/aloy/home/oguitart/projects/source/chemical_checker/chemicalchecker/tests/data/config.json'\n", "\n", "\n", "from chemicalchecker.database import Molprop, Structure\n", "from chemicalchecker.database import Molrepo\n", "from chemicalchecker.util import HPC\n", "from chemicalchecker.util import Config\n", "\n", "\n", "molprops = ['fp2d','fp3d','subskeys','scaffolds','physchem']\n", "\n", "molrepo_ik_inchi = Molrepo.get_fields_by_molrepo_name(\"biur_real\",[\"inchikey\",\"inchi\"])\n", "\n", "for mol in molprops:\n", "\n", " job_path = \"/aloy/scratch/oguitart/jobs_molprop_\" + mol\n", " if os.path.isdir(job_path):\n", " shutil.rmtree(job_path)\n", " os.mkdir(job_path)\n", "\n", " molprop = Molprop(mol)\n", "\n", " # This method sends the job and waits for the job to finish\n", " cluster = molprop.molprop_hpc(job_path,molrepo_ik_inchi)\n", " \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Calculate the molecular properties and store them for library \"biur_virtual\"\n", "\n", "It will create jobs to do this task in the cluster. \n", "It waits for a molecular property calculation to finish before submitting another one." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "import os\n", "import sys\n", "import shutil\n", "\n", "sys.path.append(\"/aloy/home/oguitart/projects/source/chemical_checker/chemicalchecker\")\n", "\n", "os.environ[\"CC_CONFIG\"] = '/aloy/home/oguitart/projects/source/chemical_checker/chemicalchecker/tests/data/config.json'\n", "\n", "cc_config = '/aloy/home/oguitart/projects/source/chemical_checker/chemicalchecker/tests/data/config.json'\n", "\n", "from chemicalchecker.database import Molprop, Structure\n", "from chemicalchecker.database import Molrepo\n", "from chemicalchecker.util import HPC\n", "from chemicalchecker.util import Config\n", "\n", "\n", "molprops = ['fp2d','fp3d','subskeys','scaffolds','physchem']\n", "\n", "molrepo_ik_inchi = Molrepo.get_fields_by_molrepo_name(\"biur_virtual\",[\"inchikey\",\"inchi\"])\n", "\n", "for mol in molprops:\n", "\n", " job_path = \"/aloy/scratch/oguitart/jobs_molprop_\" + mol\n", " if os.path.isdir(job_path):\n", " shutil.rmtree(job_path)\n", " os.mkdir(job_path)\n", "\n", " molprop = Molprop(mol)\n", "\n", " # This method sends the job and waits for the job to finish\n", " cluster = molprop.molprop_hpc(job_path,molrepo_ik_inchi)\n", " \n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.10" } }, "nbformat": 4, "nbformat_minor": 2 }