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:
-
configuration
A dictionary of the currently configured values for query properties, fields and table names.
-
sql_query
The query recoded as an
SQL
query on a simple table schema, with referenced table and column names as defined in the query object configuration.
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
:
-
atomtable
Set the name of the atom table for translating the query into
SQL
.
-
bondtable
Set the name of the bond table for translating the query into
SQL
.
-
ens_elementcount_field
Set the name of the column with an array of element counts in the ensemble table for translating the query into
SQL
.
-
ens_elementcount_property
Set the property used to compute ensemble element counts for formula searching.
-
ens_isotopehash_field
The name of the column with isotope-aware ensemble hashes in the ensemble table for translating the query into
SQL
.
-
ens_isotopehash_property
The property used to compute isotope-aware ensemble hashes. This is by default inherited from the control variable
cactvs(default_structure_isotope_hash_property)
.
-
ens_isotopestereohash_field
Set the name of the column with isotope- and stereo-aware ensemble hashes in the reaction table for translating the query into
SQL
.
-
ens_isotopestereohash_property
The property used to compute isotope- and stereo-aware ensemble hashes. This is by default inherited from the control variable
cactvs(default_structure_isotope_stereo_hash_property)
.
-
ens_similarityscreen_field
The name of the column with the similarity screen bitvector.
-
ens_similarityscreen_property
The property used to compute the similarity screen bitvector. This is by default inherited from the control variable
cactvs(default_similarity_property)
.
-
ens_simplehash_field
The name of the column with simple ensemble hashes in the ensemble table for translating the query into
SQL
.
-
ens_simplehash_property
Set the property used to compute simple ensemble hashes. This is by default inherited from the control variable
cactvs(default_structure_simple_hash_property)
.
-
ens_simpletautohash_field
Set the name of the column with simple tautomer-tolerant ensemble hashes in the ensemble table for translating the query into
SQL
.
-
ens_simpletautohash_property
The property used to compute simple tautomer-tolerant ensemble hashes. This is by default inherited from the control variable
cactvs(default_structure_tauto_hash_property)
.
-
ens_stereohash_field
The name of the column with stereo-aware ensemble hashes in the ensemble table for translating the query into
SQL
.
-
ens_stereohash_property
Set the property used to compute stereo-aware ensemble hashes. This is by default inherited from the control variable
cactvs(default_structure_stereo_hash_property)
.
-
ens_substructurescreen_field
The name of the column with the substructure screen bitvector
-
ens_substructurescreen_property
The property used to compute the substructure screen bitvector. This is by default inherited from the control variable
cactvs(default_substructure_screen_property)
.
-
ens_superstructurescreen_field
The name of the column with the superstructure screen bitvector
-
ens_superstructurescreen_property
The property used to compute the superstructure screen bitvector. This is by default inherited from the control variable
cactvs(default_superstructure_screen_property)
.
-
enstable
The name of the base ensemble-level table for translating the query into
SQL
.
-
fileassociation
The handle or reference of an open structure or reaction data file. Some file formats contain metadata on the internal configuration of the files, which are then automatically used to configure the right properties and field names for standard structure and reaction queries on this file. Providing a file reference is not req uired, it can just make the query configuration set-up easier.
-
flags
A bit-ored combination of various flags. The currently supported flags are ignorethresholds and screeningonly.
-
keycolumn
The name of tghe
SQL
column which links ensembles and atom/bond tables.
-
querystring
The string form of the query. Setting this re-configures the query object to check a different match condition.
-
reaction_isotopehash_field
Set the name of the column with isotope-aware reaction hashes in the reaction table for translating the query into
SQL
.
-
reaction_isotopehash_property
Set the property used to compute isotope-aware reaction hashes. This is by default inherited from the control variable
cactvs(default_reaction_isotope_hash_property)
.
-
reaction_isotopestereohash_field
Set the name of the column with isotope- and stereo-aware reaction hashes in the reaction table for translating the query into
SQL
.
-
reaction_isotopestereohash_property
Set the property used to compute isotope- and stereo-aware reaction hashes. This is by default inherited from the control variable
cactvs(default_reaction_isotope_stereo_hash_property)
.
-
reaction_screen_field
The name of the column with the reaction screen bitvector
-
reaction_screen_property
The property used to compute the reaction screen bitvector. This is by default inherited from the control variable
cactvs(default_reaction_screen_property)
.
-
reaction_simplehash_field
Set the name of the column with simple reaction hashes in the reaction table for translating the query into
SQL
.
-
reaction_simplehash_property
The property used to compute simple reaction hashes. This is by default inherited from the control variable
cactvs(default_reaction_simple_hash_property)
.
-
reaction_stereohash_field
Set the name of the column with stereo-aware reaction hashes in the reaction table for translating the query into
SQL
.
-
reaction_stereohash_property
The property used to compute stereo-aware reaction hashes. This is by default inherited from the control variable
cactvs(default_reaction_stereo_hash_property)
.
-
reactiontable
The name of the base reaction-level table for translating the query into
SQL
.
-
sql_dialect
The
SQL
dialect to use when translating the query to
SQL
. This is by default inherited from the
cactvs(sql_dialect)
control variable.
query subcommands
query subcommands
dir(Query)
Lists all subcommands of the
query
command. Note that this command does not require a query handle.