Hi,
I would like to sort an atom selection by some atom property. I can do 'var x =
{1}.vdw.all; x.sort; print x;' but then I loose the link to actual atoms. I
know what the 3rd smallest vdw radius is but not to which atom(s) it belongs.
I know that I could use a loop in Jmol-script but that takes too long for
proteins or ribosomes, try e.g. the tests at the end. Wait... I tried a 2nd
implementation that reuses a large enough array and also gets the properties at
once. So my ideas below for new functions are not that pressing. But I still
think them a valuable addition. What is your opinion?
-----
If there is no way to do it, I would suggest the following. There is already
fast way to sort an array of arrays with
'array.sort(columnIndexOfNestedArray)'. So how to get an array of arrays like
'x = [[vdw1, atomindex1], [vdw2, atomindex2], ...]' which could be sorted with
'x.sort(1)'. Then, how to get an array of the sorted (by the vdw radius)
atomindex. I suggest two variations of the array methods add/sub:
'array.add(APPEND, array2)' and 'array.sub(PLUCK, columnIndex)'.
Array.add(APPEND, array) would do: 'a1 = [1,2,3]; a2 = [4,5,6]; a3 =
a1.add(APPEND, a2); print a3 => [[1,4],[2,5],[3,6]]' and 'print a3.add(APPEND,
a1) => [[1,4,1],[2,5,2],[3,6,3]]'. Array.sub(PLUCK, columnIndex) would do
'print a3.sub(PLUCK, 2) => [4,5,6]'.
@Bob I'm thinking about adding these myself, would you second the syntax I
outlined above? Alternatively we could add new functions 'array.append' and
'array.pluck'. Is it sufficient to add the new tokens to script.Token.java and
handle the occurrence of the new tokens in
script.ScriptMathProcessor.java::evaluateList()?
Best
Alexander
1VQK.pdb (91602 atoms)
load =1vqk;
var x = {*}.vdw.all; x.sort; print "sort done"; # instantly done
# very slow
function property_list(sele){
var arr = [];
for( a in sele ){
arr |= [[ a.atomindex, a.vdw ]];
}
print "done";
}
#property_list( {*} );
# much faster, ok for most structures
function property_list2(sele){
var arr = sele.atomindex.all;
var prop = sele.vdw.all
var n = arr.length
for( var i=1; i<=n; ++i ){
arr[i] = [ arr[i], prop[i] ];
}
print "done2";
#print arr;
}
property_list2( {*} );
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users