Thanks Paolo – we’ll give that a try.

Regards,
Mark

Dr Mark Mackey
Chief Scientific Officer
Cresset
New Cambridge House, Bassingbourn Road, Litlington, Cambridgeshire, SG8 0SS, UK
Tel: +44 (0)1223 858890           Mobile: +44 (0)7595099165
Email: m...@cresset-group.com<mailto:m...@cresset-group.com>     Web: 
www.cresset-group.com<http://www.cresset-group.com/>



From: Paolo Tosco <paolo.tosco.m...@gmail.com>
Sent: 08 February 2022 21:48
To: Mark Mackey <m...@cresset-group.com>
Cc: rdkit-discuss@lists.sourceforge.net
Subject: Re: [Rdkit-discuss] Problem with depicting reaction SMARTS

Hi Mark,

I believe the bug is caused by the fact that isAtomListQuery() returns true for 
a query that is actually a complex query, and that subsequently 
getAtomListQueryVals() (called by getAtomListText()) fails to parse.
The following patch seems to solve the problem:

$ git diff
diff --git a/Code/GraphMol/QueryOps.cpp b/Code/GraphMol/QueryOps.cpp
index a80d8f5..ea28ad3 100644
--- a/Code/GraphMol/QueryOps.cpp
+++ b/Code/GraphMol/QueryOps.cpp
@@ -812,8 +812,9 @@ bool _atomListQueryHelper(const T query) {
         return false;
       }
     }
+    return true;
   }
-  return true;
+  return false;
 }
 }  // namespace
 bool isAtomListQuery(const Atom *a) {

Cheers,
p.

On Tue, Feb 8, 2022 at 8:29 PM Mark Mackey via Rdkit-discuss 
<rdkit-discuss@lists.sourceforge.net<mailto:rdkit-discuss@lists.sourceforge.net>>
 wrote:
Hi all,

I’m trying to generate an SVG from reaction SMARTS. The code looks like this:

QByteArray ChemicalReactionsCalculation::toSvg(const QString &reaction, int 
width, int height)
{
    try
    {
        std::string text = reaction.toStdString();

        std::unique_ptr<RDKit::ChemicalReaction> 
rxn(RDKit::RxnSmartsToChemicalReaction(text));
        if (rxn)
        {
            RDKit::MolDraw2DSVG drawer(width, height);
            drawer.drawReaction(*rxn);
            drawer.finishDrawing();

            auto svg = drawer.getDrawingText();
            return QByteArray::fromStdString(svg);
        }
    }
    catch (const std::exception &e)
    {
        qWarning() << "Exception in ChemicalReactionsCalculation::toSvg on" << 
reaction << ":" << e.what();
    }
    return QByteArray();
}

This works fine for most reaction SMARTS strings, but throws an exception at 
“drawer.drawReaction” when the SMARTS string has a combination of Boolean 
operators in it. For example, “[n&H1:1]>>[o:1]” works fine, as does 
“[c,n:1]>>[O:1]”, but doing “[c,n&H1:1]>>[o:1]” fails (as does the equivalent 
“[c,nH1:1]>>[o:1]”):

Exception in ChemicalReactionsCalculation::toSvg on "[c,n&H1:1]>>[o:1]" : bad 
query type1

This happens for pretty much any combination of “,” and “&” operators inside 
the square brackets. Any ideas?

Regards,
Mark

Dr Mark Mackey
Chief Scientific Officer
Cresset
New Cambridge House, Bassingbourn Road, Litlington, Cambridgeshire, SG8 0SS, UK
Tel: +44 (0)1223 858890           Mobile: +44 (0)7595099165
Email: m...@cresset-group.com<mailto:m...@cresset-group.com>     Web: 
www.cresset-group.com<http://www.cresset-group.com/>




This email has been sent from Cresset BioMolecular Discovery Limited, 
registered in England and Wales, Company Number: 04151475. The information in 
this email and any attachments are confidential and may be privileged. It is 
intended solely for the addressee and access to this email by anyone else is 
unauthorised. If an addressing or transmission error has misdirected this 
email, please notify the author by replying to this email. If you are not the 
intended recipient you must not use, disclose, distribute, store or copy the 
information in any medium. Although this e-mail and any attachments are 
believed to be free from any virus or other defect which might affect any 
system into which they are opened or received, it is the responsibility of the 
recipient to check that they are virus-free and that they will in no way affect 
systems and data. No responsibility is accepted by Cresset BioMolecular 
Discovery Limited for any loss or damage arising in any way from their receipt, 
opening or use. Privacy notice<https://www.cresset-group.com/privacy/>
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net<mailto:Rdkit-discuss@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to