Thank you John and Jonas for your answers.

One big issue is I still don't have a good grasp of how CDK does things. The 
second is that I'm doing it through Python and the Pype bridge.

The third is that I last looked at this part of the code over a year ago, and 
wrote most of the code about 4 years ago.

> On Jun 24, 2025, at 17:34, John Mayfield <john.wilkinson...@gmail.com> wrote:
> First off for the SMARTS matcher you can turn off the "prepare" or use the 
> lower level APIs and work on the input aromaticity.
> 
> IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance();

Is there a reason for using SilentChemObjectBuilder instead of what I use, 
which is:

  cdk.DefaultChemObjectBuilder.getInstance()

? I see cinfony does what you suggest, as does Jonas:

> SmartsPattern pat = SmartsPattern.create("C=CC=N");
> pat.setPrepare(false); // turn off auto ring+arom perception

Jonas also mentioned the prepare method:
> //prevent the SMARTS pattern from perceiving aromaticity
> pattern.setPrepare(false);

I've never used this method.

With the default of true, does each SMARTS match re-perceive aromaticity each 
time?


John:
> Cycles.markRingAtomsAndBonds(mol);
> Aromaticity.apply(Aromaticity.Model.Daylight, mol);

Hmmm. It looks like I don't understand who is supposed to be in charge of doing 
perception, or what the processing steps to get a fully prepared structure.

What I've been doing is using SmilesParser(_default_builder).parseSmiles() and 
assuming the molecule was in the right state.

I then use one of the fingerprinters, or do the SMARTS matches for a couple of 
my own fingerprint types.

Am I always supposed to perceive rings and aromaticity if I use SmilesParser? 
Is there any reason to not use the same aromcity perception steps in CDK 
Depict, using Daylight aromaticity?

What about if I use MDLV2000Reader/MDLV3000Reader? Or IteratingSDFReader or 
IteratingSMILESReader with hasNext()/next() to get the molecules? Do I need to 
perceive those too?

Also, I'm looking at SubstructureFingerprinter.java and see:

  SmartsPattern.prepare(atomContainer)

Do I need this too? Jonas wrote "SmartPattern.matchAll() is called in the web 
app, which internally calls SmartsPattern.prepare", so I don't think I need it.

John:
> I'm not sure how you got that output:

Because I was confused when I wrote the code in the first place?

I can spend some time pulling the CDK-specific code out of chemfp to get a 
stand-alone reproducible, but it's probably a better use of my time to just get 
the processing steps done correctly.

                                Andrew
                                da...@dalkescientific.com





_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to