getHybridizationState()

User 870ab5b546

22-06-2006 13:17:45

We suspected that getHybridizationState() was not working properly, so I created the attached jsp page to check. When I run it on any molecule, even a simple one like formaldehyde, getHybridizationState() always returns zero. I should note that the element's symbol is returned just fine. Can you explain?





The crucial code:





Code:
<%





   String substrate = request.getParameter("substrate");


   Molecule substrateMol = null;


   int numAtoms = 0;


   if (substrate != null) {


      substrateMol = MolImporter.importMol(substrate);


      numAtoms = substrateMol.getAtomCount();


   }





%>





...





   function getHybrids() {


      var str = document.mechapplet.getMol("mrv");


      document.tester.substrate.value=str;


      document.tester.submit();


   }





...





<% for (int j=0; j<numAtoms; j++) { %>


   <tr>


   <td><%=j%></td>


   <td><%=substrateMol.getAtom(j).getSymbol()%></td>


   <td><%=substrateMol.getAtom(j).getHybridizationState()%></td>


   </tr>


<% } %>


User 870ab5b546

22-06-2006 17:18:48

We just figured out that getHybridizationState() returns a valid hybridization state only if someone had previously executed setHybridizationState(int h) on that atom. It had seemed to us that getHybridizationState() should calculate the hybridization of an atom, and there was nothing in the documentation to say otherwise. You need to make clear in the documentation that getHybridizationState() does not calculate the hybridization of an atom, and that setHybridizationState(int h) allows you to set the hybridization of an atom to any value you want, regardless of chemical reality. In fact, I don't understand why you don't simply calculate the hybridization for us.





Another point on the documentation: It is not clear at first glance how the returned values of getAtomSymbol() and getSymbol() are supposed to differ, and it is not clear why all those getAtomSymbol() parameters exist and what they are supposed to do. You need to cross-reference getSymbol() and getAtomSymbol(), and you need to explain more clearly the input and output of the latter.

ChemAxon efa1591b5a

23-06-2006 10:39:10

Hi Bob,





MoleculeGraph.calcHybridization() calculates and sets hybridization states for each atom. Rules are rather simple and wired in the java code, thus you cannot customize rules directly.





Regards,


Miklos

User 870ab5b546

23-06-2006 12:42:58

May I suggest that you cross-reference this method in your documentation for getHybridizationState() and setHybridizationState()? The cross-reference would have saved us much grief.

ChemAxon efa1591b5a

23-06-2006 12:56:51

Very true!!! It'll be done in the next release of Marvin. Thanks Bob!





Regards,


Miklos

User 870ab5b546

23-06-2006 13:45:20

I've tried out calcHybridization() and it works well. However, I tried calculating the hybridization of an H atom, and it returned 0 for unknown. You give a constant, HS_S, for the s hybridization state, so why is the hybridization of H being returned as unknown?

ChemAxon efa1591b5a

23-06-2006 13:58:54

It's a bug. We'll fix it, thanks!!

ChemAxon efa1591b5a

23-06-2006 14:01:34

I fixed it, should be O.K. in the next release.