Easy way to visualize SMARTS #chemoinformatics #memo

SMARTS which is a language for describing molecular patterns like regular expression for NLP is really useful for chemoinformatician. However it’s difficult to understand due to difficulty of visualization SMARTS query.

As far as I know, there are few software which can visualize beautiful SMARTS pattern. BioSolveIT provides unique SMARTS editor but it’s required commercial license so it’s difficult to use personally.

So I used the other free tool which named ‘SMARTS plus‘. The tool is managed by team of university of hamburg.

The tool is easy to use from web site, but also the site provides REST service. So user can use SMARTS plus from python. I tried it. Here is an example, as you can see SMARTS plus provides rich information of SMARTS.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

TIPs for using SMARTS plus from REST, to pass the query with get method, some character should be encoded. The details are described in following url.

I think visualize chemical structure and query is really interesting and useful for learning chemoinforamtics.

Published by iwatobipen

I'm medicinal chemist in mid size of pharmaceutical company. I love chemoinfo, cording, organic synthesis, my family.

3 thoughts on “Easy way to visualize SMARTS #chemoinformatics #memo

  1. Yes, I am testing some SMARTS based reactions and MMPDB outputs, so I also occasionally access to this site.
    But I did not know they had REST interface!.
    Great thanks!!

    class SMARTSView:
    BASE_URL = “https://smarts.plus/smartsview/download_rest”
    DEFAULT_filetype = “png”
    DEFAULT_vmode = 0
    DEFAULT_vbonds = 1
    DEFAULT_textdesc = 0
    DEFAULT_depsymbols = 0
    DEFAULT_smartsheading = 0
    DEFAULT_trim = 1
    DEFAULT_labels = 1
    DEFAULT_detectarom = 1
    DEFAULT_smileslikearom = 1

    def __call__(self, smarts, **options):
        for name in dir(self):
            if not name.startswith("DEFAULT_"):
            name = name[8:]
            if name not in options:
                options[name] = getattr(self, "DEFAULT_" + name)
        smarts = smarts.replace("%", "%25").replace("&", "%26").replace("+", "%2B").replace("#", "%23").replace(";", "%3B")
        pars = [fr"smarts={smarts}"] + [fr"{k}={v}" for k, v in options.items()]
        url = fr'{self.BASE_URL}?{";".join(pars)}'
        cont = requests.get(url).content
        if options["filetype"] == "svg":
            return cont.decode()
        return cont
  2. I am afraid if my previous comment is badly dedented.

    sv = SMARTSView()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: