Revision: 20799 http://sourceforge.net/p/jmol/code/20799 Author: hansonr Date: 2015-09-28 20:26:51 +0000 (Mon, 28 Sep 2015) Log Message: ----------- Jmol.___JmolVersion="14.3.16_2015.09.28b"
bug fix: draw ramachandran broken Modified Paths: -------------- trunk/Jmol/src/org/jmol/scriptext/CmdExt.java trunk/Jmol/src/org/jmol/scriptext/IsoExt.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/scriptext/CmdExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2015-09-28 11:34:14 UTC (rev 20798) +++ trunk/Jmol/src/org/jmol/scriptext/CmdExt.java 2015-09-28 20:26:51 UTC (rev 20799) @@ -2801,7 +2801,7 @@ vwr.tm.navigateList(eval, list); } - protected String plot(T[] args) throws ScriptException { + private String plot(T[] args) throws ScriptException { ScriptEval eval = this.e; // also used for draw [quaternion, helix, ramachandran] // and write quaternion, ramachandran, plot, .... Modified: trunk/Jmol/src/org/jmol/scriptext/IsoExt.java =================================================================== --- trunk/Jmol/src/org/jmol/scriptext/IsoExt.java 2015-09-28 11:34:14 UTC (rev 20798) +++ trunk/Jmol/src/org/jmol/scriptext/IsoExt.java 2015-09-28 20:26:51 UTC (rev 20799) @@ -273,7 +273,7 @@ case T.helix: case T.quaternion: case T.ramachandran: - e.getCmdExt().plot(st); + e.getCmdExt().dispatch(T.plot, false, st); return false; } boolean havePoints = false; Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-09-28 11:34:14 UTC (rev 20798) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2015-09-28 20:26:51 UTC (rev 20799) @@ -61,8 +61,13 @@ TODO: consider if models with no atoms will cause issues in relation to model.firstAtomIndex -Jmol.___JmolVersion="14.3.16_2015.09.28" +Jmol.___JmolVersion="14.3.16_2015.09.28b" +bug fix: draw ramachandran broken + + +JmolVersion="14.3.16_2015.09.28" + new feature: array.sort("key") -- sorts an array of associative arrays by the specified associative array key. -- example: @@ -151,19 +156,29 @@ JmolSQL -There are three parts to JmolSQL, object, keys, and an optional WHERE or WHERIN phrase: +JmolSQL is a Jmol math syntax that is designed to query information related to molecular structure. The idea is that associative arrays, with key/value pairs, and especially arrays of associative arrays, are data, and those arrays themselves can be thought of as a mini database. These sorts of data can be found in Jmol in the a model's auxiliary info (variable _M), including validation data returned from LOAD =xxxx/val (_M.validation), sequence domain data returned from LOAD =xxxx/dom (_M.domains), and secondary structure information returned from LOAD =xxxx/dssr (_M.dssr) or LOAD=xxxx/rna3d (_M.rna3d). In addition, the getProperty() function returns a wide variety of data relating to model attributes, including getProperty("atomInfo") and getProperty("bondInfo") among several others. + +The original conception of JmolSQL was in the context of the getProperty() function -- for example: + +load $caffeine +print getProperty("atomInfo[SELECT atomno,coord WHERE shape LIKE 'trigonal planar']") + + { "atomno" : 1 "coord" : {1.312 -1.0479 0.0025} } { "atomno" : 3 "coord" : {1.7906001 0.20809999 9.999999E-4} } ... +More recent development widens this use to any array data, and use of the .select() function rather than getProperty() is recommended for general use. Thus, alternatively we can use: + +print getProperty("atomInfo").select("atomno,coord WHERE shape LIKE 'trigonal planar' ") + + object.SELECT("keys WHERE/WHEREIN phrase") -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. +There are three parts to JmolSQL: object, keys, and an optional WHERE or WHEREIN phrase. The object can be either an associative array [key1:value1, key2:value2, key3:value3] or an array of associative arrays, usually all having the same set of keys. Associative Arrays -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. +When the top-level object is an associative array, .select() can be used to select +out subsets of that array, either as a single associative array or as an array of values. 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. +The simplest form of .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") @@ -180,15 +195,19 @@ 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 -arrays have the same keys is not important for Jmol, but is typical for a database. +In addition to operating on an associative array directly, JmolSQL can operate on an array of associative arrays. Generally we assume here that the elements of that array are associative arrays that all have 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. For example, the getProperty("atomInfo") returns an array giving the information for each atom that is loaded: -For example: +load $caffeine +x = getProperty("atomInfo") +print x.count -xyz = [ [a:1,b:11],[a:2,b:22],[a:3,b:33] ] +24 +print x[1] +{ "_ipt" : 0 "atomIndex" : 0 "atomno" : 1 "bondCount" : 3 "clickabilityFlags" : 48 "colix" : -32761 "color" : "[x3050f8]" "coord" : {1.312 -1.0479 0.0025} "element" : "nitrogen" "elemno" : 7 "formalCharge" : 0 "info" : "N1 #1" "model" : "1" "partialCharge" : 0.0 "radius" : 0.7416667 "shape" : "trigonal planar" "spacefill" : 0.3565 "sym" : "N" "visibilityFlags" : 63 "visible" : true "x" : 1.312 "y" : -1.0479 "z" : 0.0025 } +These data can be "queried" using JmolSQL. xyz.select("...") Creates the sublist of associative arrays having the selected subset of keys: @@ -197,9 +216,10 @@ print xyz.select("b").format("JSON") [ { "b": 11 },{ "b": 22 },{ "b": 33 } ] +print x.select("atomno,element") + { "atomno" : 1 "element" : "nitrogen" } { "atomno" : 2 "element" : "carbon" } { "atomno" : 3 "element" : "carbon" } { "atomno" : 4 "element" : "oxygen" } ... xyz.select("(...)") -Creates a list of only the b values of each of x, y, and z, in order: - +Adding parentheses creates a list of only the values for the specified keys: xyz = [ [a:1,b:11],[a:2,b:22],[a:3,b:33] ] print xyz.select("(b)").format("JSON") @@ -208,6 +228,9 @@ print xyz.select("(a,b)").format("JSON") [ 11,1,22,2,33,3 ] +load $caffeine +print getProperty("atomInfo").select("(element)").pivot +{ "carbon" : 8 "hydrogen" : 10 "nitrogen" : 4 "oxygen" : 2 } 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 @@ -218,6 +241,7 @@ 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. @@ -230,17 +254,38 @@ print xyz.select("* where a<3 and b<20").format("JSON") [ { "b": 11,"a": 1 } ] +load $caffeine +print getProperty("atomInfo").select("atomno,element WHERE shape LIKE 'trigonal planar' ").format("JSON") + +[ { "element": "nitrogen","atomno": 1 },{ "element": "carbon","atomno": 3 },{ "element": "nitrogen","atomno": 5 },{ "element": "carbon","atomno": 7 },{ "element": "carbon","atomno": 9 },{ "element": "nitrogen","atomno": 10 },{ "element": "carbon","atomno": 12 },{ "element": "carbon","atomno": 13 } ] + + xyz.select("(...) where ...") 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: +values for only 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 -targeted associative array elements, producing a flat array of those objects: +load $caffeine + print getProperty("atomInfo").select("(shape) WHERE shape").pivot +{ "bent" : 1 "tetrahedral" : 3 "trigonal planar" : 8 } +Note that "WHERE shape" here just excludes all cases where shape is the empty string, since empty strings in Jmol evaluate as FALSE. (In this case that involves hydrogen atoms.) +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 +Array "Drilling" + +WHERE will "drill down" through arrays of arrays to find +elements that are associative arrays, returning 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") @@ -249,6 +294,247 @@ print xyz.select("(b) where a>0").format("JSON") [ 11,22,33 ] + +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 +array, and *that array* has a specific set of key/value relationships. Thus, the +clause is checked one level deeper in the structure. + +For example, given the associative array + +abc = [key_1:[type:"a", i:1],key_2:[type:"b", i:2],key_3:[type:"a", i:3]] + +we can select out only those keys for which type='a': + +abc = [key_1:[type:"a", i:1],key_2:[type:"b", i:2],key_3:[type:"a", i:3]] +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 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 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 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") + +[ 1,5,8,10 ] + + + + +After taking a close look at this, I decided this was getting too cryptic. I think this is much simpler. This long email message summarizes the JmolSQL business, starting with Jmol 11.3.16_2015.09.28. See http://chemapps.stolaf.edu/jmol/zip/jmol-14.3.16_2015.09.28.zip + +JmolSQL +JmolSQL is a Jmol math syntax that is designed to query information related to molecular structure. The idea is that associative arrays, with key/value pairs, and especially arrays of associative arrays, are data, and those arrays themselves can be thought of as a mini database. These sorts of data can be found in Jmol in the a model's auxiliary info (variable _M), including validation data returned from LOAD =xxxx/val (_M.validation), sequence domain data returned from LOAD =xxxx/dom (_M.domains), and secondary structure information returned from LOAD =xxxx/dssr (_M.dssr) or LOAD=xxxx/rna3d (_M.rna3d). In addition, the getProperty() function returns a wide variety of data relating to model attributes, including getProperty("atomInfo") and getProperty("bondInfo") among several others. + +The original conception of JmolSQL was in the context of the getProperty() function -- for example: + +load $caffeine +print getProperty("atomInfo[SELECT atomno,coord WHERE shape LIKE 'trigonal planar']") + + { + "atomno" : 1 + "coord" : {1.312 -1.0479 0.0025} + } + { + "atomno" : 3 + "coord" : {1.7906001 0.20809999 9.999999E-4} + } + ... + +More recent development widens this use to any array data, and use of the .select() function rather than getProperty() is recommended for general use. Thus, alternatively we can use: + +print getProperty("atomInfo").select("atomno,coord WHERE shape LIKE 'trigonal planar' ") + + +object.SELECT("keys WHERE/WHEREIN phrase") +There are three parts to JmolSQL: object, keys, and an optional WHERE or WHEREIN phrase. The object can be either an associative array [key1:value1, key2:value2, key3:value3] or an array of associative arrays, usually all having the same set of keys. + +Associative Arrays +When the top-level object is an associative array, .select() can be used to select +out subsets of that array, either as a single associative array or as an array of values. + +abc.select("...") +The simplest form of .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 +In addition to operating on an associative array directly, JmolSQL can operate on an array of associative arrays. Generally we assume here that the elements of that array are associative arrays that all have 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. For example, the getProperty("atomInfo") returns an array giving the information for each atom that is loaded: + +load $caffeine +x = getProperty("atomInfo") +print x.count + +24 + +print x[1] + +{ + "_ipt" : 0 + "atomIndex" : 0 + "atomno" : 1 + "bondCount" : 3 + "clickabilityFlags" : 48 + "colix" : -32761 + "color" : "[x3050f8]" + "coord" : {1.312 -1.0479 0.0025} + "element" : "nitrogen" + "elemno" : 7 + "formalCharge" : 0 + "info" : "N1 #1" + "model" : "1" + "partialCharge" : 0.0 + "radius" : 0.7416667 + "shape" : "trigonal planar" + "spacefill" : 0.3565 + "sym" : "N" + "visibilityFlags" : 63 + "visible" : true + "x" : 1.312 + "y" : -1.0479 + "z" : 0.0025 + } + +These data can be "queried" using JmolSQL. + +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 } ] + +print x.select("atomno,element") + { + "atomno" : 1 + "element" : "nitrogen" + } + { + "atomno" : 2 + "element" : "carbon" + } + { + "atomno" : 3 + "element" : "carbon" + } + { + "atomno" : 4 + "element" : "oxygen" + } + ... +xyz.select("(...)") +Adding parentheses creates a list of only the values for the specified keys: + +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 ] + +load $caffeine +print getProperty("atomInfo").select("(element)").pivot +{ + "carbon" : 8 + "hydrogen" : 10 + "nitrogen" : 4 + "oxygen" : 2 + } + +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. + +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 } ] + +load $caffeine +print getProperty("atomInfo").select("atomno,element WHERE shape LIKE 'trigonal planar' ").format("JSON") + +[ { "element": "nitrogen","atomno": 1 },{ "element": "carbon","atomno": 3 },{ "element": "nitrogen","atomno": 5 },{ "element": "carbon","atomno": 7 },{ "element": "carbon","atomno": 9 },{ "element": "nitrogen","atomno": 10 },{ "element": "carbon","atomno": 12 },{ "element": "carbon","atomno": 13 } ] + + +xyz.select("(...) where ...") +Using parentheses around the list of keys delivers a list of +values for only 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 ] + +load $caffeine + print getProperty("atomInfo").select("(shape) WHERE shape").pivot +{ + "bent" : 1 + "tetrahedral" : 3 + "trigonal planar" : 8 + } + +Note that "WHERE shape" here just excludes all cases where shape is the empty string, since empty strings in Jmol evaluate as FALSE. (In this case that involves hydrogen atoms.) + For example, finding all the hydrogen bonds created by DSSR for a given residue: load =1ehz/dssr @@ -256,7 +542,24 @@ print x.format("JSON") print format("%5.3f",x.average) -[ 2.832,2.879,2.838 ] 2.850 +[ 2.832,2.879,2.838 ] +2.850 + +Array "Drilling" + +WHERE will "drill down" through arrays of arrays to find +elements that are associative arrays, returning 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 ] + WHERE vs. WHEREIN Starting with Jmol 14.4, JmolSQL includes an additional option, WHEREIN. This option @@ -274,6 +577,7 @@ 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 instead of key/value pairs: @@ -282,6 +586,7 @@ 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 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 @@ -290,11 +595,12 @@ 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 -} +{ + "(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: @@ -302,11 +608,12 @@ 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 -} +{ + "(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)*' ") @@ -314,6 +621,8 @@ [ 1,5,8,10 ] + + JmolVersion="14.3.16_2015.09.25" bug fix: HBONDS DELETE broken since 14.1.2 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