Creating a reaction molecule programatically

ChemAxon fa971619eb

22-06-2006 14:03:41

I have 2 Molecule objects that I want to use to for the left and right hand side of a reaction.


How can I programatically create a new Molecule object from these 2 Molecules so that the new Molecule is the reaction?





Thanks





Tim

ChemAxon fb166edcbd

23-06-2006 09:08:08

Basically you should create an RxnMolecule and then add structures by addStructure(Molecule, int). This method will be renamed to addComponent(Molecule, int) in Marvin 4.1.





I attach some sample code with the new method name. It produces 2D output in MRV and therefore performs full clean if the reactant / product are in 0D while arranges components with the help of CleanUtil if reactant / product are in 2D (will be in the API in Marvin 4.1 - if you have an earlier version then just run full clean in all cases).





R-groups are not handles in the example, that is more complicated but I can also send some sample code if you need that (e.g. merge R-group defs from reactant / product into the reaction).





Example runs in 0D and 2D:


Code:



java RxnmolTest reactant.smiles product.smiles


java RxnmolTest reactant.mrv product.mrv