Re: [Rdkit-discuss] Maximum Common Substructure using SMARTS

2021-07-26 Thread Gustavo Seabra
On Fri, Jul 23, 2021 at 4:53 AM Paolo Tosco wrote: > > # here there seems to a be a bug with the 2D depiction, but that's another > story > > template > > [image: image.png] > > Just a quick thing: I don't know if this is supposed to be a bug or a feature, but I noticed that this seems to be cau

Re: [Rdkit-discuss] Maximum Common Substructure using SMARTS

2021-07-23 Thread Gustavo Seabra
Thanks a lot! -- Gustavo Seabra. On Fri, Jul 23, 2021 at 12:18 PM Paolo Tosco wrote: > Hi Gustavo, > > Chem.Atom.HasQuery() and Chem.Bond.HasQuery() return True when the > underlying atom (or bond) is an instance of Chem.QueryAtom (or Chem. > QueryBond). > Query atoms and bonds can either be de

Re: [Rdkit-discuss] Maximum Common Substructure using SMARTS

2021-07-23 Thread Paolo Tosco
Hi Gustavo, Chem.Atom.HasQuery() and Chem.Bond.HasQuery() return True when the underlying atom (or bond) is an instance of Chem.QueryAtom (or Chem. QueryBond). Query atoms and bonds can either be defined through SMARTS expressions... from rdkit import Chem from rdkit.Chem import rdqueries a = Ch

Re: [Rdkit-discuss] Maximum Common Substructure using SMARTS

2021-07-23 Thread Gustavo Seabra
This works perfectly! I could understand most of what you did there ;-), but what does the ".HasQuery()" mean? The RDKit API is not very clear about it: "Returns whether or not the atom has an associated query". Is this described anywhere else? Thank you so much! -- Gustavo Seabra. On Fri, Jul

Re: [Rdkit-discuss] Maximum Common Substructure using SMARTS

2021-07-23 Thread Paolo Tosco
Hi Gustavo, you should be able to address this with a custom AtomCompare (and BondCompare, if you want to use bond queries too) class, that now is also supported from Python. You can take a look at Code/GraphMol/FMCS/Wrap/testFMCS.py for inspiration how to use it; here's something that seems to wo

Re: [Rdkit-discuss] Maximum Common Substructure using SMARTS

2021-07-23 Thread Andrew Dalke
On Jul 23, 2021, at 06:42, Andrew Dalke wrote: > > No, there's no way to do that. > > The best I can suggest is to go back to the original Python implementation > and change the code leading up to Alternatively, since your template is small, you can brute-force enumerate all possible matching

Re: [Rdkit-discuss] Maximum Common Substructure using SMARTS

2021-07-22 Thread Andrew Dalke
On Jul 23, 2021, at 01:01, Gustavo Seabra wrote: > I actually want the sulfone to be found, if it is there. My problem is that I > also want flexibility to change the ring atoms and still find the ring as a > match, while considering a match on the sulfone only if it really is there. > (e.g., C

Re: [Rdkit-discuss] Maximum Common Substructure using SMARTS

2021-07-22 Thread Gustavo Seabra
Hi, Thanks a lot for the reply! However, in this case, it looks like I would have to somehow label the isotope in every query molecule, right? For example: ``` template = Chem.MolFromSmarts('[c]1(-[2S](=[3O])(=[3O])(-C)):[c]:[c]:[c]:[c]:[c]:1') mol1 = Chem.MolFromSmiles('CS(=O)(=O)c1ccc(C2=C(c3ccc

Re: [Rdkit-discuss] Maximum Common Substructure using SMARTS

2021-07-22 Thread Andrew Dalke
Hi Gustavo, > template = > Chem.MolFromSmarts('[a]1(-[S](-*)(=[O])=[O]):[a]:[a]:[a]:[a]:[a]:1') Unless things have changed since I last looked at the algorithm, you can't meaningfully pass a SMARTS-based query molecule into the MCS program, outside of a few simple cases. It generates a SMART

[Rdkit-discuss] Maximum Common Substructure using SMARTS

2021-07-22 Thread Gustavo Seabra
Hi all,, I would appreciate some pointers on how it would be possible to find the maximum common substructure of 2 molecules, where in the template structure some atoms may be *any*, but some other atoms must be fixed. Currently, I'm trying to use rdFMCS module. For example: from rdkit import Ch