The conversion module provides functions for converting chemical data. Open Babel supports over 80 chemical file formats. To avoid having to many functions, this module defines a set of two functions for each format: FORMAT_TO_MOLECULE and MOLECULE_TO_FORMAT. However, new functions, like CML_TO_SMILES, can be requested on the feature tracker.
If a function of the conversion module fails, it returns an empty string.
MOLECULE_TO_SERIALIZEDOBMOL(molecule)
MOLECULE_TO_SERIALIZEDOBMOL() converts a molecule in DEFAULT_TYPE format to a serialized OBMol object. The SQL type of a serialized object is a binary string.
mysql>SELECT MOLECULE_TO_SERIALIZEDOBMOL(molecule_col)->FROM->tbl_nameWHERE name='glycine';binary string
CML_TO_MOLECULE() converts a molecule in CML format to a molecule in DEFAULT_TYPE format.
mysql>SELECT CML_TO_MOLECULE(cml_col) FROMtbl_name->WHERE name='glycine';-> glycine OpenBabel11190809032D 5 4 0 0 0 0 0 0 0 0999 V2000 206.0000 126.0000 0.0000 C 0 0 0 0 0 227.0075 113.8713 0.0000 C 0 0 0 0 0 227.0075 89.6139 0.0000 O 0 0 0 0 0 248.0151 126.0000 0.0000 O 0 0 0 0 0 184.9925 113.8713 0.0000 N 0 0 0 0 0 1 2 1 0 0 0 1 5 1 0 0 0 2 3 2 0 0 0 2 4 1 0 0 0 M END
MOLECULE_TO_CML() converts a molecule in DEFAULT_TYPE format to a molecule in CML format.
mysql>SELECT MOLECULE_TO_CML(molecule_col) FROMtbl_name->WHERE name='glycine';-> <molecule id="glycine"> <atomArray> <atom id="a1" elementType="C" x2="206.000000" y2="126.000000"/> <atom id="a2" elementType="C" x2="227.007500" y2="113.871300"/> <atom id="a3" elementType="O" x2="227.007500" y2="89.613900"/> <atom id="a4" elementType="O" x2="248.015100" y2="126.000000"/> <atom id="a5" elementType="N" x2="184.992500" y2="113.871300"/> </atomArray> <bondArray> <bond atomRefs2="a2 a3" order="2"/> <bond atomRefs2="a2 a4" order="1"/> <bond atomRefs2="a1 a2" order="1"/> <bond atomRefs2="a1 a5" order="1"/> </bondArray> </molecule>
FINGERPRINT() converts a molecule in DEFAULT_TYPE format to a fingerprint. The fingerprint type is specified by the second argument (FP2, FP3 or FP4). The SQL type of the converted molecule is a binary string for all kinds of fingerprint.
mysql>SELECT FINGERPRINT(molecule_col,"FP2") FROMtbl_name->WHERE name='glycine';->binary fingerprint (type FP2)
Tanimoto scoring can be improved by using a concatenation of different fingerprint types. The concatenation of fingerprints can be performed with the following query:
mysql>SELECT CONCAT(FINGERPRINT(molecule_col,"FP2"),->FINGERPRINT(molecule_col,"FP3")) FROMtbl_name->WHERE id=9;->binary fingerprint (type FP2 + type FP3)
FINGERPRINT2() converts a molecule in DEFAULT_TYPE format to a FP2 fingerprint. The SQL type of FP2 fingerprints is a binary string.
mysql>SELECT FINGERPRINT2(molecule_col) FROMtbl_name->WHERE name='glycine';->binary fingerprint (type FP2)
FINGERPRINT3() converts a molecule in DEFAULT_TYPE format to a FP3 fingerprint. The SQL type of FP3 fingerprints is a binary string.
mysql>SELECT FINGERPRINT3(molecule_col) FROMtbl_name->WHERE name='glycine';->binary fingerprint (type FP3)
FINGERPRINT4() converts a molecule in DEFAULT_TYPE format to a FP4 fingerprint. The SQL type of FP4 fingerprints is a binary string.
mysql>SELECT FINGERPRINT4(molecule_col) FROMtbl_name->WHERE name='glycine';->binary fingerprint (type FP4)
INCHI_TO_MOLECULE() converts a molecule in InChI format to a molecule in DEFAULT_TYPE format.
mysql>SELECT INCHI_TO_MOLECULE(inchi_col) FROMtbl_name->WHERE name='glycine';-> OpenBabel11190809142D 5 4 0 0 0 0 0 0 0 0999 V2000 0.0000 0.0000 0.0000 C 0 0 0 0 0 0.0000 0.0000 0.0000 C 0 0 0 0 0 0.0000 0.0000 0.0000 O 0 0 0 0 0 0.0000 0.0000 0.0000 O 0 0 0 0 0 0.0000 0.0000 0.0000 N 0 0 0 0 0 1 2 1 0 0 0 1 5 1 0 0 0 2 3 2 0 0 0 2 4 1 0 0 0 M END
MOLECULE_TO_INCHI converts a molecule in DEFAULT_TYPE format to a molecule in InChI format.
mysql>SELECT MOLECULE_TO_INCHI(molecule_col) FROMtbl_name->WHERE name='glycine';-> InChI=1/C2H5NO2/c3-1-2(4)5/h1,3H2,(H,4,5)/f/h4H
The INCHI_VERSION() function permit to know which version of the InChI library is used.
MOL2_TO_MOLECULE() converts a molecule in Sybyl Mol2 format to a molecule in DEFAULT_TYPE format.
mysql>SELECT MOL2_TO_MOLECULE(mol2_col) FROMtbl_name->WHERE name='glycine';-> glycine OpenBabel11190809032D 5 4 0 0 0 0 0 0 0 0999 V2000 206.0000 126.0000 0.0000 C 0 0 0 0 0 227.0075 113.8713 0.0000 C 0 0 0 0 0 227.0075 89.6139 0.0000 O 0 0 0 0 0 248.0151 126.0000 0.0000 O 0 0 0 0 0 184.9925 113.8713 0.0000 N 0 0 0 0 0 1 2 1 0 0 0 1 5 1 0 0 0 2 3 2 0 0 0 2 4 1 0 0 0 M END
MOLECULE_TO_MOL2() converts a molecule in DEFAULT_TYPE format to a molecule in Sybyl Mol2 format.
mysql>SELECT MOLECULE_TO_MOL2(molecule_col) FROMtbl_name->WHERE name='glycine';->@<TRIPOS>MOLECULE glycine 5 4 0 0 0 SMALL GASTEIGER Energy = 0 @<TRIPOS>ATOM 1 CA 206.0000 126.0000 0.0000 C.3 1 GLY1 0.2227 2 C 227.0075 113.8713 0.0000 C.2 1 GLY1 0.3839 3 O 227.0075 89.6139 0.0000 O.co2 1 GLY1 -0.2440 4 OXT 248.0151 126.0000 0.0000 O.co2 1 GLY1 -0.2440 5 N 184.9925 113.8713 0.0000 N.3 1 GLY1 -0.1186 @<TRIPOS>BOND 1 1 2 1 2 1 5 1 3 2 3 ar 4 2 4 ar
MOLECULE_TO_MOLECULE(molecule)
MOLECULE_TO_MOLECULE() converts a molecule in the old DEFAULT_TYPE format (InChI) to a molecule in the current DEFAULT_TYPE format (MDL Molfile). This function is useful when updating a database with a new version of Mychem.
mysql>SELECT MOLECULE_TO_MOLECULE(molecule_col) FROMtbl_name->WHERE name='glycine';-> OpenBabel11190809092D 5 4 0 0 0 0 0 0 0 0999 V2000 0.0000 0.0000 0.0000 C 0 0 0 0 0 0.0000 0.0000 0.0000 C 0 0 0 0 0 0.0000 0.0000 0.0000 N 0 0 0 0 0 0.0000 0.0000 0.0000 O 0 0 0 0 0 0.0000 0.0000 0.0000 O 0 0 0 0 0 1 2 1 0 0 0 1 3 1 0 0 0 2 4 2 0 0 0 2 5 1 0 0 0 M END
MOLFILE_TO_MOLECULE() converts a molecule in MDL Molfile (V2000) format to a molecule in DEFAULT_TYPE format.
mysql>SELECT MOLFILE_TO_MOLECULE(molfile_col) FROMtbl_name->WHERE name='glycine';-> glycine OpenBabel11190809052D 5 4 0 0 0 0 0 0 0 0999 V2000 206.0000 126.0000 0.0000 C 0 0 0 0 0 227.0075 113.8713 0.0000 C 0 0 0 0 0 227.0075 89.6139 0.0000 O 0 0 0 0 0 248.0151 126.0000 0.0000 O 0 0 0 0 0 184.9925 113.8713 0.0000 N 0 0 0 0 0 1 2 1 0 0 0 1 5 1 0 0 0 2 3 2 0 0 0 2 4 1 0 0 0 M END
MOLECULE_TO_MOLFILE() converts a molecule in DEFAULT_TYPE format to a molecule in MDL Molfile (V2000) format.
mysql>SELECT MOLECULE_TO_MOLFILE(molecule_col) FROMtbl_name->WHERE name='glycine';-> glycine OpenBabel11190809062D 5 4 0 0 0 0 0 0 0 0999 V2000 206.0000 126.0000 0.0000 C 0 0 0 0 0 227.0075 113.8713 0.0000 C 0 0 0 0 0 227.0075 89.6139 0.0000 O 0 0 0 0 0 248.0151 126.0000 0.0000 O 0 0 0 0 0 184.9925 113.8713 0.0000 N 0 0 0 0 0 1 2 1 0 0 0 1 5 1 0 0 0 2 3 2 0 0 0 2 4 1 0 0 0 M END
PDB_TO_MOLECULE() converts a molecule in PDB format to a molecule in DEFAULT_TYPE format.
mysql>SELECT PDB_TO_MOLECULE(pdb_col) FROMtbl_name->WHERE name='1CRN';-> OpenBabel08210907243D 327337 0 0 0 0 0 0 0 0999 V2000 17.0470 14.0990 3.6250 N 0 0 0 0 0 16.9670 12.7840 4.3380 C 0 0 0 0 0 15.6850 12.7550 5.1330 C 0 0 0 0 0 15.2680 13.8250 5.5940 O 0 0 0 0 0 18.1700 12.7030 5.3370 C 0 0 0 0 0 19.3340 12.8290 4.4630 O 0 0 0 0 0 18.1500 11.5460 6.3040 C 0 0 0 0 0 15.1150 11.5550 5.2650 N 0 0 0 0 0 13.8560 11.4690 6.0660 C 0 0 0 0 0 14.1640 10.7850 7.3790 C 0 0 0 0 0 14.9930 9.8620 7.4430 O 0 0 0 0 0 12.7320 10.7110 5.2610 C 0 0 0 0 0 13.3080 9.4390 4.9260 O 0 0 0 0 0 12.4840 11.4420 3.8950 C 0 0 0 0 0 13.4880 11.2410 8.4170 N 0 0 0 0 0 13.6600 10.7070 9.7870 C 0 0 0 0 0 12.2690 10.4310 10.3230 C 0 0 0 0 0 11.3930 11.3080 10.1850 O 0 0 0 0 0 14.3680 11.7480 10.6910 C 0 0 0 0 0 15.8850 12.4260 10.0160 S 0 0 0 0 0 12.0190 9.2720 10.9280 N 0 0 0 0 0 10.6460 8.9910 11.4080 C 0 0 0 0 0 10.6540 8.7930 12.9190 C 0 0 0 0 0 11.6590 8.2960 13.4910 O 0 0 0 0 0 10.0570 7.7520 10.6820 C 0 0 0 0 0 9.8370 8.0180 8.9040 S 0 0 0 0 0 9.5610 9.1080 13.5630 N 0 0 0 0 0 9.4480 9.0340 15.0120 C 0 0 0 0 0 9.2880 7.6700 15.6060 C 0 0 0 0 0 ...
SMILES_TO_MOLECULE() converts a molecule in SMILES format to a molecule in DEFAULT_TYPE format.
mysql>SELECT SMILES_TO_MOLECULE(smiles_col) FROMtbl_name->WHERE name='glycine';-> OpenBabel11190809142D 5 4 0 0 0 0 0 0 0 0999 V2000 0.0000 0.0000 0.0000 C 0 0 0 0 0 0.0000 0.0000 0.0000 C 0 0 0 0 0 0.0000 0.0000 0.0000 O 0 0 0 0 0 0.0000 0.0000 0.0000 O 0 0 0 0 0 0.0000 0.0000 0.0000 N 0 0 0 0 0 1 2 1 0 0 0 1 5 1 0 0 0 2 3 2 0 0 0 2 4 1 0 0 0 M END
MOLECULE_TO_SMILES converts a molecule in DEFAULT_TYPE format to molecule in SMILES format.
mysql>SELECT MOLECULE_TO_SMILES(molecule_col) FROMtbl_name->WHERE name='glycine';-> C(C(=O)O)N
If you need a single canonical form for any particular molecule, regardless of atom order, the use of the MOLECULE_TO_CANONICAL_SMILES() function should be preferred.
MOLECULE_TO_CANONICAL_SMILES(molecule)
MOLECULE_TO_CANONICAL_SMILES converts a molecule in DEFAULT_TYPE format to a molecule in Canonical SMILES format.
mysql>SELECT MOLECULE_TO_CANONICAL_SMILES(molecule_col)->FROM-> NCC(=O)Otbl_nameWHERE name='glycine';
V3000_TO_MOLECULE() converts a molecule in MDL Molfile (V3000) format to a molecule in DEFAULT_TYPE format.
mysql>SELECT V3000_TO_MOLECULE(V3000_col) FROMtbl_name->WHERE name='glycine';-> glycine OpenBabel11190809082D 5 4 0 0 0 0 0 0 0 0999 V2000 206.0000 126.0000 0.0000 C 0 0 0 0 0 227.0075 113.8713 0.0000 C 0 0 0 0 0 227.0075 89.6139 0.0000 O 0 0 0 0 0 248.0151 126.0000 0.0000 O 0 0 0 0 0 184.9925 113.8713 0.0000 N 0 0 0 0 0 1 2 1 0 0 0 1 5 1 0 0 0 2 3 2 0 0 0 2 4 1 0 0 0 M END
MOLECULE_TO_V3000() converts a molecule in DEFAULT_TYPE format to a molecule in MDL Molfile (V3000) format.
mysql>SELECT MOLECULE_TO_V3000(molecule_col) FROMtbl_name->WHERE name='glycine';-> glycine OpenBabel11190809132D 0 0 0 0 0 999 V3000 M V30 BEGIN CTAB M V30 COUNTS 5 4 0 0 0 M V30 BEGIN ATOM M V30 1 C 206 126 0 0 M V30 2 C 227.007 113.871 0 0 M V30 3 O 227.007 89.6139 0 0 M V30 4 O 248.015 126 0 0 M V30 5 N 184.993 113.871 0 0 M V30 END ATOM M V30 BEGIN BOND M V30 1 1 1 2 M V30 2 1 1 5 M V30 3 2 2 3 M V30 4 1 2 4 M V30 END BOND M V30 END CTAB M END