Eran Hodis wrote:
> Hello all,
> 
> Please direct me to a previous group posting if the answers to my  
> questions have already been posted but...
> 
> I seem to be having a problem selecting atoms by their atom numbers  
> using "select atomno".
> 
> When I enter a sequence of atoms like "select atomno=30-40", I get an  
> error:
> 
> select atomno=30-40
> pending
> script compiler ERROR: end of expression expected
> ----
>           select atomno=30-40 <<<<
> 
> ("select atomno=30" works fine.  As does any selection of a single  
> atom number.)
> 
> I'm using Jmol 11.3.34.
> 
I think it just isn't implemented (yet?) to use a range in an "atomno="
expression.

But if you use a slightly newer version (script below was tested with
11.3.47) you could define yourself a function that does what you want:

function atomnoSelection(start_atomno,end_atomno);
  var sel_exp = "";
  for (i=start_atomno; i<=end_atomno; i=i+1);
    if (sel_exp = "");
      sel_exp = "atomno=" + i;
    else;
      sel_exp = sel_exp + " OR atomno=" + i;
    end if;
  end for;
  if (sel_exp != "");
    sel_exp = "(" + sel_exp + ")";
  end if;
  return sel_exp;
end function;

I surrounded the resulting expression with brackets in order to be able
to use it in combination with any other expression.

You could use the function for example like this:

  select @{atomnoSelection(30,40)} and */1

This would select atoms 30-40 of model 1.

You can take a look at the output of the function with the "print" command:

  print atomnoSelection(1,5);


Isn't it amazing what is possible now with Jmol scripting?

Regards,
Rolf

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to