Query_syntax

[Related to the query language: see help for Query By Example, the Query Builder, the Query Command Window, and the TableMaker. The help for KeySet windows is also important. A more formal description of the language is presented in the manual doc/query_language_guide.tex]

There are 3 general forms for a query command:

Find Class xxxxxx
The command xxx is applied to all the keys of the (sub)Class. Can be abbreviated as
>?Class xxxxxx
Follow Tag xxxx
The command xxx is applied to all the keys following tag in the objects of the active key set. Can be abbreviated as:
> Tag xxxxxx
xxxx
The command xxx is applied directly to the active key set.
A command is a logical expression evaluating to True or False. It is applied to a key which is discarded or retained in a KeySet based on the outcome of the test.

A composite query can be formed by chaining a series of queries separated by semicolons, in which case the active KeySet obtained as intermediate results are passed into the next query.

Operators

Recognised operators are, in order of increasing precedence:

        $|           SETOR
        $&           SETOR
        $^           SETXOR
        $-           SETMINUS
        $=           SETDEFINE (possibly bugged)
                     NEIGHBOURS
	|            OR
	^            XOR
	&            AND
	!            NOT
        #            Jumps in constructed types.
        <            to compare numbers
        <=                   "
        >                    "
        >=                   "
	=            to compare numbers or match the left hand side
	 	     to a template, i.e  a word with wild chars *, ?.
        COUNT        Counts the number of entries to right of its rhs
        IS  xxx      Checks if name of the active object matches xxx
        CLASS xxx    Checks if active object belongs to (sub)class xxx
Parentheses of all sorts "( [" can be used freely, but must be matched.

Words are matched to a tag or treated just as text. They must be put in "double quotes" if they include spaces or any operator &, |, ^, <, >, =, (, ), [, ], {, }. Wild cards can be used in words but then they are not at present matched to tags except in a redirection. Numbers are parsed as floats.

Examples

1.     >?Chrom*
lists all chromosomes

2.     >?Author s* | a*
lists all authors whose name begins with s or a

3.     >?Au*  s?s* OR b*s*
lists all authors whose name matches s?s* or b*s*

4.     >Pap*  Journal = N* OR Year > 1987 
Checks the previous list from query 3; redirect to papers then lists all papers published in N(ature) or after 1987

5.      Year = 1988
Restricts to the papers of exactly 1987

6.      >?Gen* myo* Clone
All the cloned myosin genes

7.      Find Author IS "Sulston JE" ; >Paper ; >Author
Finds all the coauthors of papers by Sulston.

Subfields, Subtypes, and COUNT

Subfields: some tags are followed by more than one value. To test the value of subfields you must first locate yourself on the tag then move right from it using NEXT (move right) or HERE (move here) for multiple checks. For example, suppose there were a class "Chemical" with a tag identifying the boiling and freezing points of compounds, e.g. for water:

        B_F  100 0
to identify compounds with boiling and freezing points in a certain range:

        Find Chemical B_F >50 AND NEXT >100 AND HERE <250
i.e., with boiling points > 50 and freezing points between 100 and 250 degrees.

This is clearly hard to read. Also, it will be evaluated at execution left to right as it should only if the precedence of the operators allows it. Be careful.

Subtypes: to locate a tag in a subtytpe, you must indicate the path using the operator #, for example:

        Find Gene Lab AND NEXT#freezer = 4
To find all the genes in your freezer number 4

COUNT: this operator can be used to test the number of entries. For example, to find prolific authors:

        Find Author COUNT Paper > 100
to Table of Contents

last edited: July 1994