On 09/28/2015 06:46 PM, Robert Hanson wrote:
> //Thank you, Rolf, for working on the .select() business. /After taking
> a close look at it, I decided the select() function was getting too
> cryptic, and I agree that there were some inconsistencies there. What is
> given below 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
>
Bob, thank for working on this. I agree that 'WHERE/WHEREIN" is much
clearer than '*/**' with '*/**" additionally as wildcard options. But
for me there is still left an inconsistency in the behaviour.
As far as I have seen the 'select' command now has essentially three
things that determine the behaviour:
1) The type of the first-level and second-level array: "standard" or
"associative".
2) The 'key' part of the query string (e.g.: "key1" or "(key1)")
determines if whole structures are returned (no brackets) or only the
values (brackets). And it also determines if only a subset of an array
element or its values is returned.
3) The keywords 'WHERE', 'WHEREIN' and "no keyword" determine where is
looked for matching data.
Implemented are now the following combinations (among others), if I
understood it correctly:
A) associative + no brackets
-> Searches in the first-level keys of the associative array. Returns
a complete subset of the first-level array with the matching keys.
B) associative + brackets
-> Searches in the first-level keys of the associative array. Returns
only the values (which can be scalars or arrays) behind the matching keys.
C) standard/associative + no brackets
-> Searches the second-level keys. Returns a subset of the
first-level array with the named second-level keys only.
D) standard/associative + brackets
-> Searches the second-level keys. Returns the values behind the
named second-level keys.
E) standard/associative + WHERE + no brackets
-> Searches keys from 2) and of phrase from 3) in the second-level
keys of the associative arrays. Returns a complete subset of the
first-level array with the matching second-level keys, restricted by the
'WHERE' phrase.
F) standard/associative + WHERE + brackets
-> Searches keys from 2) and of phrase from 3) in the second-level keys
of the associative arrays. Returns only the values of the second-level
array with the matching second-level keys, restricted by the 'WHERE' phrase.
G) associative/associative + WHEREIN + no brackets
-> Searches keys from 2) in the first-level keys and keys of phrase from
3) in the second-level keys of the associative arrays. Returns a subset
of the first-level array with the matching first-level keys, restricted
by the 'WHERE' phrase.
H) associative/associative + WHEREIN + brackets
-> Searches keys from 2) in the first-level keys and keys of phrase from
3) in the second-level keys of the associative arrays. Returns a subset
of the values of the first-level array with the matching first-level
keys, restricted by the 'WHERE' phrase.
The multi-level combinations C) to F) have in common that the key
restrictions from 1) act on the same level as the keys of the phrase
from 3). In contrast in the multi-level combinations G) and H) the
levels are mixed. This doesn't seem to be very consistent to me. At
least it seems to be counterintuitive.
Even if you don't agree, there are two missing cases where the levels
are not mixed. Assuming a "consistent" behaviour they would look like this:
---- Example Code ------------
snpInfo = {"rs1229984": [resno: 48,
from: "R",
to: "H"],
"rs1041969": [resno: 57,
from: "N",
to: "K"]
};
print "=== Case 1 ====";
print snpInfo.select("from,to WHEREIN to='H'").format("JSON");
print "=== Case 2 ====";
snpInfo.select("(resno) WHEREIN to='H'");
---- Example Output -----------
=== Case 1 ====
{"rs1229984": {"from": "R","to":"H"}}
=== Case 2 ====
[48]
--------------------------------
The second case could be solved by two consecutive 'select' commands.
But that would make the usage much more complicated because one couldn't
just provide a single selection filter string:
print snpInfo.select("(*) WHEREIN from='R'").select("(resno)");
For my usual use of multi-level associative arrays these two cases would
be the standard. But of course also the currently implemented two cases
do make sense. I have no idea yet, how a good syntax for them could look
like.
Regards,
Rolf
--
Rolf Huehne
Postdoc
Leibniz Institute for Age Research - Fritz Lipmann Institute (FLI)
Beutenbergstrasse 11
07745 Jena, Germany
Phone: +49 3641 65 6205
Fax: +49 3641 65 6210
E-Mail: [email protected]
Website: http://www.fli-leibniz.de
Scientific Director: Prof. Dr. K. Lenhard Rudolph
Head of Administration: Dr. Daniele Barthel
Chairman of Board of Trustees: Dennys Klein
VAT No: DE 153 925 464
Register of Associations: No. 230296, Amtsgericht Jena
Tax Number: 162/141/08228
------------------------------------------------------------------------------
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users