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 <maxj...@gmail.com> 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 <hans...@stolaf.edu>:
>
>> 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 <hans...@stolaf.edu>
>> 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 <angel.herr...@uah.es>
>>> 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
>>
>>
>
> ------------------------------------------------------------
> ------------------
> 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

Reply via email to