7
$\begingroup$

The conversion between different chemical structure formats, e.g. from .mol2 to .xyz, by openbabel may tied to conditions to be met. One example of such a filter is to allow such a conversion only for data sharing a certain scaffold, e.g.

babel -imol2 AHECAS.mol2 -oxyz AHECAS.xyz -s "c1ccccc1-[#16](=[#8])-[#6]-c2ccccc2"

So the program allows SMARTS as constraining input parameter. In difference to SMILES, (apparently, based on babel -L formats) openbabel however does not offer a conversion of any format into SMARTS and my source to generate them is the on-line PubChem Sketcher.

Question: Aiming to generate SMARTS locally (offline), I know Marvin by ChemAxon may export a structure into SMARTS. However, is there a portable alternative (with lesser footprint than a complete new GUI sketcher), preferentially allowing a conversion in a pattern like SMILES2SMARTS (or mol2toSMARTS) from the terminal / by a script?

$\endgroup$
3
$\begingroup$

The thread indicated in the comment by @andselisk dates back to July 2014. It may be condensed to

"A substructure querying with openbabel requires a good SMARTS string. In case you don't have one, often a good SMILES string may be used instead of a SMARTS string, too."

A check for a rather simple molecular structure of (benzylsulfinyl)benzene

enter image description here

there is more than one way to describe it in either form of a SMARTS, or a SMILES string. Consequently, the strings per se sometimes differ from each other. Consequently, recognizing the relevant entries in the collection of .mol2 with openbabel sometimes failed.

Below I summerize (status: 2019-May-15) a few experiences: the string offered by the software, its type, and source; eventually, if it worked (i.e., entries retrieved), or not (i.e., entries not retrieved) in a small test set of 419 model data and 7 relevant hits.

|-------------------------------------+--------+--------------------+--------|
| entry                               | type   | source             | status |
|-------------------------------------+--------+--------------------+--------|
| c1ccccc1-[#6]-[#16](-c2ccccc2)=[#8] | SMARTS | pubChemSketcher    | works  |
| C1=CC=CC=C1C[S](C2=CC=CC=C2)=O      | SMILES | pubChemSketcher    | fails  |
|-------------------------------------+--------+--------------------+--------|
| O=S(Cc1ccccc1)c2ccccc2              | SMILES | ACD ChemSketch     | works  |
|-------------------------------------+--------+--------------------+--------|
| C1=CC=C(C=C1)CS(C(C=CC1)=CC=1)=O    | SMILES | ChemDoodle         | fails  |
|-------------------------------------+--------+--------------------+--------|
| O=S(C1=CC=CC=C1)CC2=CC=CC=C2        | SMILES | ChemDraw Pro12     | fails  |
|-------------------------------------+--------+--------------------+--------|
| O=S(CC1=CC=CC=C1)C1=CC=CC=C1        | SMILES | Marvin JS          | fails  |
|-------------------------------------+--------+--------------------+--------|
| O=S(Cc1ccccc1)c2ccccc2              | SMILES | Peter Ertl JSME    | works  |
|-------------------------------------+--------+--------------------+--------|
| c1cccc(c1)CS(=O)c1ccccc1            | SMILES | openbabel, default | works  |
| c1ccc(cc1)CS(=O)c1ccccc1            | SMILES | dito, universal    | works  |
| c1ccc(cc1)CS(=O)c1ccccc1            | SMILES | dito, Inchified    | works  |
| O=S(c1ccccc1)Cc1ccccc1              | SMILES | dito, canonical    | works  |
|-------------------------------------+--------+--------------------+--------|

PubChem Sketcher: version 2.4, https://pubchem.ncbi.nlm.nih.gov/edit2/index.html
ACD ChemSketch:   Freeeware version 2015
ChemDoodle:       version 8.1.0, 2019 and webcomponents,
                  https://web.chemdoodle.com/demos/sketcher/
ChemDraw:         version 12 Pro, (then) CambridgeSoft, 2009
Marvin JS:        ChemAxon, v19.11.0, on-line test at
                  https://marvinjs-demo.chemaxon.com/latest/
                  Its SMARTS (very differently written) equally failed:
                  O=S([#6]-[#6]-1=[#6]-[#6]=[#6]-[#6]=[#6]-1)[#6]-1=[#6]-[#6]=[#6]-[#6]=[#6]-1
Peter Ertl JSME:  https://peter-ertl.com/jsme/JSME_2017-02-26/

Addition:
The approach mentioned in the question basically calls babel (or òpenbabel) as an iteration per file. Especially if the data set is accessed more than once to identify different structures, and / or consists of multiple thousand models, this may be tediously slow. Instead, it is worth to "bundle" the individual information

babel *.mol2 mymols.sdf --unique

creating a container like a multi-model .mol2 (this even works with .xyz files as input). The .sdf may be indexed

babel mymols.sdf -ofs

by fingerprints (cf. chapter 5 of the manual). Now, very quickly the names of the files about a strucure matching the query substructure are identifed, e.g.

babel mymols.fs -ifs -s"O=S(c1ccccc1)Cc1ccccc1" results.smi -xt

and stored in results.smi. Consequently, any further work may focus on them.

$\endgroup$
  • 1
    $\begingroup$ "If you deploy either a SMARTS, or a SMILES string on Linux' bash" If you enclose the string in '' to make it literal, you do not have to escape anything. $\endgroup$ – Martin - マーチン May 15 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.