The query Command

The query command creates a reusable object from the query expression parameter of a scan command ( molfile scan , dataset scan , etc.). All commands where such a query expression can be used as a string parameter alternatively accept the handle or reference of a query object in its place.

Additionally, query objects offer method to translate the query from the native toolkit syntax into other formats, such as SQL .

Examples:

set qh [query create “structure >= c1ncccc1”]
set n [molfile scan $fh $qh count]

This is the list of currently officially supported subcommands:

query create

query create ?querystring?
Query(?querystring)?
Query.Create(?querystring?)

Create a new query object from a query expression entered as a string. It is possible to omit the query string or pass en empty string or Null . In that case, a query which always matches is created.

Example:

set qh [query create {and {E_NMOLECULES = 1} {structure >= c1ncccc1}}]

query delete

query delete all
query delete ?qhandlelist?...
q.delete()
Query.Delete(“all”)
Query.Delete(?qrefsequence/qref/qhandle?,...)

Delete query objects. The special parameter all may be used to delete all queries currently registered in the application. Alternatively, any number of lists of query handles may be specified for specific query deletions.

The command returns the number of deleted queries.

Example:

query delete $qhandle

query get

query get qhandle attribute
q.get(attribute)
q.attribute
q[attribute]

Get an attribute value of the query objects. Besides the settable attributes listed under query set , the following attributes are read-only:

query list

query list ?pattern?
Query.List(?pattern=?)

Return a list of the handles of all currently existing query objects in the application. If desired, the list can be filtered by a string pattern.

query print

query print qhandle
q.print()

Return the string representation of the query in native toolkit format.

query ref

Query.Ref(identifier)

Python only method to get a query reference from a handle or another identifier.

query set

query set qhandle ?attribute value?...
query set qhandle attributedict
q.set(attributedict)
q.set(attribute,value,...)
q.att = value
q[att] = value

Configure the query object. The following attributes can be set and also read via query get :

query subcommands

query subcommands
dir(Query)

Lists all subcommands of the query command. Note that this command does not require a query handle.