OK, I see. Right, now I understand the $ business -- these are PhP
substitutions. I see you need to identify these atoms by standard RasMol
format. That changes everything! You can't do this:

measure @a @ b

where a = "39:A.CA/1.1" and b = "40:A.CA/2.1"

what you  have to do instead is create the entire measure command as a
string and then execute it, like this:

script inline @{"measure {" + a + "} {" + b + "}"}

Minor comment: I would put the set and font commands earlier, out of the for
loop; no need to repeat those.

If you have a reference atom and then a list of atoms from different models,
I think the function would be this, provided you create an array of strings
that look like ["35:a.ca", "36:b.ca","36:b.ca",...] that has the reference
atom in position 1, and the target atoms in :


function crossMeasure(atomList){
    var n = atomList.length
    measures delete
    set measurementUnits angstroms
    set measurements 3
    font measure 16 serif bold
    for (var i = 2; i <= n; i++) {
      script inlne @{ "measure {" + atomList[1] + "/1.1}{" + atomList[i] +
"/" + i + ".1}" }
    }
}

Or maybe, if the homology models all have the same group, just:

function crossMeasure(atom1, atom2){
    var n = atomList.length
    measures delete
    set measurementUnits angstroms
    set measurements 3
    font measure 16 serif bold
    for (var i = 2; i <= n; i++) {
      script inlne @{ "measure {" + atom1 + "/1.1}{" + atom2 + "/" + i +
".1}" }
   }
}

Bob

On Mon, Mar 28, 2011 at 5:00 AM, Daniel Carbajo <daniel.carb...@gmail.com>wrote:

> Thanks a lot! Sorry for not answering before, I have been away during the
> weekend... So this seems it should work. I indeed use Jmol.js, but the atoms
> are preselected (they are C-alphas from residues known to be catalytic by
> the Catalytic Site Atlas) and, actually, the corresponding residue number
> (and even the atom number) might not be the same between the native
> structure and the homology models (but it will be the same in all homology
> models), so I modified the function like this:
>
> function crossMeasure(atomListN, atomListM){
>     var n = atomListM.length
>
>     measures delete
>     for (var i = 2; i <= n; i++) {
>       set measurementUnits angstroms
>       set measurements 3
>       font measure 16 serif bold
>       measure @{atomListN[1]} @{atomListM[i]}
>     }
> }
>
> So the parameters passed will directly be something like "4:A.ca" and
> "6:A.ca" ($selectedRES_native and $selectedRES_models).
> I save the functions in myfunctions.spt, I call it when I launch the applet
> and it seems to launch properly, but when I try to load the models (that are
> loaded one by one after launching the applet via a series of checkboxes) I
> get an alert saying "could not find applet jmolApplet0" and the models do
> not show up. This is how I launch the applet:
>
> $JMOL = "<script type=\"text/javascript\">
>                     jmolInitialize(\"Jmol-12new\", true);
>                     jmolSetAppletColor(\"white\");
>                     var jmolcmds = [
>                         \"load $ZIPtoUSE|Models_$code/$pdb.pdb\",
>                         \"set frank off; select all; hbonds off; spin off;
> wireframe off; spacefill off; trace off; set ambient 40; set specpower 40;
> slab off; ribbons off; cartoons off; label off; monitor off\",
>                         \"set showAxes true\",
>                         \"set appendNew true\",
>                         \"frame all\",
>                         \"display all\",
>                         \"select 1.1; cartoon; color white\",
>                         \"select 1.1 and :$cadena; color red\"
>                      ];
>                     jmolApplet([580,580], jmolcmds.join(\"; \"), \"script
> myfunctions.spt\");
>                 </script>";
>
> Do I have to place myfunctions.spt in a particular place? What am I doing
> wrong? Thanks again for all your help Bob and everyone in the list!
> Cheers,
>
> Daniel
>
>
>
>
>
> 2011/3/25 Robert Hanson <hans...@stolaf.edu>
>
>> OK, that's Jmol scripting, not JavaScript. Are you using Jmol.js for your
>> page (I hope)? How are you choosing the atoms -- is it a user click so it is
>> variable? Usually for that we use a pickCallback, from which you get an atom
>> index (a unique number for each atom in the full set of loaded atoms). I
>> would probably keep a set of useful Jmol script functions in a .spt file and
>> then load that when the applet loads. Like this:
>>
>>
>> jmolApplet(500,"set pickCallback 'myPickCallback'; script
>> myfunctions.spt")
>>
>> and then have a file myfunctions.spt:
>>
>> function crossMeasure(iAtom){
>>
>>    // find the atom number that is associated with this atom
>>    // I'm presuming all the measurements are between atoms
>>    // with the same atom number.
>>
>>     var atomNumber = {atomIndex = iAtom}.atomno
>>     var atomList = {atomno=atomNumber}
>>     var n = atomList.length
>>     measures delete
>>
>>     for (var i = 2; i <= n; i++) {
>>         measure @{atomList[1]} @{atomList[i]}
>>     }
>> }
>>
>>
>>
>> Then your pickCallback, which is a JavaScript function in the head of the
>> page, would look like this:
>>
>> function myPickCallback(appletID,atomID, atomIndex) {
>>    jmolScript("crossMeasure(" + atomIndex + ")")
>> }
>>
>> See how that works? The main scripting is done in Jmol, but we do the
>> callback to JavaScript. Another option would be to do it all in Jmol:
>>
>> jmolApplet(500,"set pickCallback 'jmolScript:crossMeasure(-1)'; script
>> myfunctions.spt")
>>
>> and then have a file myfunctions.spt:
>>
>> function crossMeasure(iAtom){
>>
>>    // find the atom number that is associated with this atom
>>    // I'm presuming all the measurements are between atoms
>>    // with the same atom number.
>>    // _atomPicked is the atom index of the most recent atom clicked on
>>
>>    if (iAtom < 0) { iAtom = _atomPicked }
>>     var atomNumber = {atomIndex = iAtom}.atomno
>>     var atomList = {atomno=atomNumber}
>>     var n = atomList.length
>>     measures delete
>>
>>     for (var i = 2; i <= n; i++) {
>>         measure @{atomList[1]} @{atomList[i]}
>>     }
>> }
>>
>> Then you don't need any JavaScript.
>>
>> Of course, you might want something on your page to turn this off by
>> setting pickCallback to ""
>>
>>
>>
>>
>> <script type="text/javascript">
>>>
>>> </script>
>>>
>>> And I would like to call it like:
>>> jmolCheckbox("crossMeasure($selectedRES.ca)", \"measure OFF\", \"show
>>> distances\");
>>> Is it possible?
>>>
>>>
>> How are you assigning selectedRES? If it's really a Jmol selection, then
>> what you would do is substitute something like this, maybe:
>>
>> jmolCheckbox("crossMeasure('selectedRes')", \"measure OFF\", \"show
>> distances\");
>>
>> and then:
>>
>> function crossMeasure(iAtom){
>>
>>    // find the atom number that is associated with this atom
>>    // I'm presuming all the measurements are between atoms
>>    // with the same atom number.
>>
>>    if (iAtom == "selectedRes") { iAtom = {selected and *.ca}[1].atomIndex
>> }
>>
>> ...
>>
>>
>>
>>
>>
>>
>>> Thanks again,
>>> Daniel
>>>
>>>
>>> 2011/3/25 Robert Hanson <hans...@stolaf.edu>
>>>
>>>> Here you  go:
>>>>
>>>> var atomList = {46:A.ca}
>>>> var n = atomList.length
>>>> for (var i = 2; i <= n; i++) {
>>>>   measure @{atomList[1]} @{atomList[i]}
>>>> }
>>>>
>>>>
>>>> Bob
>>>>
>>>> --
>>>> 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
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Enable your software for Intel(R) Active Management Technology to meet
>>>> the
>>>> growing manageability and security demands of your customers. Businesses
>>>> are taking advantage of Intel(R) vPro (TM) technology - will your
>>>> software
>>>> be a part of the solution? Download the Intel(R) Manageability Checker
>>>> today! http://p.sf.net/sfu/intel-dev2devmar
>>>> _______________________________________________
>>>> Jmol-users mailing list
>>>> Jmol-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>>>
>>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Enable your software for Intel(R) Active Management Technology to meet
>>> the
>>> growing manageability and security demands of your customers. Businesses
>>> are taking advantage of Intel(R) vPro (TM) technology - will your
>>> software
>>> be a part of the solution? Download the Intel(R) Manageability Checker
>>> today! http://p.sf.net/sfu/intel-dev2devmar
>>> _______________________________________________
>>> Jmol-users mailing list
>>> Jmol-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>>
>>>
>>
>>
>> --
>> 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
>>
>>
>> ------------------------------------------------------------------------------
>> Enable your software for Intel(R) Active Management Technology to meet the
>> growing manageability and security demands of your customers. Businesses
>> are taking advantage of Intel(R) vPro (TM) technology - will your software
>> be a part of the solution? Download the Intel(R) Manageability Checker
>> today! http://p.sf.net/sfu/intel-dev2devmar
>> _______________________________________________
>> Jmol-users mailing list
>> Jmol-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>
>>
>
>
> ------------------------------------------------------------------------------
> Enable your software for Intel(R) Active Management Technology to meet the
> growing manageability and security demands of your customers. Businesses
> are taking advantage of Intel(R) vPro (TM) technology - will your software
> be a part of the solution? Download the Intel(R) Manageability Checker
> today! http://p.sf.net/sfu/intel-dev2devmar
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>


-- 
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
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to