Thomas Stout wrote:
> Hi All --
>
> Well, I've stumbled over this long enough & I need to ask for help! I have
> a case where I want to step through the chains of a selection (many PDB
> files have more than one identical protein-ligand complex per
> crystallographic asymmetric unit and use the identical atom names and
> residue numbering, thereby only differing in chain ID). I would like to use
> the "*show chains*" command introduced in 11.5.51, since that returns
> exactly what I need, but I admit to not fully understanding how to grab this
> output into my scripting environment. I'd love to have an array that I
> could loop through (eg "chains[0]", chains[1]", etc). I could jump back
> and forth between javascript and JmolScript and accomplish the task with
> something like:
>
> function getChainArray() {
> var chainString = script("show chains"); //pass result of script into
> variable as string
> var chains = chainString.split("\n"); //split string on
> linefeeds, or \r\n if Windows linefeeds
> }
>
> function UseTheSelection(){
> var chains = getChainArray();
> for (var j=0;j<chains.length;j++){
> jmolScriptWait("select {selected} and chains[j]};");
> jmolScriptWait("do other stuff");
> }
>
>
> but, I really don't want to have to throw it back and forth. I'm guessing
> there *must* be a simple way -- within JmolScript -- to get an array of
> chain IDs from the current selection, but I've not come up with it yet.
>
You could use for example:
x=script("show chains");
for (i=1; i<=x.size; i=i+1);
# do some stuff using x[i]
end for;
Unfortunately you get more lines than chains. For example with '1deh',
containing 2 protein chains (A,B) plus an empty chain identifier " " for
the water molecules you will get an array with 7 elements. so you still
might have to check if it is a valid chain identifier.
Currently I am using the following solution to identify valid protein
chain identifiers:
chain_id_list = array(" ","A","B","C","D","E","F","G","H","I","J","K",
"L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c",
"d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u",
"v","w","x","y","z","0","1","2","3","4","5","6","7","8","9");
for (i=1; i<=chain_id_list.size; i=i+1);
selection_expression = "protein AND *:" + chain_id_list[i];
selected_atom_count = [EMAIL PROTECTED];
if (selected_atom_count > 0);
# do whatever you want
end if;
end for;
Regards,
Rolf
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users