creepy behavior - Charge/MajorMirospeciesPlugin

User 21b7e0228c

16-12-2005 17:43:41

This time I try to get my protons set and their partial charges calculated. I therefore used the ChargePlugin in the way it's shown on the API page. Nice, but... if at given pH the major microspecies has one H atom more, 'cause it's protonated, you won't see it in the ORIGINAL compound. One should, therefore, fish for the major µspecies before getting the atom count. The trouble is that calling pp.getMajorMicrospecies() returns a NULL object - have a look at the attached charge.java!





At first, I tried with a simple ChargePlugin plugin and tried plugin.getMajorMicrospecies() - null ponter, too! I hoped that duplicating the pointer objects would settle things down - but it does not! The setH.java tool for just setting the protons (reattached) has hoever no trouble whatsoever to plugin.getMajorMicrospecies() - with exactly the same molecule(s)!! Somehow, the references to ChargePlugin AND µSpeciesplugin hate to coexist??





By the way - I also had a bad time with hydrogens! Doc says that IMPLICIT H are accounted for by setting this residual charge value of the heavy atom carrier. I tried my best to make mine very EXPLICIT so that they earn the right to be treated as any other atom by the ChargePlugin - , using, besides the stanardizer, the inMol.hydrogenize(true) trick, but no way! (The only explicit things I eventually managed to produce were some typical Transsylvanian references to non-standard sexual behaviors). Eventually I settled for the solution of redispatching the residual H charge of the heavy guys to the concerned H atoms- is that a good idea?





Cheers!

ChemAxon fb166edcbd

16-12-2005 19:48:18

I will look at this on Monday (19 Dec).

ChemAxon fb166edcbd

19-12-2005 17:47:40

If you want to get the major microspecies as plugin result then you should use the MajorMicrospeciesPlugin itself and not the ChargePlugin (which extends MajorMicrospeciesPlugin but does not return the major microspecies as result because of licensing issues). You can fix this by setting


Code:



pp = new MajorMicrospeciesPlugin();





instead of


Code:



pp = new ChargePlugin();








Furthermore, if you use





CalculatorPlugin.setMolecule(Molecule mol, boolean st, boolean om)
with parameter setting:


Code:



Molecule msMol = pc.setMolecule(mol, true, false);





then you will get the standardized microspecies that is used in the charge calculation in return - and this molecule will be used for atom indexing when enquiring charge values. In this case there are no explicit H-s since microspecies are returned in dehydrogenized form. You can use this molecule for charge output and also a dehydrogenized / hydrogenized version as SDF output.


I attach your test code with these modifications.





If you insist on the original molecule to be used for output (atom indexing) then there is no way to ask the microspecies from the plugin. Then you sre left with the solution you found: use a separate MajorMicrospeciesPlugin to get the microspecies.





However, there is no way to get a hydrogenized version of the microspecies to be used for atom indexing: either you use the origrinal molecule (not the microspecies) for atom indexing:


Code:



pc.setMolecule(mol);





which is equivalent to


Code:



pc.setMolecule(mol, true, true);





or else you decide to use the inner molecule (standardized, microspecies) that is actually used in the calculation as the molecule for atom indexing - but this is a dehydrogenized microspecies:


Code:



Molecule msMol = pc.setMolecule(mol, true, false);





You can then pick the summed hydrogen charge for each heavy atom by:


Code:



hchg[i]=pc.getResultantImplicitHCharge(i);





and finally you might hydrogenize the microspecies and distribute these resultant charges equally among the attached H atoms.





I attach the modified code, I tested it by:


Code:



java charge -f pharma.mol








Remark: you do not need the


Code:



pc.validate("...");





call from Marvin 4.0.2 / JChem 4.3.1

User 21b7e0228c

21-12-2005 16:48:30

Thanks, Nora - that seems to do the job, unless your input molecule IS hydrogenized (in that case, explicit H are NOT stripped off in msMol) In my hands, I found it necessary to dehydogenize the input molecule, then pass it to the charge calculator, eventually add hydrogens on a CLONE molecule and do the hydrogen balance (see attached). It works - for pharma.mol, the sum of charges (output in col #3) is +1, as they should be!

ChemAxon fb166edcbd

21-12-2005 17:53:17

dragos wrote:
Thanks, Nora - that seems to do the job, unless your input molecule IS hydrogenized (in that case, explicit H are NOT stripped off in msMol)
Actually, microspecies are always dehydrogenized - therefore you have the problem if your original input molecule contains explicit hydrogens.





Yes, it is a bit cumbersome if you both need the microspecies and want to use the original molecule for atom indexing at the same time. I will extend the plugin API so that the microspecies could be fetched separately. I will add some example code after I have written this.





In your code you use the fact that if you add atoms to a molecule (e.g. hydrogenize) then atoms will be added to the end of the atopm array - that is, original atom indexes are not changed. This is true in most cases, one exception is the case of reaction molecules.

ChemAxon fb166edcbd

22-12-2005 15:30:37

I have added a new function:


Code:



    /**


     * Returns the molecule used in the calculation.


     * This can be a standardized and/or microspecies version of the input molecule.


     * Standardized if parameter 'st' is set to <code>true</code> in


     * {@link #setMolecule(chemaxon.struc.Molecule, boolean)} or


     * {@link #setMolecule(chemaxon.struc.Molecule, boolean, boolean)}.


     * Microspecies if standardized and the plugin extends


     * {@link chemaxon.marvin.calculations.MajorMicrospeciesAccessorPlugin}


     * and the pH is set in


     * {@link chemaxon.marvin.calculations.MajorMicrospeciesAccessorPlugin#setpH(double)}.


     * @return the molecule used in the calculation


     * @since Marvin 4.1


     */


    public Molecule getCalcMolecule()





to CalculatorPlugin.


This will be available from Marvin 4.1.


This function returns the molecule actually used in the calculation (standardized, microspecies) - the same returned by


Code:



CalculatorPlugin.setMolecule(mol, true, false)





but it is without the side-effect of using this standardized/microspecies molecule for atom indexing when asking for the plugin results (e.g. charge values).





In this way it will be possible to use the original molecule for atom indexing (and identifying atoms), use the already existing


CalculatorPlugin.getAtomIndex(int)


function to map original atom idnexes to corresponding atom indexes in the standardized/microspecies molecule and hence avoid post-transformations of the input molecule. The necessary transformations can be done beforehand (e.g. adding explicit H-s), then use this molecule to get the results and the standardized/microspecies molecule for the microspecies.





Still there is some difficulty with the hydrogens - these do not have corresponding atoms in the microspecies, since the microspecies is dehydrogenized - therefore you have to go back to the original molecule and ask for the resultant hydrogen charge as before.





I attach sample code that does this. But it uses the new function CalculatorPlugin.getCalcMolecule(), therefore you will be able to run it only from the next major release Marvin 4.1.