Revision: 20798 http://sourceforge.net/p/jmol/code/20798 Author: hansonr Date: 2015-09-28 11:34:14 +0000 (Mon, 28 Sep 2015) Log Message: ----------- lost getProperty("atomInfo")
Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/PropertyManager.java Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-09-28 10:02:39 UTC (rev 20797) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-09-28 11:34:14 UTC (rev 20798) @@ -150,50 +150,39 @@ 2.8496666 -So... - JmolSQL - There are three parts to JmolSQL, object, keys, and an optional WHERE or WHERIN phrase: object.SELECT("keys WHERE/WHEREIN phrase") - -The object can be either an associative array [key1:value1, key2:value2, key3:value3] +The object can be either an associative array [key1:value1, key2:value2, key3:value3] or an array of associative arrays, usually with the same set of keys. Associative Arrays - -When the top-level array is an associative array, select() can be used to select +When the top-level array is an associative array, select() can be used to select out subsets of the array, either as a single associative array or as an array of values. -abc.select("A,B") - -returns a subset of abc. Wild cards can be interspersed with additional keys, +abc.select("...") +returns a subset of abc. Wild cards can be interspersed with additional keys, for example, "a*,b" or "*_id". In each such case, the case-sensitive LIKE operation is used to match keys. abc = [ A:[b:1],B:[b:2],AA:[b:3, d:50] ] print abc.select("A").format("JSON") { "A": { "b": 1 } } - abc = [ A:[b:1],B:[b:2],AA:[b:3, d:50] ] print abc.select("A*").format("JSON") { "A": { "b": 1 },"AA": { "b": 3,"d": 50 } } - abc.select("(...)") - Using parentheses around the list of keys delivers a list of values of b for only the the subset of xyz for which a=1: abc = [ A:[b:1],B:[b:2],AA:[b:3, d:50] ] print abc.select("(A,B)").format("JSON") [ { "b": 2 },{ "b": 1 } ] - Arrays of Associative Arrays - -Generally we assume here that the elements of the array are associative arrays, all with the -same set of keys. This is the essence of a database. Whether or not the associative +Generally we assume here that the elements of the array are associative arrays, all with the +same set of keys. This is the essence of a database. Whether or not the associative arrays have the same keys is not important for Jmol, but is typical for a database. For example: @@ -201,82 +190,77 @@ xyz = [ [a:1,b:11],[a:2,b:22],[a:3,b:33] ] -xyz.select("b") - +xyz.select("...") Creates the sublist of associative arrays having the selected subset of keys: xyz = [ [a:1,b:11],[a:2,b:22],[a:3,b:33] ] print xyz.select("b").format("JSON") [ { "b": 11 },{ "b": 22 },{ "b": 33 } ] - xyz.select("(...)") - Creates a list of only the b values of each of x, y, and z, in order: xyz = [ [a:1,b:11],[a:2,b:22],[a:3,b:33] ] print xyz.select("(b)").format("JSON") [ 11,22,33 ] - xyz = [ [a:1,b:11],[a:2,b:22],[a:3,b:33] ] print xyz.select("(a,b)").format("JSON") [ 11,1,22,2,33,3 ] - -The assumption when using (keys) is that you want to know all these values, -but you don't care what order they are in (because that will not be predictable) -and you don't care about their exact context. An example is a list of bonds for -which we just want to know all the atoms involved, but the atoms are listed +The assumption when using (keys) is that you want to know all these values, +but you don't care what order they are in (because that will not be predictable) +and you don't care about their exact context. An example is a list of bonds for +which we just want to know all the atoms involved, but the atoms are listed under "atom1" and "atom2" in each bond array. load =1ehz/dssr select on @{_M.dssr.hbonds.select("(atom1_id,atom2_id)")} 206 atoms selected - Using WHERE - WHERE is used to select a subset of the elements of an array based on specific key-value relationships. xyz.select("... WHERE ...") +Delivers all key/value pairs in the subset of xyz element associative arrays +for which the WHERE clause is true for that element. -Delivers all key/value pairs in the subset of xyz element associative arrays -for which the WHERE clause is true for that element. - xyz = [ [a:1,b:11],[a:2,b:22],[a:3,b:33] ] print xyz.select("* where a<3 and b<20").format("JSON") [ { "b": 11,"a": 1 } ] - xyz.select("(...) where ...") - -Using parentheses around the list of keys delivers a list of +Using parentheses around the list of keys delivers a list of values of for only the the subset of xyz for which the WHERE clause is true: xyz = [ [a:1,b:11],[a:2,b:22],[a:3,b:33] ] print xyz.select("(b) where a>1").format("JSON") [ 22,33 ] - -Note that "... where..." will "drill down" through arrays of arrays to find the +Note that "... where..." will "drill down" through arrays of arrays to find the targeted associative array elements, producing a flat array of those objects: xyz = [ [[a:1,b:11], [a:0,b:0]],[[[a:2,b:22]]],[[a:3,b:33,aa:44]] ] print xyz.select("a* where a>0").format("JSON") [ { "a": 1 },{ "a": 2 },{ "a": 3,"aa": 44 } ] - xyz = [ [[a:1,b:11], [a:0,b:0]],[[[a:2,b:22]]],[[a:3,b:33,aa:44]] ] print xyz.select("(b) where a>0").format("JSON") [ 11,22,33 ] +For example, finding all the hydrogen bonds created by DSSR for a given residue: + +load =1ehz/dssr +x = _M.dssr.hbonds.select("(distance) where res_long like '*|A|C|72|*'"); +print x.format("JSON") +print format("%5.3f",x.average) + +[ 2.832,2.879,2.838 ] 2.850 WHERE vs. WHEREIN - -Starting with Jmol 14.4, JmolSQL includes an additional option, WHEREIN. This option -allows selecting specific key/value pairs for which the value is itself an associative +Starting with Jmol 14.4, JmolSQL includes an additional option, WHEREIN. This option +allows selecting specific key/value pairs for which the value is itself an associative array, and *that array* has a specific set of key/value relationships. Thus, the clause is checked one level deeper in the structure. @@ -290,22 +274,41 @@ print abc.select("* WHEREIN type='a'").format("JSON"); { "key_3": { "i": 3,"type": "a" },"key_1": { "i": 1,"type": "a" } } - All of the options that involve WHERE also apply to WHEREIN. For example, -multiple keys can be specified, and keys can be surrounded by parentheses -to return just the values: +multiple keys can be specified, and keys can be surrounded by parentheses +to return just the values instead of key/value pairs: abc = [key_1:[type:"a", i:1],key_2:[type:"b", i:2],key_3:[type:"a", i:3]] print abc.select("(key_1,key2) WHEREIN type='a'").format("JSON"); [ { "i": 1,"type": "a" } ] - -In addition, WHEREIN can be applied to arrays as well as associative arrays. +In addition, WHEREIN can be applied to arrays as well as associative arrays. In this case, the WHEREIN phrase applies to the elements of that array, which are assumed to be associative arrays. For example, we can get a list of just -the orbitals that are of a given symmetry: +the occupied orbitals produced by Gaussian that are of a given symmetry: load http://chemapps.stolaf.edu/jmol/jsmol/data/no2_nbo.log.gz 2 filter "alpha" +print _M.moData.select("mos wherein occupancy>0").select("(symmetry)").pivot + +{ "(A1)--O" : 6 + "(A2)--O" : 1 + "(B1)--O" : 1 + "(B2)--O" : 4 +} + +Note that this use of WHEREIN with arrays in this way can also be accomplished +more directly with WHERE: + +load http://chemapps.stolaf.edu/jmol/jsmol/data/no2_nbo.log.gz 2 filter "alpha" +print _M.moData.mos.select("(symmetry) where occupancy>0").pivot + +{ "(A1)--O" : 6 + "(A2)--O" : 1 + "(B1)--O" : 1 + "(B2)--O" : 4 +} + +load http://chemapps.stolaf.edu/jmol/jsmol/data/no2_nbo.log.gz 2 filter "alpha" x= _M.moData.select("mos wherein occupancy>0 and symmetry like '(B2)*' ") print x.select("(index)").format("JSON") Modified: trunk/Jmol/src/org/jmol/viewer/PropertyManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2015-09-28 10:02:39 UTC (rev 20797) +++ trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2015-09-28 11:34:14 UTC (rev 20798) @@ -192,8 +192,9 @@ private final static int PROP_CENTER_INFO = 10; private final static int PROP_ORIENTATION_INFO = 11; private final static int PROP_TRANSFORM_INFO = 12; - private final static int PROP_ATOM_INFO = 13; - + + private final static int PROP_ATOM_INFO = 14; + private final static int PROP_BOND_INFO = 15; private final static int PROP_CHAIN_INFO = 16; private final static int PROP_POLYMER_INFO = 17; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits