Package com.actelion.research.chem
Class SmilesParser
- java.lang.Object
-
- com.actelion.research.chem.SmilesParser
-
public class SmilesParser extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static int
MODE_MAKE_HYDROGEN_EXPLICIT
static int
MODE_SKIP_COORDINATE_TEMPLATES
static int
SMARTS_MODE_GUESS
static int
SMARTS_MODE_IS_SMARTS
static int
SMARTS_MODE_IS_SMILES
-
Constructor Summary
Constructors Constructor Description SmilesParser()
Creates a new SmilesParser that doesn't allow SMARTS features to be present in parsed strings.SmilesParser(int mode, boolean createSmartsWarnings)
Creates a new SmilesParser that may or may not allow SMARTS features to be present in parsed strings.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getSmartsWarning()
If createSmartsWarning in the constructor was passed as true, then this method returns a list of all SMARTS features, which could not be interpreted in the most recently parsed SMILES/SMARTS pattern.static void
main(java.lang.String[] args)
void
parse(StereoMolecule mol, byte[] smiles)
void
parse(StereoMolecule mol, byte[] smiles, boolean createCoordinates, boolean readStereoFeatures)
void
parse(StereoMolecule mol, byte[] smiles, int position, int endIndex)
void
parse(StereoMolecule mol, byte[] smiles, int position, int endIndex, boolean createCoordinates, boolean readStereoFeatures)
void
parse(StereoMolecule mol, java.lang.String smiles)
Parses the given smiles into the molecule, creates proper atom coordinates to reflect correct double bond geometries and translates tetrahedral and allene parities into up/down-bonds.StereoMolecule
parseMolecule(byte[] smiles)
Convenience method to quickly obtain a StereoMolecule from a SMILES string.StereoMolecule
parseMolecule(java.lang.String smiles)
Reaction
parseReaction(byte[] smiles)
Reaction
parseReaction(java.lang.String smiles)
void
setRandomSeed(long seed)
Depending on the parse() parameters, the SmilesParser may or may not generate new atom coordinates after parsing the SMILES.
-
-
-
Field Detail
-
SMARTS_MODE_IS_SMILES
public static final int SMARTS_MODE_IS_SMILES
- See Also:
- Constant Field Values
-
SMARTS_MODE_GUESS
public static final int SMARTS_MODE_GUESS
- See Also:
- Constant Field Values
-
SMARTS_MODE_IS_SMARTS
public static final int SMARTS_MODE_IS_SMARTS
- See Also:
- Constant Field Values
-
MODE_SKIP_COORDINATE_TEMPLATES
public static final int MODE_SKIP_COORDINATE_TEMPLATES
- See Also:
- Constant Field Values
-
MODE_MAKE_HYDROGEN_EXPLICIT
public static final int MODE_MAKE_HYDROGEN_EXPLICIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SmilesParser
public SmilesParser()
Creates a new SmilesParser that doesn't allow SMARTS features to be present in parsed strings. SMARTS features cause an exception. The fragment flag of created molecules is never set.
-
SmilesParser
public SmilesParser(int mode, boolean createSmartsWarnings)
Creates a new SmilesParser that may or may not allow SMARTS features to be present in parsed strings. If smartsMode is SMARTS_MODE_IS_SMILES, then any SMARTS features cause an exception. If smartsMode is SMARTS_MODE_IS_SMARTS, then the input string is considered a SMARTS, e.g. 'CC' is taken as fragment of two non-aromatic carbon atoms connected by a single bond and without any implicit hydrogen atoms. If smartsMode is SMARTS_MODE_IS_GUESS, then molecules is never set.- Parameters:
mode
- one of SMARTS_MODE... and optionally other mode flagscreateSmartsWarnings
- if true, then getSmartsWarning() may be used after parsing a SMILES or SMARTS
-
-
Method Detail
-
setRandomSeed
public void setRandomSeed(long seed)
Depending on the parse() parameters, the SmilesParser may or may not generate new atom coordinates after parsing the SMILES. In difficult cases the employed CoordinateInventor uses random decisions when optimizing colliding coordinates. In strained and bridged ring systems, generated coordinates may not correctly represent all E/Z-bond configurations. Calling this method with a seed != 0 causes the creation of reproducible atom coordinates.- Parameters:
seed
- value different from 0 in order to always create the same reproducible atom coordinates
-
parseMolecule
public StereoMolecule parseMolecule(java.lang.String smiles)
-
parseMolecule
public StereoMolecule parseMolecule(byte[] smiles)
Convenience method to quickly obtain a StereoMolecule from a SMILES string. If you process many SMILES, then the parse() methods are preferred, because they avoid the steady instantiation new StereoMolecules.- Parameters:
smiles
-- Returns:
-
parseReaction
public Reaction parseReaction(java.lang.String smiles) throws java.lang.Exception
- Throws:
java.lang.Exception
-
parseReaction
public Reaction parseReaction(byte[] smiles) throws java.lang.Exception
- Throws:
java.lang.Exception
-
getSmartsWarning
public java.lang.String getSmartsWarning()
If createSmartsWarning in the constructor was passed as true, then this method returns a list of all SMARTS features, which could not be interpreted in the most recently parsed SMILES/SMARTS pattern.- Returns:
-
parse
public void parse(StereoMolecule mol, java.lang.String smiles) throws java.lang.Exception
Parses the given smiles into the molecule, creates proper atom coordinates to reflect correct double bond geometries and translates tetrahedral and allene parities into up/down-bonds. SMARTS features are neglected unless setAllowSmartsFeatures(true) was called before parsing.- Parameters:
mol
-smiles
-- Throws:
java.lang.Exception
-
parse
public void parse(StereoMolecule mol, byte[] smiles) throws java.lang.Exception
- Throws:
java.lang.Exception
-
parse
public void parse(StereoMolecule mol, byte[] smiles, int position, int endIndex) throws java.lang.Exception
- Throws:
java.lang.Exception
-
parse
public void parse(StereoMolecule mol, byte[] smiles, boolean createCoordinates, boolean readStereoFeatures) throws java.lang.Exception
- Throws:
java.lang.Exception
-
parse
public void parse(StereoMolecule mol, byte[] smiles, int position, int endIndex, boolean createCoordinates, boolean readStereoFeatures) throws java.lang.Exception
- Throws:
java.lang.Exception
-
main
public static void main(java.lang.String[] args)
-
-