#1177 smiles generator removes aromaticity from aromatic fragments


See Mailing List Thread:


Email with problem description and example code:

Hi all,

I would like to mine the MCS and print it as aromatic smarts. Unfortunately, the aromaticity information gets lost, even though the mcs-fragment has arom flags asigned (see code example below).
IMHO, the problem is that the smiles writer (is there a smarts writer?) has its own armaticity detection.

Thanks for helping, regards,


[[ is mcs atom arom: true is mcs atom arom: true is mcs atom arom: true is mcs atom arom: true is mcs atom arom: true mcs smiles: CCCCC ]]

SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer mol1 = sp.parseSmiles("c1ccccc1NC");
IAtomContainer mol2 = sp.parseSmiles("c1cccnc1");

    org.openscience.cdk.smsd.Isomorphism mcs = new org.openscience.cdk.smsd.Isomorphism(
            org.openscience.cdk.smsd.interfaces.Algorithm.DEFAULT, true);
    mcs.init(mol1, mol2, true, true);
    mcs.setChemFilters(true, true, true);

    mol1 = mcs.getReactantMolecule();
    IMolecule mcsmolecule = DefaultChemObjectBuilder.getInstance().newInstance(IMolecule.class, mol1);
    List<IAtom> atomsToBeRemoved = new ArrayList<IAtom>();
    for (IAtom atom : mcsmolecule.atoms())
        int index = mcsmolecule.getAtomNumber(atom);
        if (!mcs.getFirstMapping().containsKey(index))

    for (IAtom atom : atomsToBeRemoved)

    for (int i = 0; i < mcsmolecule.getAtomCount(); i++)
        System.out.println("is mcs atom aromtic: " + mcsmolecule.getAtom(i).getFlag(CDKConstants.ISAROMATIC));

    SmilesGenerator g = new SmilesGenerator();
    System.out.println("mcs smiles: " + g.createSMILES(mcsmolecule));



  • Martin Gütlein

    Martin Gütlein - 2011-11-18

    just noticed that my ticket reports get auto-assigned to chris steinbeck, changing that to none

  • Martin Gütlein

    Martin Gütlein - 2013-05-23

    I'll check in my hack to fix this, the proper fix should be a bit more elegant though

  • John May

    John May - 2013-06-03

    Okay, i've patched this here /patches/643.

    I think your solution is correct however, the MCS output may not be valid SMILES. This is bad as a robot could pick it up and try and deposite it in PubChem for example. However IMO the SMILES generator should not change the input.

    In your case, an alternative is to store either molecule full, then have flags for which atoms are in the MCS. You'd actually probably want to store the bonds but as an example:

    c1cccnc1 {0,1,2,3,5}


  • John May

    John May - 2014-12-02
    • status: open --> closed
  • John May

    John May - 2014-12-02

    SMILES generator no longer has this behaviour.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks