public final class SmilesParser extends Object
Reading Aromatic SMILEStry { SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer m = sp.parseSmiles("c1ccccc1"); } catch (InvalidSmilesException e) { System.err.println(e.getMessage()); }
Aromatic SMILES are automatically kekulised producing a structure with
assigned bond orders. The aromatic specification on the atoms is maintained
from the SMILES even if the structures are not considered aromatic. For
example 'c1ccc1' will correctly have two pi bonds assigned but the
atoms/bonds will still be flagged as aromatic. Recomputing or clearing the
aromaticty will remove these erroneous flags. If a kekulé structure could not
be assigned this is considered an error. The most common example is the
omission of hydrogens on aromatic nitrogens (aromatic pyrrole is specified as
'[nH]1cccc1' not 'n1cccc1'). These structures can not be corrected without
modifying their formula. If there are multiple locations a hydrogen could be
placed the returned structure would differ depending on the atom input order.
If you wish to skip the kekulistation (not recommended) then it can be
disabled with kekulise
. SMILES can be verified for validity with the
DEPICT service.
Unsupported Features
The following features are not supported by this parser.
The atom class is stored as the CDKConstants.ATOM_ATOM_MAPPING
property.
SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer m = sp.parseSmiles("c1[cH:5]cccc1"); Integer c1 = m.getAtom(1) .getProperty(CDKConstants.ATOM_ATOM_MAPPING); // 5 Integer c2 = m.getAtom(2) .getProperty(CDKConstants.ATOM_ATOM_MAPPING); // null
Constructor and Description |
---|
SmilesParser(IChemObjectBuilder builder)
Create a new SMILES parser which will create
IAtomContainer s with
the specified builder. |
Modifier and Type | Method and Description |
---|---|
boolean |
isPreservingAromaticity()
Deprecated.
|
void |
kekulise(boolean kekulise)
Indicated whether structures should be automatically kekulised if they
are provided as aromatic.
|
IReaction |
parseReactionSmiles(String smiles)
Parse a reaction SMILES.
|
IAtomContainer |
parseSmiles(String smiles)
Parses a SMILES string and returns a structure (
IAtomContainer ). |
void |
setPreservingAromaticity(boolean preservingAromaticity)
Deprecated.
|
void |
setStrict(boolean strict)
Sets whether the parser is in strict mode.
|
public SmilesParser(IChemObjectBuilder builder)
IAtomContainer
s with
the specified builder.builder
- used to create the CDK domain objectspublic void setStrict(boolean strict)
strict
- strict mode true/false.public IReaction parseReactionSmiles(String smiles) throws InvalidSmilesException
smiles
- The SMILES string to parseIReaction
InvalidSmilesException
- if the string cannot be parsedparseSmiles(String)
public IAtomContainer parseSmiles(String smiles) throws InvalidSmilesException
IAtomContainer
).smiles
- A SMILES stringInvalidSmilesException
- thrown when the SMILES string is invalid@Deprecated public void setPreservingAromaticity(boolean preservingAromaticity)
preservingAromaticity
- boolean to indicate if aromaticity is to be
preserved.kekulise
@Deprecated public boolean isPreservingAromaticity()
public void kekulise(boolean kekulise)
kekulise
- should structures be kekulisedCopyright © 2022. All rights reserved.