public class ReactionTest { public static void main(String [] args) throws CDKException, IOException { //Crea una instancia sin crear nuevo elemento! IChemObjectBuilder iChemObjectBuilder = SilentChemObjectBuilder.getInstance(); //Convierte el texto a una molecula SmilesParser smilesParser = new SmilesParser(iChemObjectBuilder); //smilesParser crea la referencia;pareseSmiles es un método que devuelve IAtomContainer IAtomContainer ethanol = smilesParser.parseSmiles("CCO"); IAtomContainer aceticAcid = smilesParser.parseSmiles("CC=OO"); IAtomContainer bleach = smilesParser.parseSmiles("ClO");
Reaction reaction = new Reaction(); ethanol.setProperty(CDKConstants.TITLE,"Ethanol");//Crea un título a la imagen reaction.setProperty(CDKConstants.TITLE,"reaction1");//Crea tíyulo a la reacción reaction.addReactant(ethanol); reaction.addAgent(bleach); reaction.addProduct(aceticAcid);
DepictionGenerator depictionGenerator = new DepictionGenerator(); depictionGenerator = depictionGenerator.withFillToFit().withAtomColors() .withSize(500,500).withMolTitle().withRxnTitle(); //Usando ambos títulos //Al depict() se le asigna un elemento de IAtomContainer depictionGenerator.depict(reaction).writeTo("reaction.png"); depictionGenerator.depict(ethanol).writeTo("ethanol.png"); } } |