Skip to content

1. Basic usage

Jonas Schaub edited this page Dec 15, 2023 · 1 revision

In the example code below, an input molecule is parsed and preprocessed, the ErtlFunctionalGroupsFinder class is instantiated, and the latter is used to identify functional groups in the former:

//Prepare input SmilesParser tmpSmiPar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer tmpInputMol = tmpSmiPar.parseSmiles("C[C@@H]1CN(C[C@H](C)N1)C2=C(C(=C3C(=C2F)N(C=C(C3=O)C(=O)O)C4CC4)N)F"); //PubChem CID 5257 AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(tmpInputMol); Aromaticity tmpAromaticity = new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet()); tmpAromaticity.apply(tmpInputMol);

//Identify functional groups (generalized FG, default) ErtlFunctionalGroupsFinder tmpEFGF = new ErtlFunctionalGroupsFinder(); //default: generalization turned on List tmpFunctionalGroupsList = tmpEFGF.find(tmpInputMol); SmilesGenerator tmpSmiGen = new SmilesGenerator(SmiFlavor.Canonical | SmiFlavor.UseAromaticSymbols); for (IAtomContainer tmpFunctionalGroup : tmpFunctionalGroupsList) { String tmpSmilesString = tmpSmiGen.create(tmpFunctionalGroup); System.out.println(tmpSmilesString); } System.out.println("----------------");

//non-generalized functional groups tmpEFGF = new ErtlFunctionalGroupsFinder(ErtlFunctionalGroupsFinder.Mode.NO_GENERALIZATION); tmpFunctionalGroupsList = tmpEFGF.find(tmpInputMol); for (IAtomContainer tmpFunctionalGroup : tmpFunctionalGroupsList) { String tmpSmilesString = tmpSmiGen.create(tmpFunctionalGroup); System.out.println(tmpSmilesString); }

Output:
*N(*)*
*N(*)[H]
*F
*C(=O)C(=[C]N(*)*)C(=O)O[H]
[H]N([H])[c]
*F
----------------
[C]N([C])[c]
[H]N([C])[C]
[c]F
[H]OC(=O)C(C([c])=O)=C([H])N([c])[C]
[H]N([H])[c]
[c]F

By default, the extracted functional groups are "generalized", i.e. their environamental carbon and hydrogen atoms are replaced by R atoms (pseudo atoms, "*" in SMILES notation) in most of the cases, except those were this information is important, e.g. to differentiate between an alcohol and a phenole. More information on this can be found in Dr Peter Ertl's original publication of the algorithm. This default behaviour of ErtlFunctionalGroupsFinder can be turned off at instantiation (see above). More information on the necessary preprocessing of input molecules and how it can influence the functional group detection results, can be found in our paper

Clone this wiki locally