Re: [Jmol-users] selection using modulus -- new feature: select() function

2008-06-13 Thread Bob Hanson
Angel, that got me thinking Jmol 11.5.40 will include a new feature:

 full math on individual atom properties using a new function:

   select(dummyVariable;{atomexpression};booleanEvaluation)

I've installed the latest applet Jar files at 
http://Jmol.ProteinExplorer.org in the subdirectory

  http://Jmol.ProteinExplorer.org/molview

in case you are interested in experimenting with this.

 for example:

   x = select(x;{*};x.atomIndex%427 = 397)
  color @x blue;
  select ! @x

or

 print select(x;{*};x.atomIndex / 50 = 397);



The idea is this:

--choose a dummy variable -- x in this case
--identify a set of atoms to be included in the calculation -- {*} here
--give an expression in terms of atom properties that you want 
satisfied. This expression will be looped through for each atom in the 
set and tested for being TRUE or FALSE.

While you cannot mix standard select syntax with this:

  select select(.) # NOT

you can define a variable and then select it:

  var x = select(x;{..};...);  select @x

or you can do the math inline with the @{...} syntax:

  select  @{ select(x;{..};...) }

You just have to be careful to distinguish Jmol math from the original 
Rasmol syntax. So you can do this:

 select  @{ select(x;{*};x.atomno  3) } and model=1

But in this case it would be more efficient to use:

select  @{ select(x;{model=1};x.atomno  3) }

because there would be only one loop instead of two.

Note that the variable name chosen as the first parameter of the select 
function is local to it -- it's just a dummy variable that needs to be 
there so that Jmol can refer to individual atoms when it evaluates that 
expression. If you have already defined x, then using select(x;...) 
will not change its value -- and, likewise, within the select() 
evaluation, your x will not be used if the dummy variable is given the 
name x. I think this is fair.

In principal you could replace just about any select of the form:

  select atomno  3 or 

with:

 x = select(x;{*};x.atomno  3 or)

It actually might be more efficient this way.  But I'm not sure. The new 
way is pretty efficient and fewer loops are involved than the old way.  
Because in the old way, each term such as atomno  3  or model=2 
required a full scan of all atoms, whereas here there is just one 
overall loop. Maybe someone could run some timing tests and tell us what 
the difference is.

Notice that the select syntax, with its two semicolons, is similar to 
the FOR command syntax:

  for (var i; i  3; i = i + 1)

In fact, having that already in Jmol explains why  it was easy to 
implement this so fast. It was a nice challenge getting this to work. 
And, believe it or not,  it only took about 40 lines of code (and about 
5 hours of my time!).

Thanks, Angel, for posting your need. This should be quite generally useful.

By the way, in preparing Jmol Protein Explorer, I'm amazed at all the 
comments in the code about how SLOW Chime was to select atoms for large 
systems. I guess I only used it for small molecules. Was it really that 
slow? One hardly notices any delay in Jmol selecting 50,000 atoms. I 
wonder what in the world Chime was doing

Bob



Angel Herraez wrote:

Hi
I have a complex loading of several models and I need to select a 
combination of atoms based on their atomIndex property and the 
mathematical MODULUS operator.

I have tried 
   select (atomIndex % 427) = 397;
but a get an error, a comparison operator was expected

It seems that the limitation is in operating with atomIndex before 
the comparison, since
   select (atomIndex / 50) = 397;
gives the same error, while
   select atomIndex = 397;
works OK

What is the way to achieve this?


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users
  



-- 
Robert M. Hanson
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 new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


Re: [Jmol-users] selection using modulus -- new feature: select() function

2008-06-13 Thread Angel Herraez
It's working, Bob - Wonderful!

This fits my plans/needs for the 3D phase diagram page 
(in that project, I am loading two files 4 times, in just 4 frames, 
so specifying the atomNo are not enough, I needed the atomIndex and 
the modulus to select specific groups of atoms easily).



-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users


[Jmol-users] selection using modulus

2008-06-10 Thread Angel Herraez
Hi
I have a complex loading of several models and I need to select a 
combination of atoms based on their atomIndex property and the 
mathematical MODULUS operator.

I have tried 
select (atomIndex % 427) = 397;
but a get an error, a comparison operator was expected

It seems that the limitation is in operating with atomIndex before 
the comparison, since
select (atomIndex / 50) = 397;
gives the same error, while
select atomIndex = 397;
works OK

What is the way to achieve this?


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
___
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users