difference between Reaction, Molecule and RxnMolecule

User ae63c4f22b

20-09-2006 15:46:02

Hello,




I am currently using Reactor, and I should have some informations about the differents classes : Molecule, RxnMolecule and Reaction? I don't really see the differences between this tree classes.




For example :


To load reactions from a file, I must use the methode read of MolImporter witch return Molecule.




And to define a reaction, I can use either Reaction, or Molecule (but witch apear to be a RxnMolecule)




thanks,


Drivers2



PS : sorry for my bad english

ChemAxon e08c317633

20-09-2006 17:06:28

Hi Nicolas,
drivers2 wrote:
Hello,





I am currently using Reactor, and I should have some informations about the differents classes : Molecule, RxnMolecule and Reaction? I don't really see the differences between this tree classes.
Molecule: I think it's clear (see http://www.chemaxon.com/jchem/doc/api/chemaxon/struc/Molecule.html)





RxnMolecule (subclass of the Molecule class): a Molecule, that knows about reactants, products, etc. For example it has a getReactant(int i) method to get the i-th reactant (a Molecule object) from the reaction it describes. (see http://www.chemaxon.com/jchem/doc/api/chemaxon/struc/RxnMolecule.html)





Reaction (it is not a subclass/superclass of the Molecule object): a reaction object that stores the reaction (reactants, products, etc.), the reaction rules (used in Reactor), and information about changing atoms and bonds. (see http://www.chemaxon.com/jchem/doc/api/chemaxon/reaction/Reaction.html)
Quote:



For example :


To load reactions from a file, I must use the methode read of MolImporter witch return Molecule.
Yes, we read Molecule-s with MolImporter (RxnMolecule IS-A Molecule).
Quote:



And to define a reaction, I can use either Reaction, or Molecule (but witch apear to be a RxnMolecule)


Yes, you can use either Molecule, or Reaction as input for Reactor. The Molecule input has to be a "reaction molecule", but you don't have to convert it to RxnMolecule object. We will throw an exception if the input Molecule is not a "reaction molecule". RxnMolecule is also accepted as input, because it IS-A Molecule. In fact when Molecule is used as input, than we convert it to Reaction (object), so you do not have to bother with this conversion step, we will do it for you.





Best regards,


Zsolt

User ae63c4f22b

21-09-2006 14:19:42

Hello,




OK, so, a Molecule (the class) can contain either a molecule or a reaction. thanks!




When I call











Code:
Molecule reaction = importer.read();




It works perfectly, but, when I call












Code:
Molecule reaction = new Molecule(importer.read());




It doesn't work (an exception is throwed : "Not a reaction molecule" when I set the reaction in reactor)


And I don't understand why that make that!?




I have a second question :


when I load a reaction, it's recommended to use












Code:
importer.setQueryMode(true);




knowing that I don't know the file format that will be loaded, or I mistake for something else?




thank,


Drivers2

ChemAxon a3d59b832c

22-09-2006 07:10:03

drivers2 wrote:
but, when I call


Code:
Molecule reaction = new Molecule(importer.read());



It doesn't work (an exception is throwed : "Not a reaction molecule" when I set the reaction in reactor)


And I don't understand why that make that!?
Because here you create an empty molecule with a parent coming from your file. (Parent molecule does not make much sense here, but for example, a reactant molecule's parent is the whole reaction RxnMolecule.)





Because of the confusion with "copy constructors", this constructor - new Molecule(Molecule) - has been already removed in the latest version.
drivers2 wrote:
I have a second question :


when I load a reaction, it's recommended to use


Code:
importer.setQueryMode(true);



knowing that I don't know the file format that will be loaded, or I mistake for something else?
This option is only relevant to distinguish between SMILES and SMARTS file formats. See for example this topic: http://www.chemaxon.com/forum/ftopic236.html&highlight=setquerymode





Best regards,


Szabolcs

User ae63c4f22b

26-09-2006 13:20:50

ok,


thank you!




Drivers2