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