From: Robert H. <ha...@st...> - 2009-07-06 05:46:21
|
Hmm. javascript:alert(jmolGetPropertyAsArray("atomInfo", "all")[2].elemno) certainly works at http://chemapps.stolaf.edu/jmol/docs/examples-11/new.htm On Sun, Jul 5, 2009 at 3:42 PM, vikash jaiswal <vik...@gm...> wrote: > Hello Everyone, > > I am trying to get the list of atoms of a structure using the jmol applet. > I am using the method "jmolGetPropertyAsArray()" for the purpose. My code is > provided lower in this mail. > The application loads the applet and displays the protein structure but the > atom list is not shown. It always returns the length as 0 for the list of > atoms. > > Could someone please suggest what I may be doing wrong? > > Thanks in advance. > > Regards, > Vikash > > Code: > > <head> > <title>Trying to get atom names</title> > <script src="../Jmol.js" type="text/javascript"></script> > <script type="text/javascript"> > jmolInitialize("../"); > jmolSetAppletColor("black"); > jmolApplet(500 , "load 1MBA.pdb"); > > var appletIDsuffix = "0"; > var applet > var filePathName > var fileType > var fileName > > function atomident() > { > applet = document.getElementById("jmolApplet" + appletIDsuffix ); > var atoms= jmolGetPropertyAsArray("atomInfo","all"); > //var atoms= > jmolGetPropertyAsArray("atomInfo","selected",appletIDsuffix); > //var atoms = jmolGetPropertyAsJSON("atominfo", "atomno=1"); > //alert(jmolDecodeJSON(atoms)); > var tx = "Atoms list:<ol>"; > var tmpvk = atoms.length; > > for (var i=0; i<atoms.length;i++) > { tx += "<li>" + elemName(atoms[i].elemno, atoms[i].sym); > tx += " named " + atomName(atoms[i].name); > > tx += "</li>"; > > } > document.getElementById("result").innerHTML = tx + "</ol>" + tmpvk > ; > jmolScript("select none"); > } > > </script> > </head> > <body> > <form> > <br> > <input type="button" value="Atom Data" onClick="atomident()"> > > <br> > this is the result area: > <br> > <table border="1"> > <tr> > <td> > <div id="result">...</div> > </td> > </tr> > </table> > </form> > </body> > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Jmol-developers mailing list > Jmo...@li... > https://lists.sourceforge.net/lists/listinfo/jmol-developers > > -- Robert M. Hanson Professor of Chemistry St. Olaf College 1520 St. Olaf Ave. Northfield, MN 55057 http://www.stolaf.edu/people/hansonr phone: 507-786-3107 If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 |