Re: [Jmol-users] Zoom calculation

2015-12-05 Thread simon

Thanks - this works.

I modified your script to also return the atoms at the max min  
positions so that these could be selected and subsequent calls to  
getScreenBoundary only had to examine the {selected} atoms (because  
there's no rotation between calls).

Curiously this showed that the 'rotate best' needed to be done first  
(before the initial zoom) otherwise the coordinates did not reflect  
the rotated model.
Perhaps the subsequent zoom forces a refresh...

Anyway, many thanks for your help with this - another job done :-)

Cheers

Simon

Quoting Rolf Huehne :

> Am 04.12.15 um 18:47 schrieb si...@publcif.co.uk:
>>
>> Thanks for this Angel
>>
>> My task was to effectively "crop" the model so that a static image
>> could be created that was as large as possible with respect to the
>> model, but also exactly reflected what would be seen in the applet -
>> i.e. the static image could be used in e.g. a PDF but scaled to a
>> 'thumbnail' size, but still had minimal margins and still represented
>> what the associated applet would show.
>>
>> Anyway, a script such as:
>>
>> zoom {visible} 0;
>> rotate best;
>> refresh;
>> margin=15;
>> c=0;
>> while ({visible}.sx.all.max < _width-margin && {visible}.sx.all.min >
>> margin && {visible}.sy.all.max < _height-margin &&
>> {visible}.sy.all.min > margin ) {
>>zm=100+c;
>>zoom {visible} @zm;
>>refresh;
>>c=c+1;
>>if (c>100) {break;}
>> }
>> echo @c;
>>
>> achieves this nicely and shows that in many cases there is room for a
>> zoom of 130+ percent.
>>
>> Unfortunately, however, the script requires calling 'refresh' in order
>> to update
>> the screen coordinates of the model (.sx, .sy), which it seems is not
>> possible when running the script from the command line to generate a
>> static image (i.e. running the jmol application with -ionx and the
>> script contained in an spt file) - which is essential to my task,
>> which involves automated production of print content and html content
>> without user intervention.
>>
>> So at the moment I'm left with having to 'crop' the static images for
>> print use and reproducing the 'crop' effect in the html versions - not
>> a major problem, but it would have been nice to have just had the one
>> image with the load script embedded, etc., which could then be used
>> for print and html...
>>
>> Anyway, if anyone has any suggestions regarding running the jmol
>> application 'headless' with scripts that appear to require an 'event
>> loop' I'd be very grateful...
>>
> The 'point({x,y,z},true)' function to calculate the screen coordinates
> does work headless in Jmol 14.4.0. So you can determine the minima and
> maxima in a loop (startZoom set to '80' for testing):
>
>  scriptfile 'autozoom.spt' 
> startZoom = 80
> zoom {visible} @startZoom;
> rotate best;
> margin=15;
> c=0;
>
> function getScreenBoundary(atomSet) {
>if (atomSet.type == "bitset") {
>  var screenMinX = "";
>  var screenMaxX = "";
>  var screenMinY = "";
>  var screenMaxY = "";
>  for (var i from [1 atomSet.size]) {
>var screenXYZ = point(atomSet[i].xyz, true);
>if (screenMinX == "") {
>  screenMinX = screenXYZ.x;
>  screenMaxX = screenXYZ.x;
>  screenMinY = screenXYZ.y;
>  screenMaxY = screenXYZ.y;
>} else {
>  screenMinX = [screenMinX, screenXYZ.x].min;
>  screenMaxX = [screenMaxX, screenXYZ.x].max;
>  screenMinY = [screenMinY, screenXYZ.y].min;
>  screenMinY = [screenMinY, screenXYZ.y].min;
>}
>  }
>  return [screenMinX, screenMaxX, screenMinY, screenMaxY];
>}
> }
>
> sxInfo = getScreenBoundary({visible});
> while (sxInfo[2] < _width-margin && sxInfo[1] > margin && sxInfo[4] <
> _height-margin && sxInfo[3] > margin ) {
>zm=startZoom+c;
>zoom {visible} @zm;
>c=c+1;
>if (c>100) {break;}
>sxInfo = getScreenBoundary({visible});
> }
> print "c=" + c;
>
> -- Headless Jmol call 
> java -jar JmolData.jar -g800x800 -J 'load =1deh; script "autozoom.spt";
> write PNGJ 9 "autozoom-test.png";'
> --
>
> Regards,
> Rolf
>
>
> --
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140
> ___
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>



--
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app 

Re: [Jmol-users] Zoom calculation

2015-12-05 Thread Rolf Huehne
Am 05.12.15 um 13:49 schrieb si...@publcif.co.uk:
> Curiously this showed that the 'rotate best' needed to be done first
> (before the initial zoom) otherwise the coordinates did not reflect
> the rotated model.
> Perhaps the subsequent zoom forces a refresh...
>
It seemed to work at least for my example '1DEH' also the other way 
round. Otherwise it must have been cropped because the initial view is 
quadratic and after rotate best one side is about twice as large as the 
other.
Simon, can you name an example were it didn't work for you?

Regards,
Rolf

--
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Bug or feature? (anomalous _P)

2015-12-05 Thread Robert Hanson
What about just using:

load =5cl3
load append =5cle
compare {1.1} {2.1} atoms {*.P and conformation=1} rotate translate


On Sat, Dec 5, 2015 at 12:52 PM, Robert Hanson  wrote:

> Eric, you  have created an invalid PDB file, I think.
> ​
>



-- 
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
--
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Zoom calculation

2015-12-05 Thread Rolf Huehne
Am 05.12.15 um 19:49 schrieb Robert Hanson:
> I find that JmolData does not work as expected and requires a bug fix to
> get this work. Not sure why/how it is working for you both. I have had
> to fix JmolData.jar to make the following work:
>
> // script t3.spt
>
> function getScreenBoundary(atomSet)  {
>refresh
>return [atomSet.sx.all.min, atomSet.sx.all.max,
>atomSet.sy.all.min, atomSet.sy.all.max]
> }
>
Yes, this bug was the reason why I proposed the slower method: the 
'point' function did work in 'JmolData.jar' but not '.sx'.

Regards,
Rolf

--
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Zoom calculation

2015-12-05 Thread Robert Hanson
Just a few comments here:

Be aware that I just recently fixed a bug in point(,true) as well as
atom.sxyz. So use the latest SourceForge version of Jmol 14.4 if you
utilize those functions.

function getScreenBoundary could be simply the following, which executes
far faster:

function getScreenBoundary(atomSet)  {
   return [atomSet.sx.all.min, atomSet.sx.all.max, atomSet.sy.all.min,
atomSet.sy.all.max]
}

The reason your script is working without refresh is that the script checks
{visible}. This check triggers the setting of screen coordinates for an
atom. If that had been just a variable name, it would not have worked, and
you would need REFRESH.

I find that JmolData does not work as expected and requires a bug fix to
get this work. Not sure why/how it is working for you both. I have had to
fix JmolData.jar to make the following work:

// script t3.spt

function getScreenBoundary(atomSet)  {
  refresh
  return [atomSet.sx.all.min, atomSet.sx.all.max,
  atomSet.sy.all.min, atomSet.sy.all.max]
}

var margin=15;
var startZoom = 60
var atoms = {visible}

zoom @atoms @startZoom;
rotate best;

var sxInfo = getScreenBoundary(atoms);
print format("JSON",sxInfo)

var c=0;
while (sxInfo[2] < _width-margin
 && sxInfo[1] > margin
 && sxInfo[4] < _height-margin
 && sxInfo[3] > margin) {
   zm=startZoom+c;
   zoom @atoms @zm;
   if (++c>100) break;
   sxInfo = getScreenBoundary(atoms);
}
print format("JSON",sxInfo)
print "c=" + c;
print show("zoom")

//-- Headless Jmol call 
//java -jar JmolData.jar -p -g800x800 -J 'load =1deh; script "t3.spt"'
//--
// result:
//C:\jmol-dev\bobtest>jmoldata -g800x800 -p -J "load =1deh; script t3.spt"
//[ 123.0,380.0,171.0,329.0 ]
//[ 22.0,486.0,107.0,390.0 ]
//c=48
//zoom 107.0

I also note the oddity that the -p option allows "show" output for
JmolData.

Bob
--
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Zoom calculation

2015-12-05 Thread simon
It wasn't that your script didn't work, it was my modified script that  
didn't work (i.e. using the atom sites that correspond to the initial  
min max positions in subsequent calls):

rotate best; # moved here
startZoom = 100;
zoom {visible} @startZoom;
# rotate best; # if done here the initial coords dont seem to be updated
margin=15;
c=0;

function getScreenBoundary(atomSet) {
   if (atomSet.type == "bitset") {
 var screenMinX = "";
 var screenMaxX = "";
 var screenMinY = "";
 var screenMaxY = "";
 var minXsite="";
 var maxXsite="";
 var minYsite="";
 var maxYsite="";
 for (var i from [1 atomSet.size]) {
   var screenXYZ = point(atomSet[i].xyz, true);
   if (screenMinX == "") {
 screenMinX = screenXYZ.x;
 screenMaxX = screenXYZ.x;
 screenMinY = screenXYZ.y;
 screenMaxY = screenXYZ.y;
minXsite=atomSet[i];
 maxXsite=atomSet[i];
 minYsite=atomSet[i];
 maxYsite=atomSet[i];
   } else {
if (screenXYZ.xscreenMaxX) {
  screenMaxX=screenXYZ.x;
  maxXsite=atomSet[i];
}
if (screenXYZ.yscreenMaxY) {
  screenMaxY=screenXYZ.y;
  maxYsite=atomSet[i];
}

   }
 }
 return [screenMinX, screenMaxX, screenMinY, screenMaxY, minXsite,  
maxXsite, minYsite, maxYsite];
   }
}

sxInfo = getScreenBoundary({visible});

selectionHalos ON; # just to see whats selected

select @{sxInfo[5]}, @{sxInfo[6]}, @{sxInfo[7]}, @{sxInfo[8]};

while (sxInfo[2] < _width-margin && sxInfo[1] > margin && sxInfo[4] <
_height-margin && sxInfo[3] > margin ) {
   zm=startZoom+c;
   zoom {visible} @zm;
   c=c+1;
   if (c>100) {break;}
   sxInfo = getScreenBoundary({selected});
}
print "c=" + c;
# extra translation to center the model horizontally (yuk)
rm=_width-sxInfo[2];
lm=sxInfo[1];
t=(rm-lm)/2;tp=t/_width*100;
translate x @tp;
print "c=" + c;

I was testing using the console and e.g.
http://publcif.iucr.org/cifmoldb/gui/cifjmol.php?jsmol=y=av1222

If I swap the position of 'rotate best' the selected atoms no longer  
appear at the min max positions (at least in my browser)...

Cheers

Simon


Quoting Rolf Huehne :

> Am 05.12.15 um 13:49 schrieb si...@publcif.co.uk:
>> Curiously this showed that the 'rotate best' needed to be done first
>> (before the initial zoom) otherwise the coordinates did not reflect
>> the rotated model.
>> Perhaps the subsequent zoom forces a refresh...
>>
> It seemed to work at least for my example '1DEH' also the other way
> round. Otherwise it must have been cropped because the initial view is
> quadratic and after rotate best one side is about twice as large as the
> other.
> Simon, can you name an example were it didn't work for you?
>
> Regards,
> Rolf
>
> --
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140
> ___
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>



--
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


[Jmol-users] Testing subscription - please ignore

2015-12-05 Thread S Westrip
 --
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Bug or feature? (anomalous _P)

2015-12-05 Thread Robert Hanson
Eric, you  have created an invalid PDB file, I think.
​
--
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


[Jmol-users] Bug or feature? (anomalous _P)

2015-12-05 Thread Eric Martz

Dear Bob,

While preparing a morph from 5cl3 to 5cle, I re-ordered the hetero atoms 
in 5cle so as to be in the same order as the homologous atoms in 5cl3. 
This separated [3DR]6:B.P from the other 3DR atoms. The result is that 
this phosphorus, while it remains hetero, is deemed by Jmol to be 
neither ligand nor solvent nor DNA. I can live with this, but I am 
reporting it in case it is a bug.


Tested with Jmol application dated November 18, 2015.

Example files:
http://bioinformatics.org/molvis/tmp/5cle-ligand.pdb
http://bioinformatics.org/molvis/tmp/reordered-ligand.pdb

Contents of example files:

ORIGINAL order from 5cle ([3DR]6:B.P is ligand)

HETATM1  O5' 3DR B   6  40.400  -4.134  11.144  1.00 
16.98   O
*HETATM2  P   3DR B   6  40.429  -5.572  10.443 1.00 
17.42   P *
HETATM3  OP1 3DR B   6  41.434  -5.662   9.357 1.00 
18.41   O
HETATM4  OP2 3DR B   6  40.671  -6.600  11.482 1.00 
19.96   O
HETATM5  C2' 3DR B   6  40.069  -0.707  13.038 1.00 
25.11   C
HETATM6  C5' 3DR B   6  40.150  -3.117  10.183 1.00 
20.01   C
HETATM7  C4' 3DR B   6  39.863  -1.817  10.934 1.00 
17.65   C
HETATM8  O4' 3DR B   6  38.569  -1.913  11.598 1.00 
19.68   O
HETATM9  C1' 3DR B   6  38.611  -1.154  12.821 1.00 
20.01   C
HETATM   10  C3' 3DR B   6  40.891  -1.550  12.055 1.00 
23.32   C
HETATM   11  O3' 3DR B   6  41.949  -0.747  11.542 1.00 
25.20   O
HETATM   12  N9  ADK B 101  38.704  -4.026  15.100 1.00 
24.10   N
HETATM   13  C4  ADK B 101  38.277  -4.217  16.354 1.00 
19.29   C
HETATM   14  N3  ADK B 101  37.775  -3.385  17.350 1.00 
35.42   N
HETATM   15  C2  ADK B 101  37.434  -3.931  18.532 1.00 
28.39   C
HETATM   16  N1  ADK B 101  37.558  -5.221  18.755 1.00 
24.56   N
HETATM   17  C6  ADK B 101  38.031  -6.073  17.825 1.00 
29.43   C
HETATM   18  N6  ADK B 101  38.164  -7.496  18.102 1.00 
23.29   N
HETATM   19  C5  ADK B 101  38.405  -5.601  16.602 1.00 
19.32   C
HETATM   20  N7  ADK B 101  38.896  -6.144  15.497 1.00 
17.81   N
HETATM   21  C8  ADK B 101  39.069  -5.183  14.606 1.00 
19.82   C
HETATM   22  C3A ADK B 101  37.649  -2.030  17.097 1.00 
31.68   C


REORDERED (coordinates differ because this was aligned with 5cl3; 
[3DR]6:B.P is NOT ligand):


*HETATM 2424  P   3DR B   6  59.344  -7.302  54.550  1.00 
17.42   P*
HETATM 2438  N1  ADK B 101  56.456  -6.944  62.856  1.00 
24.56   N
HETATM 2437  C2  ADK B 101  56.354  -5.651  62.639  1.00 
28.39   C
HETATM 2436  N3  ADK B 101  56.707  -5.105  61.460  1.00 
35.42   N
HETATM 2435  C4  ADK B 101  57.198  -5.940  60.462  1.00 
19.29   C
HETATM 2441  C5  ADK B 101  57.302  -7.327  60.703  1.00 
19.32   C
HETATM 2439  C6  ADK B 101  56.917  -7.799  61.923  1.00 
29.43   C
HETATM 2440  N6  ADK B 101  57.026  -9.225  62.193  1.00 
23.29   N
HETATM 2442  N7  ADK B 101  57.788  -7.873  59.597  1.00 
17.81   N
HETATM 2443  C8  ADK B 101  57.979  -6.911  58.711  1.00 
19.82   C
HETATM 2434  N9  ADK B 101  57.632  -5.750  59.210  1.00 
24.10   N
HETATM 2431  C1' 3DR B   6  57.593  -2.866  56.945  1.00 
20.01   C
HETATM 2426  OP2 3DR B   6  59.566  -8.339  55.585  1.00 
19.96   O
HETATM 2427  C2' 3DR B   6  59.058  -2.445  57.168  1.00 
25.11   C
HETATM 2425  OP1 3DR B   6  60.351  -7.404  53.467  1.00 
18.41   O
HETATM 2432  C3' 3DR B   6  59.869  -3.296  56.183  1.00 
23.32   C
HETATM 2433  O3' 3DR B   6  60.941  -2.509  55.677  1.00 
25.20   O
HETATM 2444  C3A ADK B 101  56.605  -3.747  61.214  1.00 
31.68   C
HETATM 2429  C4' 3DR B   6  58.840  -3.541  55.058  1.00 
17.65   C
HETATM 2430  O4' 3DR B   6  57.542  -3.618  55.718  1.00 
19.68   O
HETATM 2428  C5' 3DR B   6  59.107  -4.842  54.302  1.00 
20.01   C
HETATM 2423  O5' 3DR B   6  59.337  -5.867  55.258  1.00 
16.98   O



-Eric
--
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] Zoom calculation

2015-12-05 Thread Robert Hanson
should all be working with the latest at SourceForge (14.4) now.

On Sat, Dec 5, 2015 at 1:27 PM, Rolf Huehne  wrote:

> Am 05.12.15 um 19:49 schrieb Robert Hanson:
> > I find that JmolData does not work as expected and requires a bug fix to
> > get this work. Not sure why/how it is working for you both. I have had
> > to fix JmolData.jar to make the following work:
> >
> > // script t3.spt
> >
> > function getScreenBoundary(atomSet)  {
> >refresh
> >return [atomSet.sx.all.min, atomSet.sx.all.max,
> >atomSet.sy.all.min, atomSet.sy.all.max]
> > }
> >
> Yes, this bug was the reason why I proposed the slower method: the
> 'point' function did work in 'JmolData.jar' but not '.sx'.
>
> Regards,
> Rolf
>
>
> --
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple
> OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140
> ___
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>



-- 
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
--
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users