Re: [Rdkit-discuss] Problem with depicting reaction SMARTS

2022-02-09 Thread Mark Mackey via Rdkit-discuss
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 
Sent: 08 February 2022 21:48
To: Mark Mackey 
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 
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 , int 
width, int height)
{
try
{
std::string text = reaction.toStdString();

std::unique_ptr 
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 )
{
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:1]>>[o:1]” works fine, as does 
“[c,n:1]>>[O:1]”, but doing “[c,n:1]>>[o:1]” fails (as does the equivalent 
“[c,nH1:1]>>[o:1]”):

Exception in ChemicalReactionsCalculation::toSvg on "[c,n: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


[Rdkit-discuss] Problem with depicting reaction SMARTS

2022-02-08 Thread Mark Mackey via Rdkit-discuss
Hi all,

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

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

std::unique_ptr 
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 )
{
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:1]>>[o:1]" works fine, as does 
"[c,n:1]>>[O:1]", but doing "[c,n:1]>>[o:1]" fails (as does the equivalent 
"[c,nH1:1]>>[o:1]"):

Exception in ChemicalReactionsCalculation::toSvg on "[c,n: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 Web: 
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
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Reaction SMARTS ring properties

2021-09-14 Thread Mark Mackey via Rdkit-discuss
Hi Greg,

Argh, I’d missed that we hadn’t done the ring calculation on the reagents, and 
had been led astray by Googling the exception message. Adding the ring 
calculation does the trick - thanks very much for the help.

Regards,
Mark


Dr Mark Mackey
Chief Scientific Officer
Cresset



From: Greg Landrum 
Sent: 14 September 2021 06:01
To: Mark Mackey 
Cc: rdkit-discuss@lists.sourceforge.net
Subject: Re: [Rdkit-discuss] Reaction SMARTS ring properties

Hi Mark,

You haven't shown how the molecules in reagentsRdMolList are constructed, but 
from the error message I guess that they have been created without running any 
of the sanitization code.
The example transformation you show includes ring information, so it will 
generate errors if the molecules you run through the reaction don't have the 
ring information pre-computed.
If you don't care about ring size information, the fastest way to get the 
required info is to call MolOps::fastFindRings() on the molecules in 
reagentsRdMolList before passing them to rxn->runReactants().
If you include ring size (or ring count) information in your transformations, 
then using MolOps::symmetrizeSSSR() is a better idea.

I hope that helps,
-greg


On Tue, Sep 14, 2021 at 12:33 AM Mark Mackey via Rdkit-discuss 
mailto:rdkit-discuss@lists.sourceforge.net>>
 wrote:
Hi all,

I’m trying to run some chemical reactions using the C++ API. Doing something 
like

text = “ 
[cH1:1]1:[c:2](-[CH2:7]-[CH2:8]-[NH2:9]):[c:3]:[c:4]:[c:5]:[c:6]:1.[#6:11]-[CH1;R0:10]=[OD1]>>[c:1]12:[c:2](-[CH2:7]-[CH2:8]-[NH1:9]-[C:10]-2(-[#6:11])):[c:3]:[c:4]:[c:5]:[c:6]:1c1cc(CCN)ccc1”;
auto rxn =RDKit::RxnSmartsToChemicalReaction(text, nullptr, false);
rxn->initReactantMatchers();
auto reactionProducts = rxn->runReactants(reagentsRdMolList, 0);

works fine for trivial transformations, but throws “RingInfo not initialized” 
for anything more complex. Googling has shown that the problem is that the ring 
information is not automatically calculated for the SMARTS molecules, but I’m 
failing to work out what I need to call RDKit::MolOps::findSSSR on and when. 
All pointers appreciated.

Regards,
Mark

Dr Mark Mackey
Chief Scientific Officer
Cresset




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


[Rdkit-discuss] Reaction SMARTS ring properties

2021-09-13 Thread Mark Mackey via Rdkit-discuss
Hi all,

I'm trying to run some chemical reactions using the C++ API. Doing something 
like

text = " 
[cH1:1]1:[c:2](-[CH2:7]-[CH2:8]-[NH2:9]):[c:3]:[c:4]:[c:5]:[c:6]:1.[#6:11]-[CH1;R0:10]=[OD1]>>[c:1]12:[c:2](-[CH2:7]-[CH2:8]-[NH1:9]-[C:10]-2(-[#6:11])):[c:3]:[c:4]:[c:5]:[c:6]:1c1cc(CCN)ccc1";
auto rxn =RDKit::RxnSmartsToChemicalReaction(text, nullptr, false);
rxn->initReactantMatchers();
auto reactionProducts = rxn->runReactants(reagentsRdMolList, 0);

works fine for trivial transformations, but throws "RingInfo not initialized" 
for anything more complex. Googling has shown that the problem is that the ring 
information is not automatically calculated for the SMARTS molecules, but I'm 
failing to work out what I need to call RDKit::MolOps::findSSSR on and when. 
All pointers appreciated.

Regards,
Mark

Dr Mark Mackey
Chief Scientific Officer
Cresset





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
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] rejoining pairs of fragments after fragmenting a molecule

2021-04-01 Thread Mark Mackey via Rdkit-discuss
Hi Ling,

Having done something similar (but not in RDKit), I would suggest a different 
algorithm. I think that fragmenting the molecule first and then stitching the 
bits together is always going to be very complicated. Instead, just fragment 
the molecule in the ways that you want:

- Find the set B of all breakable bonds according to your rules. I’m assuming 
here that B contains only acyclic bonds.
- To get all of the pairwise pieces, for each element b of B break all bonds in 
B _except_ b. Keep the fragment containing b, and clean up.
- To get all of the triplets, for each tuple (b1, b2) in B, break all bonds in 
B except b1 and b2. Keep the fragment containing b1 only if it also contains b2.

Regards,
Mark

--
Mark Mackey
Chief Scientific Officer
Cresset
New Cambridge House, Bassingbourn Road, Litlington, Cambridgeshire, SG8 0SS, UK
tel: +44 (0)1223 858890mobile: +44 (0)7595 099165fax: +44 (0)1223 853667
email: m...@cresset-group.comweb: 
www.cresset-group.comskype: mark_cresset



From: Ling Chan 
Sent: 31 March 2021 20:56
To: RDKit 
Subject: [Rdkit-discuss] rejoining pairs of fragments after fragmenting a 
molecule

Dear Colleagues,

I am trying to do something that I think is quite simple, but I have not 
figured out a simple way. Don't know if I am missing something. I am sure that 
ultimately I can figure it out, but I wonder if there is a good way.

I fragmented a molecule with some rules, using FragmentOnBonds. I did get a 
list of primary fragments.

I wish to recombine pairs (and triplets, but no bigger) of these primary 
fragments, but only if the resulting fragment is part of the original molecule. 
I.e. I want to undo some of the cuttings. (FragmentOnSomeBonds does not help, 
since you cannot ensure that the resulting fragments consist only of pairs of 
primary fragments.)

What is the best way to do this? The following is what I am trying.

I see that you can mark the original cut points using the dummyLabels argument 
in FragmentOnBonds. So I converted the primary fragments to smiles. I looked 
for the two sides of the original cut point and substituted the two dummyLables 
to [2H] and [3H]. I then tried to rejoin the fragments using a reaction string 
"[*:1][2H].[*:2][3H]>>[*:1][*:2]". Unfortunately the ReactionFromSmarts 
function does not accept this string. So I'll have to use Smarts search to look 
for [2H] and [3H], then create an editable molecule from the two primary 
fragments, look for neighbours of [2H] and [3H], add a bond, then delete the 
atoms [2H] and [3H], then sanitize.

Thank you for your ideas.

Ling


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
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] explicit H atoms

2021-03-10 Thread Mark Mackey via Rdkit-discuss
I believe it's not possible to represent the chirality of the attached 
molecule's ring fusion carbons without using an explicit H.

Regards,
Mark

--
Mark Mackey
Chief Scientific Officer
Cresset
New Cambridge House, Bassingbourn Road, Litlington, Cambridgeshire, SG8 0SS, UK
tel: +44 (0)1223 858890mobile: +44 (0)7595 099165fax: +44 (0)1223 853667
email: m...@cresset-group.comweb: www.cresset-group.comskype: 
mark_cresset



-Original Message-
From: Jean-Marc Nuzillard 
Sent: 08 March 2021 13:55
To: RDKit Discuss 
Subject: [Rdkit-discuss] explicit H atoms

Dear all,

my question of the day is more general than directly related to RDKit but the 
link is indirect.

Is it always possible to represent an organic molecule in 2D with all necessary 
configuration hints (bond wedges pointing to the front or to the back) without 
introducing any explicit hydrogen atom?

May be my question is very naive, all my apologies in advance for that.

Best,

Jean-Marc

--
Jean-Marc Nuzillard
Directeur de Recherches au CNRS

Institut de Chimie Moléculaire de Reims
CNRS UMR 7312
Moulin de la Housse
CPCBAI, Bâtiment 18
BP 1039
51687 REIMS Cedex 2
France

Tel : 03 26 91 82 10
Fax : 03 26 91 31 66
http://www.univ-reims.fr/icmr
http://eos.univ-reims.fr/LSD/CSNteam.html

http://www.univ-reims.fr/LSD/
http://www.univ-reims.fr/LSD/JmnSoft/



___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

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
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss