Hi again!
Thank you very much for your help. I couldn't make it work as provided, but 
your code allowed me to understand the dynamics of the callbacks and all that, 
so I managed to solve my problem. I understand it's not the best, cleanest 
solution, but it will work for my application.
Basically I grasp what i need by checking the length of y, because it will be 
large only when it contains a protein sequence.
I have this in the script tag:
var residuesVar = "";

function titi(x, y, z) {
    if (y.length > 30) { residuesVar = y; alert(residuesVar)}   //the alert 
here is just helping me see that it received the data
    return null;
}

I am doing this when I load the PDB:

set MessageCallBack 'titi'


And then this in the html, mimicking what my code will contain:
<a href="javascript:Jmol.script(jmolApplet0,'show RESIDUES')">Play with protein 
sequence</a><p>

If a cleaner solution comes up, it will be welcome, but I can at least go on 
with my project. Best,
Luciano
PS Your chemagic is an amazing website!

     De: Otis Rothenberger <osrot...@chemagic.com>
 Para: Luciano Abriata <luciano_abri...@yahoo.com>; 
"jmol-users@lists.sourceforge.net" <jmol-users@lists.sourceforge.net> 
 Enviado: Domingo, 18 de enero, 2015 20:49:44
 Asunto: Re: [Jmol-users] JSmol: how to put a protein's sequence into a 
javascript variable
   
Luciano,
OK, a bit more than 15 minutes, but I wanted to test this:
Step One -
You need to establish the message call back. One way to do this is in your 
model load script with the following:
set MessageCallback "MessageCallback"

 You can call the function anything you want. Here I'm calling it 
"MessageCallback."
Step Two-
I find it easier to do this with global variables because I can't  always find 
an identifiable handle in the actual value I want. These two globals will 
hopefully be clear to you in step Three:
var messageSwitch = false;var residuesVar = "";
Globalize them by defining them outside any function.
Step Three-
Write an appropriate callback script in your function to get the value:
function MessageCallback(x, y, z) {    if (messageSwitch) { residuesVar = y; 
messageSwitch = false; }    if (z.toLowerCase().indexOf("show residues") > -1) 
{ messageSwitch = true; }    return null;}
There may be a more elegant way to handle this, but I've had problems getting z 
without the global trick above. For example, in "show center", the word center 
is in Y - you could get it without the global two step above. Other shows, 
however, do not appear to have an identifiable handle - hence the two step with 
globals above.
residuesVar could of course be generic for any show value that you want to 
capture. A statements like

if (z.toLowerCase().indexOf("show residues") > -1) { messageSwitch = true; }

could also be generalized for other shows.
Hastily written! Feel free to query me further...


Otis
-- 
Otis rothenbergero...@chemagic.com

  
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to