Conversions

Back to main page

Introduction

Orchem contains functionality to convert between different chemical notations. It uses the the ConvertMolecule.java class located in Java package 'uk.ac.ebi.orchem.convert'. This class includes methods to convert:
  • SMILES → Molfile
  • Molfile → SMILES
  • Molfile → Jpeg (using JChemPaint)
  • Molfile → InChi
You interact with these classes through PL/SQL packages that wrap the classes as Java stored functions. These functions will be explained in the following sections and some example queries will be given.


Smiles To Molfile

Package.function: ORCHEM_CONVERT.SMILESTOMOLFILE.

The function SMILESTOMOLFILE converts a Smiles to Molfile string:
  • Input : SMILES (CLOB): a SMILES pattern
  • input : gen_coords (VARCHAR2): optional, indicate with 'Y' or 'N' (default) if you want 2D coordinates generated for the molecule. Generating coordinates can be relatively expensive, especially for large structures.
  • Input : USE_BOND_TYPE_4 (VARCHAR2): optional, indicate with 'Y' or 'N' (default) if you want aromatic bonds in the SMILES preserved as MOL file bond type "4". This is relevant if you do not Kekule notation, see the example below for c1ccccc1. With USE_BOND_TYPE_4=>'N', aromaticity is lost in the MOLfile output as the bond types become "1" (single).
  • Output: CLOB, an MDL mol file
Example


select orchem_convert.smilestomolfile('c1ccccc1',USE_BOND_TYPE_4=>'Y') from dual

OUTPUT:
-------

  CDK     0715101546

  6  6  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  2  1  4  0  0  0  0
  3  2  4  0  0  0  0
  4  3  4  0  0  0  0
  5  4  4  0  0  0  0
  6  5  4  0  0  0  0
  6  1  4  0  0  0  0
M  END


select orchem_convert.smilestomolfile('c1ccccc1',USE_BOND_TYPE_4=>'N') from dual
OUTPUT
------

  CDK     0715101546

  6  6  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  2  1  1  0  0  0  0
  3  2  1  0  0  0  0
  4  3  1  0  0  0  0
  5  4  1  0  0  0  0
  6  5  1  0  0  0  0
  6  1  1  0  0  0  0
M  END




Molfile To Smiles

Package.function: ORCHEM_CONVERT.MOLFILETOSMILES.

The function MOLFILETOSMILES converts a Molfile to Smiles string:
  • MOLFILE (CLOB): a string MDL mol file
  • RETURN (CLOB): a string SMILES converted
Example

select orchem_convert.molfiletosmiles(orchem_convert.smilestomolfile('CC1CCCC1')) as smi from dual

SMI
--------------------------------------------------------------------------------
CC1CCCC1

Elapsed: 00:00:00.03





Molfile To Jpeg

Package.function: ORCHEM_CONVERT.MOLFILETOJPEG.

The function MOLFILETOJPEG converts a Molfile to a picture in JPEG format, using JChemPaint software.
  • MOLFILE (CLOB): a string MDL molfile
  • HSIZE (NUMBER): a numeric horizontal size
  • VSIZE (NUMBER): a numeric vertical size
  • RETURN (BLOB): a Jpeg Image displaying the chemical structure
For database 11g
There is a Bug 7184929 regarding the fonts in Oracle Server - Version: 11.1.0.6 to 11.1.0.7

Implement the workaround (check Oracle Metalink Note): 604472.1

- mkdir $ORACLE_HOME/javavm/lib/fonts

- cp $ORACLE_HOME/jdk/jre/lib/fonts/* $ORACLE_HOME/javavm/lib/fonts

Example

declare mdl clob; pic blob;
begin
   select molfile into mdl from orchem_compound_sample where id=42;
   pic:=orchem_convert.MOLFILETOJPEG(mdl,800,600);
end;

RESULT pic:



Molfile To InChi

Package.function: ORCHEM_CONVERT.MOLFILETOINCHI.

The function MOLFILETOINCHI converts a Molfile to an InChi string:
  • MOLFILE (CLOB): a string MDL molfile
  • OUTPUT_TYPE (VARCHAR2): defaults to 'INCHI', set it to 'INCHI_KEY' if you want the InChI key (hashed) value returned.
  • EXTRA_COMMANDLINE_ARGS: defaults to null, set it to valid stdinchi command line argument(s) such as '-FixedH' to further influence the output

Axemplas
> select orchem_convert.molfiletoinchi(orchem_convert.smilestomolfile('OC1=NC=NC2=C1C=NN2'),'INCHI_KEY') as INCHIKEY from dual;
INCHIKEY
--------------------------------------------------------------------------------
InChIKey=OFCNXPDARWKPPY-UHFFFAOYSA-N


> select orchem_convert.molfiletoinchi(orchem_convert.smilestomolfile('OC1=NC=NC2=C1C=NN2')) as INCHI from dual;
INCHI
--------------------------------------------------------------------------------
InChI=1S/C5H4N4O/c10-5-3-1-8-9-4(3)6-2-7-5/h1-2H,(H2,6,7,8,9,10)


> select orchem_convert.molfiletoinchi(orchem_convert.smilestomolfile('OC1=NC=NC2=C1C=NN2'),'INCHI','-FixedH') as INCHI from dual;
INCHI
--------------------------------------------------------------------------------
InChI=1/C5H4N4O/c10-5-3-1-8-9-4(3)6-2-7-5/h1-2H,(H2,6,7,8,9,10)/f/h9-10H


> select orchem_convert.molfiletoinchi(orchem_convert.smilestomolfile('OC1=NC=NC2=C1C=NN2'),'INCHI','-KET -DoNotAddH') as INCHI from dual
INCHI
--------------------------------------------------------------------------------
InChI=1/C5N4O/c10-5-3-1-8-9-4(3)6-2-7-5






Back to main page