Skip to content

Commit

Permalink
The createSMILES() methods now take IAtomContainer rather than IMolec…
Browse files Browse the repository at this point in the history
…ule. Originally, IMolecule was the type since it was assumed that SMILES would only be generated for connected components - but the code already handles disconnected components. Since IAtomContainers are meant to support that, this change makes sense. Also a result is that we don't have to convert a IAtomContainer to IMolecule to generate SMILES

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
rajarshi authored and egonw committed May 23, 2010
1 parent 32cb936 commit 2399a18
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/main/org/openscience/cdk/smiles/SmilesGenerator.java
Expand Up @@ -24,15 +24,6 @@
*/
package org.openscience.cdk.smiles;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
import java.util.Vector;

import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.PseudoAtom;
import org.openscience.cdk.annotations.TestClass;
Expand All @@ -48,10 +39,10 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IIsotope;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IPseudoAtom;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IRingSet;
Expand All @@ -60,6 +51,15 @@
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.tools.manipulator.RingSetManipulator;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
import java.util.Vector;

/**
* Generates SMILES strings {@cdk.cite WEI88, WEI89}. It takes into account the
* isotope and formal charge information of the atoms. In addition to this it
Expand Down Expand Up @@ -133,7 +133,7 @@ public SmilesGenerator() {}

/**
* Create the SMILES generator.
* @param userAromaticityFlag if false only SP2-hybridized atoms will be lower case (default), true=SP2 or aromaticity trigger lower case (same as using setUseAromaticityFlag later)
* @param useAromaticityFlag if false only SP2-hybridized atoms will be lower case (default), true=SP2 or aromaticity trigger lower case (same as using setUseAromaticityFlag later)
*/
public SmilesGenerator(boolean useAromaticityFlag) {
this.useAromaticityFlag=useAromaticityFlag;
Expand Down Expand Up @@ -201,7 +201,7 @@ public SmilesGenerator setRings(IRingSet rings)
* @return the SMILES representation of the molecule
*/
@TestMethod("testCisResorcinol,testEthylPropylPhenantren,testAlanin")
public synchronized String createSMILES(IMolecule molecule)
public synchronized String createSMILES(IAtomContainer molecule)
{
try
{
Expand Down Expand Up @@ -285,7 +285,7 @@ public synchronized String createSMILES(IReaction reaction) throws CDKException
* @return the SMILES representation of the molecule
*/
@TestMethod("testAlaSMILES,testSugarSMILES")
public synchronized String createChiralSMILES(IMolecule molecule, boolean[] doubleBondConfiguration) throws CDKException
public synchronized String createChiralSMILES(IAtomContainer molecule, boolean[] doubleBondConfiguration) throws CDKException
{
return (createSMILES(molecule, true, doubleBondConfiguration));
}
Expand Down Expand Up @@ -316,7 +316,7 @@ public synchronized String createChiralSMILES(IMolecule molecule, boolean[] doub
* @see org.openscience.cdk.graph.invariant.CanonicalLabeler#canonLabel(IAtomContainer)
* @return the SMILES representation of the molecule
*/
public synchronized String createSMILES(IMolecule molecule, boolean chiral, boolean doubleBondConfiguration[]) throws CDKException
public synchronized String createSMILES(IAtomContainer molecule, boolean chiral, boolean doubleBondConfiguration[]) throws CDKException
{
IMoleculeSet moleculeSet = ConnectivityChecker.partitionIntoMolecules(molecule);
if (moleculeSet.getMoleculeCount() > 1)
Expand Down Expand Up @@ -358,9 +358,6 @@ public synchronized String createSMILES(IMolecule molecule, boolean chiral, bool
* If flag is true for a bond which does not constitute a valid double bond configuration, it will be
* ignored (meaning setting all to true will create E/Z indication will be pu in the smiles wherever
* possible, but note the coordinates might be arbitrary).
* @param detectAromaticity true=an aromaticity detection will be done
* (using setRings avoids ring search for that),
* false=no aromaticity detection will be done
* @exception CDKException At least one atom has no Point2D;
* coordinates are needed for creating the chiral smiles. This excpetion
* can only be thrown if chiral smiles is created, ignore it if you want a
Expand All @@ -370,7 +367,7 @@ public synchronized String createSMILES(IMolecule molecule, boolean chiral, bool
* @return the SMILES representation of the molecule
*/
@TestMethod("testCreateSMILESWithoutCheckForMultipleMolecules_withDetectAromaticity,testCreateSMILESWithoutCheckForMultipleMolecules_withoutDetectAromaticity")
public synchronized String createSMILESWithoutCheckForMultipleMolecules(IMolecule molecule, boolean chiral, boolean doubleBondConfiguration[]) throws CDKException
public synchronized String createSMILESWithoutCheckForMultipleMolecules(IAtomContainer molecule, boolean chiral, boolean doubleBondConfiguration[]) throws CDKException
{
if (molecule.getAtomCount() == 0)
{
Expand Down

0 comments on commit 2399a18

Please sign in to comment.