Chemical reactions take place between two or more molecules called reactants , and results other molecules called products . Sometimes other molecule may participate in the reaction, the agent . Similarly, the chemaxon.struc.RxnMolecule
class that represents the chemical reactions, embeddes two or more molecules.
The RxnMolecule.addComponent(Molecule, int)
method adds the reactant, agent and result Molecule object to the RxnMolecule
. In the argument of the method Molecule
is molecule object to be added, while the integer flag specifies the type of the component. The constants of the RxnMolecule
class can be used:
RxnMolecule.REACTANTS
RxnMolecule.AGENTS
RxnMolecule.PRODUCTS
To change the type of the reaction arrow, use the RxnMolecule.setReactionArrowType(int)
. You can use the predefined constants:
RxnMolecule.REGULAR_SINGLE
RxnMolecule.TWO_HEADED_SINGLE
RxnMolecule.REGULAR_DOUBLE
RxnMolecule.TWO_HEADED_DOUBLE
RxnMolecule.RESONANCE
RxnMolecule.RETROSYNTHETIC
RxnMolecule.EQUILIBRIUM
Example for building a simple reaction
/*
* Copyright (c) 1998-2014 ChemAxon Ltd. All Rights Reserved.
* This software is the confidential and proprietary information of
* ChemAxon. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms of the agreements
* you entered into with ChemAxon.
*
*/
package chemaxon.examples.strucrep;
import java.io.IOException;
import chemaxon.calculations.clean.Cleaner;
import chemaxon.formats.MolExporter;
import chemaxon.formats.MolImporter;
import chemaxon.struc.Molecule;
import chemaxon.struc.RxnMolecule;
/**
* Example class. Creates a basic RxnMolecule.
*
* @author Janos Kendi
*
*/
public class BuildRxnMolecule {
public static void main(String[] args) throws IOException {
// Create an empty reaction
RxnMolecule mol = new RxnMolecule();
// Create the components
Molecule reactant1 = MolImporter.importMol("CC(=C)C");
Molecule reactant2 = MolImporter.importMol("Cl");
Molecule agent = MolImporter.importMol("CCOCC");
Molecule product = MolImporter.importMol("C(Cl)(C)(C)C");
// Add the components
mol.addComponent(reactant1, RxnMolecule.REACTANTS);
mol.addComponent(reactant2, RxnMolecule.REACTANTS);
mol.addComponent(agent, RxnMolecule.AGENTS);
mol.addComponent(product, RxnMolecule.PRODUCTS);
// Calculate coordinates.
Cleaner.clean(mol, 2, null);
// Change the reaction arrow type.
mol.setReactionArrowType(RxnMolecule.EQUILIBRIUM);
System.out.println(MolExporter.exportToFormat(mol, "mrv:P"));
}
}
Reaction of aromatic nitration
package chemaxon.examples.strucrep
import chemaxon.struc.*;
import chemaxon.formats.MolImporter;
import chemaxon.formats.MolFormatException;
/**
* Example class for structure manipulation.
* Creates a simple reaction.
*
* @author Andras Volford
*
*/
public class AromaticNitration {
public static void main(String[] args) {
// create an empty Molecule
RxnMolecule m = new RxnMolecule();
try{
Molecule reactant = MolImporter.importMol("c1ccccc1");
Molecule agent = MolImporter.importMol("N(O)(=O)=O.S(O)(O)(=O)=O");
Molecule product = MolImporter.importMol("c1ccccc1N(=O)=O");
m.addComponent(reactant, RxnMolecule.REACTANTS);
m.addComponent(agent, RxnMolecule.AGENTS);
m.addComponent(product, RxnMolecule.PRODUCTS);
m.addComponent(MolImporter.importMol("O"), RxnMolecule.PRODUCTS);
System.out.println(m.toFormat("mrv"));
} catch (MolFormatException e) {
System.err.println("Format not recognised.");
}
}
}