Re: [Jmol-users] Color maps for bonds

2017-01-21 Thread Max Pinheiro Jr
Hi Bob,

Thank you very much for your answer! This last script solved my problem. It
is working pretty well. The function color("rgb",bmin, bmax, x.length) was
the tricky. Thanks also for all other previous suggestions!

All the best,

Max Pinheiro Jr

2017-01-19 16:04 GMT-02:00 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
>
>
--
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 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


Re: [Jmol-users] Color maps for bonds

2017-01-18 Thread 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()? The
script updated with the information of bond length is the following:

load $caffeine
var colors = color("rgb").colors // just a nice list of colors -- you can
make your own list
x=color("rwb", -3, 3)
for (var i = {*}.bonds.count; --i >= 0;) {
  var x = eval("[{"+i + "}]") // note that this bond-set syntax is 0-based.
You  must use eval() to create it.
  *y = ((x.bonds.length)*10) % 0* // convert the bond length into an
integer value with two digits
  print " " + x + " " + y + " " + @{colors[y]} // arrays are 1-based
  select @x
 color bonds @{colors[y]}
}

I will appreciate any help on this issue.

Thanks!

2017-01-18 22:13 GMT-05:00 Max Pinheiro Jr :

> As I said, the version of jmol I am running is the 14.6.3 of 2016-09-18. I
> ran your script again using the cafeine molecule loaded directly from jmol
> (File -> Get MOL), and, in this case, all bonds are colored as expected.
> However, the same script has no effect when I run it over my xyz file. I
> see that the jmol recognize the single and double bonds when loading the
> cafeine structure but in my case this not happen because I am loading a xyz
> file, I think. Is there some additional step missing in the case of xyz
> files?
>
> 2017-01-18 13:33 GMT-05:00 Robert Hanson :
>
>> What version of Jmol are you running? Should be no problem running that
>> exact script. Just did it again now.
>>
>>
>>
>>
>> On Wed, Jan 18, 2017 at 11:44 AM, Max Pinheiro Jr 
>> wrote:
>>
>>> Hi Bob,
>>>
>>> Thank for the tips. I tried to run your script right now, but something
>>> seems to be wrong with the color assignment. Jmol is returning the
>>> following error message:
>>>
>>> script ERROR: invalid argument
>>> 
>>>  color bonds ""
>>> 
>>>  for ( var i = { all } . bonds . count ; -- i >= 0 ; )
>>>
>>> I have tried the same script with a fixed color (red, for example) and
>>> the script ran normally. I checked the manual and I found a reference to
>>> the function "x=y.color" instead "something.colors", but I tested this
>>> former option and it didn't work anyway. I also tried to assign a color
>>> from the variable "var colors = color("rgb").colors" for a single bond
>>> selected manually with "select bond ({2})" but the "color bonds" command do
>>> not accept the argument for the color ("@{colors[5]}", for example). Do you
>>> think that this problem could be related to the version of jmol? I am using
>>> the version 14.6.3.
>>>
>>> Besides this problem, I still could not see (in your script) how the
>>> colors can be assigned based on the length or a difference in length as I
>>> have mentioned in the previous message. Supposing that the variable
>>> color("rgb").colors works, can it receive no integer numbers as argument?
>>>
>>> 2017-01-18 11:18 GMT-05:00 Robert Hanson :
>>>
 ps - I forgot to mention that this bond set syntax [{...}] makes it
 unnecessary  to use  BOND in the select command:

 select [{2}]

 selects the third bond in the model.



 On Tue, Jan 17, 2017 at 7:32 PM, Robert Hanson 
 wrote:

> If you know the  ordering in the file, you can select them using the
> select BOND option, but that requires "atom/bond set" syntax:
>
> select bond ({0})   # first bond
> select bond ({1})   # second bond
>
> etc.
>
> Now, the trick here is that that syntax doesn't allow for variables.
> For example, you cannot say:
>
> select bond ({ i })
>
> HOWEVER, you can get around this by using a variable and setting the
> value using an *bond set*, using a which  does accept variables:
>
> load $caffeine
> var colors = color("rgb").colors // just a nice list of colors -- you
> can make your own list
> for (var i = {*}.bonds.count; --i >= 0;) {
>   var x = eval("[{"+i + "}]") // note that this bond-set syntax is
> 0-based. You  must use eval() to create it.
> print " " + x + " " + @{colors[i + 1]} // arrays are 1-based
>   select @x
>  color bonds @{colors[i + 1]}
> }
>
> Bob
>
> On Tue, Jan 17, 2017 at 11:38 AM, Angel Herráez 

Re: [Jmol-users] Color maps for bonds

2017-01-18 Thread Max Pinheiro Jr
As I said, the version of jmol I am running is the 14.6.3 of 2016-09-18. I
ran your script again using the cafeine molecule loaded directly from jmol
(File -> Get MOL), and, in this case, all bonds are colored as expected.
However, the same script has no effect when I run it over my xyz file. I
see that the jmol recognize the single and double bonds when loading the
cafeine structure but in my case this not happen because I am loading a xyz
file, I think. Is there some additional step missing in the case of xyz
files?

2017-01-18 13:33 GMT-05:00 Robert Hanson :

> What version of Jmol are you running? Should be no problem running that
> exact script. Just did it again now.
>
>
>
>
> On Wed, Jan 18, 2017 at 11:44 AM, Max Pinheiro Jr 
> wrote:
>
>> Hi Bob,
>>
>> Thank for the tips. I tried to run your script right now, but something
>> seems to be wrong with the color assignment. Jmol is returning the
>> following error message:
>>
>> script ERROR: invalid argument
>> 
>>  color bonds ""
>> 
>>  for ( var i = { all } . bonds . count ; -- i >= 0 ; )
>>
>> I have tried the same script with a fixed color (red, for example) and
>> the script ran normally. I checked the manual and I found a reference to
>> the function "x=y.color" instead "something.colors", but I tested this
>> former option and it didn't work anyway. I also tried to assign a color
>> from the variable "var colors = color("rgb").colors" for a single bond
>> selected manually with "select bond ({2})" but the "color bonds" command do
>> not accept the argument for the color ("@{colors[5]}", for example). Do you
>> think that this problem could be related to the version of jmol? I am using
>> the version 14.6.3.
>>
>> Besides this problem, I still could not see (in your script) how the
>> colors can be assigned based on the length or a difference in length as I
>> have mentioned in the previous message. Supposing that the variable
>> color("rgb").colors works, can it receive no integer numbers as argument?
>>
>> 2017-01-18 11:18 GMT-05:00 Robert Hanson :
>>
>>> ps - I forgot to mention that this bond set syntax [{...}] makes it
>>> unnecessary  to use  BOND in the select command:
>>>
>>> select [{2}]
>>>
>>> selects the third bond in the model.
>>>
>>>
>>>
>>> On Tue, Jan 17, 2017 at 7:32 PM, Robert Hanson 
>>> wrote:
>>>
 If you know the  ordering in the file, you can select them using the
 select BOND option, but that requires "atom/bond set" syntax:

 select bond ({0})   # first bond
 select bond ({1})   # second bond

 etc.

 Now, the trick here is that that syntax doesn't allow for variables.
 For example, you cannot say:

 select bond ({ i })

 HOWEVER, you can get around this by using a variable and setting the
 value using an *bond set*, using a which  does accept variables:

 load $caffeine
 var colors = color("rgb").colors // just a nice list of colors -- you
 can make your own list
 for (var i = {*}.bonds.count; --i >= 0;) {
   var x = eval("[{"+i + "}]") // note that this bond-set syntax is
 0-based. You  must use eval() to create it.
 print " " + x + " " + @{colors[i + 1]} // arrays are 1-based
   select @x
  color bonds @{colors[i + 1]}
 }

 Bob

 On Tue, Jan 17, 2017 at 11:38 AM, Angel Herráez 
 wrote:

> Hi Max
>
> Two issues here. One is the way to achive this in Jmol scripting. The
> other is
> to specify what you are expecting to achieve, i.e. which is your
> criteria of
> bond ordering + coloring.
>
> Atoms are indexed as the file is read, and so there is no issue: they
> receive a
> sequential number and you can refer to it. They also have many
> properties
> associated to each atom.
>
> Bonds, on the one hand, have no properties attached to them except
> thickness and color. On the other hand, it is not so easy to define
> their
> ordering and indexing. Among other things, each bond "belongs" to 2
> atoms
> and each atom "has" several bonds, so what should their index/order be?
> (We recently experienced a case: the same protein, when read from a pdb
> file and when read from a cif file, has the same atom indexing in Jmol
> but
> different bond indexing)
>
> I believe that yes, most probably you can iterate or loop over the
> bonds
> collection and assign a color to each bond, read from your data file.
> But still
> the question is in which order those bonds will come, every time you
> have a
> new file.
> What are you expecting in this regard when you define your color-data
> file?
>
>
> > Good question. Since in the case of coloring atoms by the partial
> charge I don't need to specify
> > the atoms, i.e, I think there 

Re: [Jmol-users] Color maps for bonds

2017-01-18 Thread Robert Hanson
What version of Jmol are you running? Should be no problem running that
exact script. Just did it again now.




On Wed, Jan 18, 2017 at 11:44 AM, Max Pinheiro Jr  wrote:

> Hi Bob,
>
> Thank for the tips. I tried to run your script right now, but something
> seems to be wrong with the color assignment. Jmol is returning the
> following error message:
>
> script ERROR: invalid argument
> 
>  color bonds ""
> 
>  for ( var i = { all } . bonds . count ; -- i >= 0 ; )
>
> I have tried the same script with a fixed color (red, for example) and the
> script ran normally. I checked the manual and I found a reference to the
> function "x=y.color" instead "something.colors", but I tested this former
> option and it didn't work anyway. I also tried to assign a color from the
> variable "var colors = color("rgb").colors" for a single bond selected
> manually with "select bond ({2})" but the "color bonds" command do not
> accept the argument for the color ("@{colors[5]}", for example). Do you
> think that this problem could be related to the version of jmol? I am using
> the version 14.6.3.
>
> Besides this problem, I still could not see (in your script) how the
> colors can be assigned based on the length or a difference in length as I
> have mentioned in the previous message. Supposing that the variable
> color("rgb").colors works, can it receive no integer numbers as argument?
>
> 2017-01-18 11:18 GMT-05:00 Robert Hanson :
>
>> ps - I forgot to mention that this bond set syntax [{...}] makes it
>> unnecessary  to use  BOND in the select command:
>>
>> select [{2}]
>>
>> selects the third bond in the model.
>>
>>
>>
>> On Tue, Jan 17, 2017 at 7:32 PM, Robert Hanson 
>> wrote:
>>
>>> If you know the  ordering in the file, you can select them using the
>>> select BOND option, but that requires "atom/bond set" syntax:
>>>
>>> select bond ({0})   # first bond
>>> select bond ({1})   # second bond
>>>
>>> etc.
>>>
>>> Now, the trick here is that that syntax doesn't allow for variables. For
>>> example, you cannot say:
>>>
>>> select bond ({ i })
>>>
>>> HOWEVER, you can get around this by using a variable and setting the
>>> value using an *bond set*, using a which  does accept variables:
>>>
>>> load $caffeine
>>> var colors = color("rgb").colors // just a nice list of colors -- you
>>> can make your own list
>>> for (var i = {*}.bonds.count; --i >= 0;) {
>>>   var x = eval("[{"+i + "}]") // note that this bond-set syntax is
>>> 0-based. You  must use eval() to create it.
>>> print " " + x + " " + @{colors[i + 1]} // arrays are 1-based
>>>   select @x
>>>  color bonds @{colors[i + 1]}
>>> }
>>>
>>> Bob
>>>
>>> On Tue, Jan 17, 2017 at 11:38 AM, Angel Herráez 
>>> wrote:
>>>
 Hi Max

 Two issues here. One is the way to achive this in Jmol scripting. The
 other is
 to specify what you are expecting to achieve, i.e. which is your
 criteria of
 bond ordering + coloring.

 Atoms are indexed as the file is read, and so there is no issue: they
 receive a
 sequential number and you can refer to it. They also have many
 properties
 associated to each atom.

 Bonds, on the one hand, have no properties attached to them except
 thickness and color. On the other hand, it is not so easy to define
 their
 ordering and indexing. Among other things, each bond "belongs" to 2
 atoms
 and each atom "has" several bonds, so what should their index/order be?
 (We recently experienced a case: the same protein, when read from a pdb
 file and when read from a cif file, has the same atom indexing in Jmol
 but
 different bond indexing)

 I believe that yes, most probably you can iterate or loop over the bonds
 collection and assign a color to each bond, read from your data file.
 But still
 the question is in which order those bonds will come, every time you
 have a
 new file.
 What are you expecting in this regard when you define your color-data
 file?


 > Good question. Since in the case of coloring atoms by the partial
 charge I don't need to specify
 > the atoms, i.e, I think there is a direct correspondence of each line
 of the file for each atom in the
 > respective ordering,

 YES

 > I thought that in the case of bonds we would have the same kind of
 > correspondence.

 NOT THE SAME (see above)


 > I have checked in the manual that specific bonds can be selected by
 the command "select[{i}]" or
 > a set of bonds could be attributed to a variable by "x = {atomno <
 30}.bonds"

 Right, but that x will be a collection of bonds -- in which order, is
 difficult to
 anticipate.


 > and I could change
 > the color of the selected bonds to red, for example.

 That would mean all bonds 

Re: [Jmol-users] Color maps for bonds

2017-01-18 Thread Max Pinheiro Jr
Hi Bob,

Thank for the tips. I tried to run your script right now, but something
seems to be wrong with the color assignment. Jmol is returning the
following error message:

script ERROR: invalid argument

 color bonds ""

 for ( var i = { all } . bonds . count ; -- i >= 0 ; )

I have tried the same script with a fixed color (red, for example) and the
script ran normally. I checked the manual and I found a reference to the
function "x=y.color" instead "something.colors", but I tested this former
option and it didn't work anyway. I also tried to assign a color from the
variable "var colors = color("rgb").colors" for a single bond selected
manually with "select bond ({2})" but the "color bonds" command do not
accept the argument for the color ("@{colors[5]}", for example). Do you
think that this problem could be related to the version of jmol? I am using
the version 14.6.3.

Besides this problem, I still could not see (in your script) how the colors
can be assigned based on the length or a difference in length as I have
mentioned in the previous message. Supposing that the variable
color("rgb").colors works, can it receive no integer numbers as argument?

2017-01-18 11:18 GMT-05:00 Robert Hanson :

> ps - I forgot to mention that this bond set syntax [{...}] makes it
> unnecessary  to use  BOND in the select command:
>
> select [{2}]
>
> selects the third bond in the model.
>
>
>
> On Tue, Jan 17, 2017 at 7:32 PM, Robert Hanson  wrote:
>
>> If you know the  ordering in the file, you can select them using the
>> select BOND option, but that requires "atom/bond set" syntax:
>>
>> select bond ({0})   # first bond
>> select bond ({1})   # second bond
>>
>> etc.
>>
>> Now, the trick here is that that syntax doesn't allow for variables. For
>> example, you cannot say:
>>
>> select bond ({ i })
>>
>> HOWEVER, you can get around this by using a variable and setting the
>> value using an *bond set*, using a which  does accept variables:
>>
>> load $caffeine
>> var colors = color("rgb").colors // just a nice list of colors -- you can
>> make your own list
>> for (var i = {*}.bonds.count; --i >= 0;) {
>>   var x = eval("[{"+i + "}]") // note that this bond-set syntax is
>> 0-based. You  must use eval() to create it.
>> print " " + x + " " + @{colors[i + 1]} // arrays are 1-based
>>   select @x
>>  color bonds @{colors[i + 1]}
>> }
>>
>> Bob
>>
>> On Tue, Jan 17, 2017 at 11:38 AM, Angel Herráez 
>> wrote:
>>
>>> Hi Max
>>>
>>> Two issues here. One is the way to achive this in Jmol scripting. The
>>> other is
>>> to specify what you are expecting to achieve, i.e. which is your
>>> criteria of
>>> bond ordering + coloring.
>>>
>>> Atoms are indexed as the file is read, and so there is no issue: they
>>> receive a
>>> sequential number and you can refer to it. They also have many properties
>>> associated to each atom.
>>>
>>> Bonds, on the one hand, have no properties attached to them except
>>> thickness and color. On the other hand, it is not so easy to define their
>>> ordering and indexing. Among other things, each bond "belongs" to 2 atoms
>>> and each atom "has" several bonds, so what should their index/order be?
>>> (We recently experienced a case: the same protein, when read from a pdb
>>> file and when read from a cif file, has the same atom indexing in Jmol
>>> but
>>> different bond indexing)
>>>
>>> I believe that yes, most probably you can iterate or loop over the bonds
>>> collection and assign a color to each bond, read from your data file.
>>> But still
>>> the question is in which order those bonds will come, every time you
>>> have a
>>> new file.
>>> What are you expecting in this regard when you define your color-data
>>> file?
>>>
>>>
>>> > Good question. Since in the case of coloring atoms by the partial
>>> charge I don't need to specify
>>> > the atoms, i.e, I think there is a direct correspondence of each line
>>> of the file for each atom in the
>>> > respective ordering,
>>>
>>> YES
>>>
>>> > I thought that in the case of bonds we would have the same kind of
>>> > correspondence.
>>>
>>> NOT THE SAME (see above)
>>>
>>>
>>> > I have checked in the manual that specific bonds can be selected by
>>> the command "select[{i}]" or
>>> > a set of bonds could be attributed to a variable by "x = {atomno <
>>> 30}.bonds"
>>>
>>> Right, but that x will be a collection of bonds -- in which order, is
>>> difficult to
>>> anticipate.
>>>
>>>
>>> > and I could change
>>> > the color of the selected bonds to red, for example.
>>>
>>> That would mean all bonds attached to that atom get the same red color.
>>> But each bond will also be attached to another atom, then which is the
>>> last
>>> color applied to it?
>>>
>>> So, in summary, I believe some of these "philosophical" or "logical"
>>> questions
>>> need to be answered before trying to find Jmol commands to do what you
>>> want.
>>>
>>>
>>> 

Re: [Jmol-users] Color maps for bonds

2017-01-18 Thread Robert Hanson
ps - I forgot to mention that this bond set syntax [{...}] makes it
unnecessary  to use  BOND in the select command:

select [{2}]

selects the third bond in the model.



On Tue, Jan 17, 2017 at 7:32 PM, Robert Hanson  wrote:

> If you know the  ordering in the file, you can select them using the
> select BOND option, but that requires "atom/bond set" syntax:
>
> select bond ({0})   # first bond
> select bond ({1})   # second bond
>
> etc.
>
> Now, the trick here is that that syntax doesn't allow for variables. For
> example, you cannot say:
>
> select bond ({ i })
>
> HOWEVER, you can get around this by using a variable and setting the value
> using an *bond set*, using a which  does accept variables:
>
> load $caffeine
> var colors = color("rgb").colors // just a nice list of colors -- you can
> make your own list
> for (var i = {*}.bonds.count; --i >= 0;) {
>   var x = eval("[{"+i + "}]") // note that this bond-set syntax is
> 0-based. You  must use eval() to create it.
> print " " + x + " " + @{colors[i + 1]} // arrays are 1-based
>   select @x
>  color bonds @{colors[i + 1]}
> }
>
> Bob
>
> On Tue, Jan 17, 2017 at 11:38 AM, Angel Herráez 
> wrote:
>
>> Hi Max
>>
>> Two issues here. One is the way to achive this in Jmol scripting. The
>> other is
>> to specify what you are expecting to achieve, i.e. which is your criteria
>> of
>> bond ordering + coloring.
>>
>> Atoms are indexed as the file is read, and so there is no issue: they
>> receive a
>> sequential number and you can refer to it. They also have many properties
>> associated to each atom.
>>
>> Bonds, on the one hand, have no properties attached to them except
>> thickness and color. On the other hand, it is not so easy to define their
>> ordering and indexing. Among other things, each bond "belongs" to 2 atoms
>> and each atom "has" several bonds, so what should their index/order be?
>> (We recently experienced a case: the same protein, when read from a pdb
>> file and when read from a cif file, has the same atom indexing in Jmol but
>> different bond indexing)
>>
>> I believe that yes, most probably you can iterate or loop over the bonds
>> collection and assign a color to each bond, read from your data file. But
>> still
>> the question is in which order those bonds will come, every time you have
>> a
>> new file.
>> What are you expecting in this regard when you define your color-data
>> file?
>>
>>
>> > Good question. Since in the case of coloring atoms by the partial
>> charge I don't need to specify
>> > the atoms, i.e, I think there is a direct correspondence of each line
>> of the file for each atom in the
>> > respective ordering,
>>
>> YES
>>
>> > I thought that in the case of bonds we would have the same kind of
>> > correspondence.
>>
>> NOT THE SAME (see above)
>>
>>
>> > I have checked in the manual that specific bonds can be selected by the
>> command "select[{i}]" or
>> > a set of bonds could be attributed to a variable by "x = {atomno <
>> 30}.bonds"
>>
>> Right, but that x will be a collection of bonds -- in which order, is
>> difficult to
>> anticipate.
>>
>>
>> > and I could change
>> > the color of the selected bonds to red, for example.
>>
>> That would mean all bonds attached to that atom get the same red color.
>> But each bond will also be attached to another atom, then which is the
>> last
>> color applied to it?
>>
>> So, in summary, I believe some of these "philosophical" or "logical"
>> questions
>> need to be answered before trying to find Jmol commands to do what you
>> want.
>>
>>
>> 
>> --
>> 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
>>
>
>
>
> --
> Robert M. Hanson
> Larson-Anderson Professor 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
>
>


-- 
Robert M. Hanson
Larson-Anderson Professor 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
--
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-17 Thread Robert Hanson
If you know the  ordering in the file, you can select them using the
select BOND option, but that requires "atom/bond set" syntax:

select bond ({0})   # first bond
select bond ({1})   # second bond

etc.

Now, the trick here is that that syntax doesn't allow for variables. For
example, you cannot say:

select bond ({ i })

HOWEVER, you can get around this by using a variable and setting the value
using an *bond set*, using a which  does accept variables:

load $caffeine
var colors = color("rgb").colors // just a nice list of colors -- you can
make your own list
for (var i = {*}.bonds.count; --i >= 0;) {
  var x = eval("[{"+i + "}]") // note that this bond-set syntax is 0-based.
You  must use eval() to create it.
print " " + x + " " + @{colors[i + 1]} // arrays are 1-based
  select @x
 color bonds @{colors[i + 1]}
}

Bob

On Tue, Jan 17, 2017 at 11:38 AM, Angel Herráez 
wrote:

> Hi Max
>
> Two issues here. One is the way to achive this in Jmol scripting. The
> other is
> to specify what you are expecting to achieve, i.e. which is your criteria
> of
> bond ordering + coloring.
>
> Atoms are indexed as the file is read, and so there is no issue: they
> receive a
> sequential number and you can refer to it. They also have many properties
> associated to each atom.
>
> Bonds, on the one hand, have no properties attached to them except
> thickness and color. On the other hand, it is not so easy to define their
> ordering and indexing. Among other things, each bond "belongs" to 2 atoms
> and each atom "has" several bonds, so what should their index/order be?
> (We recently experienced a case: the same protein, when read from a pdb
> file and when read from a cif file, has the same atom indexing in Jmol but
> different bond indexing)
>
> I believe that yes, most probably you can iterate or loop over the bonds
> collection and assign a color to each bond, read from your data file. But
> still
> the question is in which order those bonds will come, every time you have a
> new file.
> What are you expecting in this regard when you define your color-data file?
>
>
> > Good question. Since in the case of coloring atoms by the partial charge
> I don't need to specify
> > the atoms, i.e, I think there is a direct correspondence of each line of
> the file for each atom in the
> > respective ordering,
>
> YES
>
> > I thought that in the case of bonds we would have the same kind of
> > correspondence.
>
> NOT THE SAME (see above)
>
>
> > I have checked in the manual that specific bonds can be selected by the
> command "select[{i}]" or
> > a set of bonds could be attributed to a variable by "x = {atomno <
> 30}.bonds"
>
> Right, but that x will be a collection of bonds -- in which order, is
> difficult to
> anticipate.
>
>
> > and I could change
> > the color of the selected bonds to red, for example.
>
> That would mean all bonds attached to that atom get the same red color.
> But each bond will also be attached to another atom, then which is the last
> color applied to it?
>
> So, in summary, I believe some of these "philosophical" or "logical"
> questions
> need to be answered before trying to find Jmol commands to do what you
> want.
>
>
> 
> --
> 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
>



-- 
Robert M. Hanson
Larson-Anderson Professor 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
--
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-17 Thread Angel Herráez
Hi Max

Two issues here. One is the way to achive this in Jmol scripting. The other is 
to specify what you are expecting to achieve, i.e. which is your criteria of 
bond ordering + coloring.

Atoms are indexed as the file is read, and so there is no issue: they receive a 
sequential number and you can refer to it. They also have many properties 
associated to each atom.

Bonds, on the one hand, have no properties attached to them except 
thickness and color. On the other hand, it is not so easy to define their 
ordering and indexing. Among other things, each bond "belongs" to 2 atoms 
and each atom "has" several bonds, so what should their index/order be?
(We recently experienced a case: the same protein, when read from a pdb 
file and when read from a cif file, has the same atom indexing in Jmol but 
different bond indexing)

I believe that yes, most probably you can iterate or loop over the bonds 
collection and assign a color to each bond, read from your data file. But still 
the question is in which order those bonds will come, every time you have a 
new file.
What are you expecting in this regard when you define your color-data file?


> Good question. Since in the case of coloring atoms by the partial charge I 
> don't need to specify 
> the atoms, i.e, I think there is a direct correspondence of each line of the 
> file for each atom in the 
> respective ordering, 

YES

> I thought that in the case of bonds we would have the same kind of 
> correspondence. 

NOT THE SAME (see above)

 
> I have checked in the manual that specific bonds can be selected by the 
> command "select[{i}]" or 
> a set of bonds could be attributed to a variable by "x = {atomno < 30}.bonds" 

Right, but that x will be a collection of bonds -- in which order, is difficult 
to 
anticipate.


> and I could change 
> the color of the selected bonds to red, for example. 

That would mean all bonds attached to that atom get the same red color.
But each bond will also be attached to another atom, then which is the last 
color applied to it?

So, in summary, I believe some of these "philosophical" or "logical" questions 
need to be answered before trying to find Jmol commands to do what you 
want.


--
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-17 Thread Max Pinheiro Jr
Good question. Since in the case of coloring atoms by the partial charge I
don't need to specify the atoms, i.e, I think there is a direct
correspondence of each line of the file for each atom in the respective
ordering, I thought that in the case of bonds we would have the same kind
of correspondence.

I have checked in the manual that specific bonds can be selected by the
command "select[{i}]" or a set of bonds could be attributed to a variable
by "x = {atomno < 30}.bonds" and I could change the color of the selected
bonds to red, for example. But I don't know how to use these commands to
associate the intensity of the color with the specific value of strain in
the data file. In this case, should I try a looping over the bonds for the
selection? Is there a keyword equivalent to "property_partialcharge" for
the case of bonds? Do you have some simple example to start with?

Thanks!

2017-01-17 11:39 GMT-05:00 Robert Hanson :

> How are you determining which bonds go with which properties in your file?
>
>
> On Mon, Jan 16, 2017 at 10:14 AM, Max Pinheiro Jr 
> wrote:
>
>> Dear Jmol team,
>>
>> I am trying to make a figure of a molecule in which the bonds are colored
>> by a RGB scale according to the values read from a data file. I have done
>> something similar to this idea in the case of coloring atoms by the value
>> of partial charges:
>>
>> x = load("charges.dat")
>> set propertydatafield 1
>> data "property_partialcharge @x"
>> {y>0}.label = load("charges.dat").split()
>> color property_partialcharge "bwr" range 0.7 1.3
>> write IMAGE PNG "color_by_charges.png"
>>
>> It worked pretty well in this case but I couldn't find a way to update my
>> script for the case of coloring bonds. I tried to use the "
>> property_bond_lengths" but it seems to have the same effect as in the
>> partialcharge. Is there a way to do such color maps of bonds in jmol? If
>> yes, could somebody, please, give me a suggestion of how to do that?
>>
>> I will be grateful for any help you can provide.
>>
>> All the best,
>>
>> Max Pinheiro Jr
>>
>> 
>> --
>> 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
>>
>>
>
>
> --
> Robert M. Hanson
> Larson-Anderson Professor 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
>
>
> 
> --
> 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
>
>
--
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-17 Thread Robert Hanson
How are you determining which bonds go with which properties in your file?


On Mon, Jan 16, 2017 at 10:14 AM, Max Pinheiro Jr  wrote:

> Dear Jmol team,
>
> I am trying to make a figure of a molecule in which the bonds are colored
> by a RGB scale according to the values read from a data file. I have done
> something similar to this idea in the case of coloring atoms by the value
> of partial charges:
>
> x = load("charges.dat")
> set propertydatafield 1
> data "property_partialcharge @x"
> {y>0}.label = load("charges.dat").split()
> color property_partialcharge "bwr" range 0.7 1.3
> write IMAGE PNG "color_by_charges.png"
>
> It worked pretty well in this case but I couldn't find a way to update my
> script for the case of coloring bonds. I tried to use the "
> property_bond_lengths" but it seems to have the same effect as in the
> partialcharge. Is there a way to do such color maps of bonds in jmol? If
> yes, could somebody, please, give me a suggestion of how to do that?
>
> I will be grateful for any help you can provide.
>
> All the best,
>
> Max Pinheiro Jr
>
> 
> --
> 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
>
>


-- 
Robert M. Hanson
Larson-Anderson Professor 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
--
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