Re: [Jmol-users] Color maps for bonds

2017-01-19 Thread Robert Hanson
Yes, Max, there is a very simple way to do this. If you have a color scheme
in mind, the color() function is what you want:




*x = color(schemeName, min, max, value)*

for example:

$ x = color("rgb",0,2,1.5)
$ print x

{0.0 255.0 255.0}​

bmin = {*}.bonds.length.min
bmax = {*}.bonds.length.max

Now you loop through the bonds, get the value of their length, and use that
to deliver a color:

load $caffeine
bmin = {*}.bonds.length.min
bmax = {*}.bonds.length.max
for (var i = {*}.bonds.count; --i >= 0;) {
  var x = eval("[{"+i + "}]")
  select @x
 color bonds @{color("rgb",bmin, bmax, x.length)}
}
--
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


Re: [Jmol-users] Color maps for bonds

2017-01-19 Thread Rolf Huehne
Am 19.01.17 um 05:26 schrieb Max Pinheiro Jr:
> Hi Bob,
>
> The problem that still persist is how to use the values bond lengths to
> assign the colors for each bond. I included a new variable to get the
> bond length inside the for loop: y=x.bonds.length. However, I think the
> variable colors[ ] just accept integer values, right? So, one
> possibility that I check is to convert the bond length into an integer
> using "% 0". But in most of the cases it is necessary to rescale the
> bond length to get more decimal places before to convert into an
> integer. When I tried to run the script with the values of bond length
> times 100 and rounded, this variable used as argument to the colors fall
> out of the range. Do you have any other idea of how to use the bond
> length  as an argument for the colors()?
Max, you could use the following formula to normalize a bond length 
value to the color index range before you convert the bond length value 
to an integer value, e.g.:

minColorIndex=1;
maxColorIndex=32;
minBondlength=0.1;
maxBondLength=1.5;

normalizedBondLength = (bondLength - minBondLength) * maxColorIndex / 
(maxBondLength - minBondLength) + minColorIndex;

If you would like to get directly comparable results between different 
atom sets you should use the same 'minBondLength' and 'maxBondLength' 
values for each atom set and the same 'minColorIndex' and 
'maxColorIndex' value. If you would like to get the maximum color range 
for each atom set instead (loosing comparability) you should determine 
the actual minimum and maximum bond length individually for each atom set.

Regards,
Rolf

--
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


Re: [Jmol-users] Color maps for bonds

2017-01-19 Thread Angel Herráez
Hi Max

Have you explored the "connect" command?

>From your last description, I think that might do what you want.
It's easy to select atom pairs by distance, and then you could "reconnect" 
them and apply color and thickness of bond

https://chemapps.stolaf.edu/jmol/docs/#connect

·
 Dr. Angel Herráez
 Biochemistry and Molecular Biology,
 Dept. of Systems Biology, University of Alcalá
 E-28871 Alcalá de Henares  (Madrid), Spain


--
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