I am trying to load a cube file with load data and displaying isosurfaces. I had a working script where I could read from a file that was present on the webserver which looked like the following:
Unfortunately I can no longer save files on the webserver and so have to retrieve the cube files through an API call. As such I will have to use the 'load data' syntax to use the file as loaded in the variable directly.
In my javascript I thus have a variable 'result' that contains the cube file I want to display. With the following script I can split it on newlines and add it explicitly to the jsmol script like so:
varscript='load data "myData"\n';script+=result;script+='end "myData"\n';Jmol.script(resultsApplet,script);
This works but I now do not know how to add isosurfaces since I no longer can reference a filename like in the first script. How would I add isosurfaces in the latter case?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok I will try to elaborate. The first script I posted works fine and reads a cube file directly from disk on the webserver. However I need to replicate this script that does not take the input from file but rather from a javascript variable. I will retrieve the file that is to be plotted from another server through a HTTP get request through an ajax call like so:
The variable result now contains the contents of the file that I want to display in jsmol. I was hoping to adapt the original script to use this variable in stead of the file on disk with the following:
However this does not work and the applet never displays the cube file. I am not sure how the isosurface command works but I think that is the problem now. In the original script the isosurface command also took the stateFile variable which in that case contained the path to the file on disk. But in the second script there is no file on disk and so I am not sure how I should adapt the isosurface commands accordingly.
Hopefully this clears up the situation.
I thank you for your time
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your syntax with the "neg" and "pos" is very very old. We don't generally
do that anymore. Instead we just use two-color isosurface using the PHASE
keyword
There is no need for the data statement; in that code you sent you weren't
using it anyway. I would never recommend inserting a full CUBE file into a
script. That's not going to perform well.
Ok I will try to elaborate. The first script I posted works fine and reads
a cube file directly from disk on the webserver. However I need to
replicate this script that does not take the input from file but rather
from a javascript variable. I will retrieve the file that is to be plotted
from another server through a HTTP get request through an ajax call like so:
The variable result now contains the contents of the file that I want to
display in jsmol. I was hoping to adapt the original script to use this
variable in stead of the file on disk with the following:
var stateFile = result; // result contains the contents of the file
script = "set echo top left;font echo 16;echo \"Reading...\";refresh;\n";
script += 'load data "myData";\n';
script += stateFile;
script += 'end "myData"\n';
script += "isosurface pos .001 '"+stateFile+"';color isosurface translucent;";
script += "isosurface neg -.001 '"+stateFile+"';color isosurface translucent;";
script += "selectionHalos on;select "+data.atomNo+";javascript deleteStateFileFromServer();";
However this does not work and the applet never displays the cube file. I
am not sure how the isosurface command works but I think that is the
problem now. In the original script the isosurface command also took the
stateFile variable which in that case contained the path to the file on
disk. But in the second script there is no file on disk and so I am not
sure how I should adapt the isosurface commands accordingly.
--
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department 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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok I have tried to insert the http get request directly into the isosurface command but that does not seem to work. Probably I am doing something wrong but I am having a hard time debugging what that might be.
Right now I use the javascript:
The applet starts but just shows "loading..." for ever in the upper left corner. Nothing is being loaded though and no errors are thrown. I have verified that the url to the file is correct and will download the file. Am I missing something?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok I have tried to insert the http get request directly into the
isosurface command but that does not seem to work. Probably I am doing
something wrong but I am having a hard time debugging what that might be.
Right now I use the javascript:
var scr = 'isosurface cutoff 0.001 phase "https://server.edu/path/file/state.cube?view=read"';Jmol.script(resultsApplet, scr);
The applet starts but just shows "loading..." for ever in the upper left
corner. Nothing is being loaded though and no errors are thrown. I have
verified that the url to the file is correct and will download the file. Am
I missing something?
--
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department 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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to load a cube file with load data and displaying isosurfaces. I had a working script where I could read from a file that was present on the webserver which looked like the following:
Unfortunately I can no longer save files on the webserver and so have to retrieve the cube files through an API call. As such I will have to use the 'load data' syntax to use the file as loaded in the variable directly.
In my javascript I thus have a variable 'result' that contains the cube file I want to display. With the following script I can split it on newlines and add it explicitly to the jsmol script like so:
This works but I now do not know how to add isosurfaces since I no longer can reference a filename like in the first script. How would I add isosurfaces in the latter case?
Explain what you mean by "using an API". How is that different from just
calling that same service within the isosurface command?
Ok I will try to elaborate. The first script I posted works fine and reads a cube file directly from disk on the webserver. However I need to replicate this script that does not take the input from file but rather from a javascript variable. I will retrieve the file that is to be plotted from another server through a HTTP get request through an ajax call like so:
The variable
resultnow contains the contents of the file that I want to display in jsmol. I was hoping to adapt the original script to use this variable in stead of the file on disk with the following:However this does not work and the applet never displays the cube file. I am not sure how the isosurface command works but I think that is the problem now. In the original script the isosurface command also took the stateFile variable which in that case contained the path to the file on disk. But in the second script there is no file on disk and so I am not sure how I should adapt the isosurface commands accordingly.
Hopefully this clears up the situation.
I thank you for your time
Your syntax with the "neg" and "pos" is very very old. We don't generally
do that anymore. Instead we just use two-color isosurface using the PHASE
keyword
I don't see why you couldn't do this:
isosurface cutoff 0.001 phase "
http://wherever.server.edu/file.cube?view=read"
There is no need for the data statement; in that code you sent you weren't
using it anyway. I would never recommend inserting a full CUBE file into a
script. That's not going to perform well.
Bob
On Tue, Apr 28, 2015 at 12:27 PM, Plank sphuber@users.sf.net wrote:
--
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department 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
Ok I have tried to insert the http get request directly into the isosurface command but that does not seem to work. Probably I am doing something wrong but I am having a hard time debugging what that might be.
Right now I use the javascript:
The applet starts but just shows "loading..." for ever in the upper left corner. Nothing is being loaded though and no errors are thrown. I have verified that the url to the file is correct and will download the file. Am I missing something?
Could be your page is not https. Should be some JavaScript errors there.
Also, if Jmol caught the error, you could use
resultsApplet._showInfo(true)
and see if there is something in the Jmol console.
On Tue, Apr 28, 2015 at 4:21 PM, Plank sphuber@users.sf.net wrote:
--
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department 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