Dear Luciano,

Below is a script that selects the frontmost atom as the molecule is rotated by the mouse. It defines a set of 4 atoms, and whichever becomes frontmost is selected. This script can be adapted to run any arbitrary script triggered by one of a specified set of atoms becoming frontmost due to rotation of the molecule with the mouse. Thus, it could be adapted to label the frontmost atom.

The script defines a set of 4 atoms in atomlist. Every 100 milliseconds, it runs checkOrient(), which re-determines which of the 4 atoms is frontmost, and selects it. The selection is visible because selectionHalos is on.

Copy the script below and paste it into the Jmol console, or paste it into a plain text file, and drop that file into Jmol. As you rotate the molecule with the mouse, the frontmost atom is highlighted with a yellow halo. It does not seem to work if the molecule is spinning.

In April, 2012, we had the pleasure of a visit by Bob Hanson at our campus (UMass, Amherst). Craig Martin's Molecular Playground (website is currently unresponsive, but http://molecularplayground.org) was a major topic of discussion. Karsten Theis asked Bob if, when a person rotates the projected molecule by waving their arm, a script could be triggered to show more detail about whatever is in front. Within one day, Bob came up with orient.spt (below). Here is a photo commemorating this meeting: http://proteopedia.org/w/Proteopedia:Scrapbook#Molecular_Playground_Team -- as far as I know, this method has not yet been incorporated into Molecular Playground modules, or any other uses.

--------------------------

// orient.spt -- tracks the orientation of four points
// This script by Robert Hanson, April, 2012 for Karsten Theis, Eric Martz, Craig Martin. // The frontmost of the 4 atoms specified in atomlist is selected every 0.1 sec. // This script can be adapted to run any arbitrary script when a specified atom
// becomes the frontmost of a specified set of atoms.

load DATA "mol"
C:/jmol-dev/bobtest/mmff94_dative.mol2
__Jmol-12_04301213583D 1   1.00000     0.00000     0
Jmol version 12.3.24_dev  2012-04-27 23:05 EXTRACT: ({0:24})
 25 26  0  0  0  0              1 V2000
  -8.19190  -2.59960  15.52080 N   0  0  0  0  0  0
  -7.34730  -2.94810  16.47440 C   0  0  0  0  0  0
  -7.02800  -2.03140  17.44970 N   0  0  0  0  0  0
  -6.80300  -4.16350  16.55330 N   0  0  0  0  0  0
  -7.15100  -5.04140  15.59320 C   0  0  0  0  0  0
  -6.48610  -6.26490  15.62980 N   0  0  0  0  0  0
  -8.03730  -4.74600  14.54960 C   0  0  0  0  0  0
  -8.39880  -5.63640  13.58900 N   0  0  0  0  0  0
  -9.27230  -5.22870  12.63230 C   0  0  0  0  0  0
  -9.64070  -6.23510  11.58280 C   0  0  0  0  0  0
  -9.79140  -3.93470  12.64140 C   0  0  0  0  0  0
 -10.75920  -3.46050  11.59680 C   0  0  0  0  0  0
  -9.44170  -3.03720  13.60530 N   0  0  0  0  0  0
  -8.56300  -3.44580  14.55720 C   0  0  0  0  0  0
  -8.61250  -1.68180  15.51700 H   0  0  0  0  0  0
  -6.87870  -1.06530  17.18790 H   0  0  0  0  0  0
  -6.29240  -2.39870  18.05420 H   0  0  0  0  0  0
  -5.95280  -6.40360  16.48240 H   0  0  0  0  0  0
  -7.05940  -7.06120  15.35990 H   0  0  0  0  0  0
 -10.71720  -6.43030  11.60180 H   0  0  0  0  0  0
  -9.12410  -7.18450  11.75870 H   0  0  0  0  0  0
  -9.35260  -5.87520  10.59050 H   0  0  0  0  0  0
 -11.04610  -2.41970  11.78010 H   0  0  0  0  0  0
 -11.66930  -4.06770  11.61530 H   0  0  0  0  0  0
 -10.30480  -3.51330  10.60280 H   0  0  0  0  0  0
  1 15  1  0  0  0
  1 14  2  0  0  0
  1  2  1  0  0  0
  2  4  2  0  0  0
  2  3  1  0  0  0
  3 17  1  0  0  0
  3 16  1  0  0  0
  4  5  1  0  0  0
  5  7  2  0  0  0
  5  6  1  0  0  0
  6 19  1  0  0  0
  6 18  1  0  0  0
  7 14  1  0  0  0
  7  8  1  0  0  0
  8  9  2  0  0  0
  9 11  1  0  0  0
  9 10  1  0  0  0
 10 22  1  0  0  0
 10 21  1  0  0  0
 10 20  1  0  0  0
 11 13  2  0  0  0
 11 12  1  0  0  0
 12 25  1  0  0  0
 12 24  1  0  0  0
 12 23  1  0  0  0
 13 14  1  0  0  0
M  END
END "mol"

atomlist = ["C10","C12","N3","N6"]



function checkOrient() {
    ptcenter = {*}.xyz
    q = quaternion()    // current rotation
    asort = []
    for (var i = 1; i <= atomlist.length; i++) {
        var a = atomlist[i]
        var pt = {atomName=a}.xyz - ptcenter
        asort[i] = [a, (q%pt).z]
    }
    asort = asort.sort(2)
    var frontAtom = (asort[0])[1]
    select {atomName=frontatom}
}

selectionHalos on
# run checkOrient() every 100 milliseconds.
timeout "t1" -100 "checkOrient()"

----------------------------------------
-Eric

Eric Martz, Professor Emeritus, Dept Microbiology
U Mass, Amherst -- Martz.MolviZ.Org <http://Martz.MolviZ.Org>

 * Top Five 3D MolVis Tools: Top5.MolviZ.Org <http://top5.MolviZ.Org>
 * FirstGlance: 3D Molecules in /Nature/: FirstGlance.Jmol.Org
   <http://firstglance.jmol.Org>
 * Protein 3D Structure Wiki: Proteopedia.Org <http://proteopedia.Org>
 * Education: Biochem in 3D at MolviZ.Org <http://MolviZ.Org>
 * Find Functional Patches in Proteins: ConSurf <http://consurf.tau.ac.il>
 * Atlas of Macromolecules: Atlas.MolviZ.Org <http://atlas.MolviZ.Org>
 * Interactive Molecules in Architectural Spaces:
   MolecularPlayground.Org <http://molecularplayground.Org>
 * Workshops: Workshops.MolviZ.Org <http://workshops.MolviZ.Org>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to