Brian Ramos wrote:

> Bob,
>
> That's a great idea but I still want to check in to make sure that I 
> am not over complicating this for myself.
>
> Essentially, I want a feature (menu item, jbutton, etc) that will 
> print to a file the distances between each hydrogen atom for each 
> model that is currently loaded in a format like this:
>
> #model x
> H1 H2 0.243
> H1 H3 0.343
> ...
>
> #model y
> ...
>
> Using your suggestion from before, my next course of action is to run 
> the following script:
>
> measure all (hydrogen and */n) (hydrogen and */n)
>
> where n will be iterated across the model numbers for a particular 
> loaded file.  Taking the return value from the JmolViewer.script 
> method, I was planning on parsing it to attain the atom numbers, that 
> would then be used to index into the atomNames array in the 
> JmolViewer's modelSet object to get the name of each particular 
> hydrogen atom.  Does this seem like too much of a workaround? Is there 
> a simpler way to attain this data?
>
You have an application, right? not an applet? If so, then you can use

Vector info = (Vector) viewer.getProperty(null,"measurementInfo", null)

This produces a vector listing all the measurements, and there's no 
parsing. Just take a look at org.jmol.shapes.Measures.java:

  private Vector getAllInfo() {
    Vector info = new Vector();
    for (int i = 0; i< measurementCount; i++) {
      info.addElement(getInfo(i));
    }
    return info;
  }
 
  private Hashtable getInfo(int index) {
    int count = measurements[index].getCount();
    Hashtable info = new Hashtable();
    info.put("index", new Integer(index));
    info.put("type", (count == 2 ? "distance" : count == 3 ? "angle"
        : "dihedral"));
    info.put("strMeasurement", measurements[index].getString());
    info.put("count", new Integer(count));
    info.put("value", new Float(measurements[index].getValue()));
    Vector atomsInfo = new Vector();
    for (int i = 0; i < count; i++) {
      Hashtable atomInfo = new Hashtable();
      Atom atom = modelSet.atoms[measurements[index].getIndex(i + 1)];
      atomInfo.put("_ipt", new Integer(atom.getAtomIndex()));
      atomInfo.put("atomno", new Integer(atom.getAtomNumber()));
      atomInfo.put("info", atom.getInfo());
      atomsInfo.addElement(atomInfo);
    }
    info.put("atoms", atomsInfo);
    return info;
  }

That should be all you need. You might have to be careful with threads, 
as the getProperty command won't be queued like the original script 
command would be. If that turns out to be an issue, we can make

  Viewer.defineMeasurement(Vector monitorExpressions, float[] rangeMinMax,
                         boolean isDelete, boolean isAllConnected,
                         boolean isShowHide, boolean isHidden, String 
strFormat)

public.




> Any suggestions would be greatly appreciated.
>
> Thanks.
>   
>
> On Mon, Jun 16, 2008 at 10:41 AM, Bob Hanson <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     Brian, why not just do it with a simple Jmol script:
>
>     measure ALL {*} {*}; show measurements
>
>
>
>
>     Brian Ramos wrote:
>
>     > Hi,
>     >
>     > (Since this is a different question, I figured I'd start a different
>     > thread.)
>     >
>     > I'm trying to add a reporting feature that will calculate distances
>     > between all pairs of atoms in each model of either an sdf or mol
>     > file.  I've never really worked on a project this big so I'm having
>     > trouble wrapping my head around jmol's internal representation
>     of sets
>     > of atoms for a given model.  In essence, how would I go about
>     > iterating through each model in a file in such a way that I can
>     > iterate through all the atoms in each model individually and get
>      the
>     > atom info(xyz coords) for each atom? I am currently looking through
>     > the source and am getting lost when it comes to modelsets vs. atoms
>     > vs. models.  How exactly do I get atom info for a model that is not
>     > currently being displayed?
>     >
>     > Thanks in advance,
>     > Brian
>     >
>     >------------------------------------------------------------------------
>     >
>     >-------------------------------------------------------------------------
>     >Check out the new SourceForge.net Marketplace.
>     >It's the best place to buy or sell services for
>     >just about anything Open Source.
>     >http://sourceforge.net/services/buy/index.php
>     >
>     >------------------------------------------------------------------------
>     >
>     >_______________________________________________
>     >Jmol-developers mailing list
>     >[email protected]
>     <mailto:[email protected]>
>     >https://lists.sourceforge.net/lists/listinfo/jmol-developers
>     >
>     >
>
>
>     --
>     Robert M. Hanson
>     Professor of Chemistry
>     St. Olaf College
>     Northfield, MN
>     http://www.stolaf.edu/people/hansonr
>
>
>     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
>
>
>
>     -------------------------------------------------------------------------
>     Check out the new SourceForge.net Marketplace.
>     It's the best place to buy or sell services for
>     just about anything Open Source.
>     http://sourceforge.net/services/buy/index.php
>     _______________________________________________
>     Jmol-developers mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://lists.sourceforge.net/lists/listinfo/jmol-developers
>
>
>------------------------------------------------------------------------
>
>-------------------------------------------------------------------------
>Check out the new SourceForge.net Marketplace.
>It's the best place to buy or sell services for
>just about anything Open Source.
>http://sourceforge.net/services/buy/index.php
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Jmol-developers mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/jmol-developers
>  
>


-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


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



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to