Search in sources :

Example 1 with SmilesParser

use of org.openscience.cdk.smiles.SmilesParser in project MassBank-web by MassBank.

the class StructureToSvgStringGenerator method structureFromSMILES.

public static IAtomContainer structureFromSMILES(String smiles) {
    IAtomContainer mol = null;
    try {
        // get atom container
        SmilesParser smipar = new SmilesParser(DefaultChemObjectBuilder.getInstance());
        mol = smipar.parseSmiles(smiles);
    } catch (CDKException e) {
        System.out.println("Warning: " + e.getLocalizedMessage());
    }
    return mol;
}
Also used : SmilesParser(org.openscience.cdk.smiles.SmilesParser) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) CDKException(org.openscience.cdk.exception.CDKException)

Example 2 with SmilesParser

use of org.openscience.cdk.smiles.SmilesParser in project Smiles2Monomers by yoann-dufresne.

the class CDKMoleculesTests method setUp.

@Before
public void setUp() throws Exception {
    this.testFile = new File("data_tests/pictureTest.png");
    if (this.testFile.exists())
        this.testFile.delete();
    this.smiles = "c1ccccc1";
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    this.imol = null;
    try {
        this.imol = sp.parseSmiles(this.smiles);
    } catch (InvalidSmilesException e) {
        e.printStackTrace();
    }
}
Also used : SmilesParser(org.openscience.cdk.smiles.SmilesParser) InvalidSmilesException(org.openscience.cdk.exception.InvalidSmilesException) File(java.io.File) Before(org.junit.Before)

Aggregations

SmilesParser (org.openscience.cdk.smiles.SmilesParser)2 File (java.io.File)1 Before (org.junit.Before)1 CDKException (org.openscience.cdk.exception.CDKException)1 InvalidSmilesException (org.openscience.cdk.exception.InvalidSmilesException)1 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)1