It is often convenient to highlight or focus certain parts of the structure. OpenStructure includes a powerful query system that allows you to perform custom selections in a convenient way.

Please refer to the tutorial on the query language for an introduction.

The query language reference

The query consists of one or more predicates combined with boolean operators. A predicate takes the form prop op value. Operators are one of

=, !=, >, >=, <=` and `<

. A predicate has the following form: PROPERTY - OPERATOR - ARGUMENT. The following properties may be used in predicates. The supported type of the value is given for each property.

Distance-based selections within a given atom position are supported by the within statement. To select atoms within 5 Angstrom of the point {1,2,3}, one would write:

5 <> {1,2,3}

Negation of this expression is possible with the not operator, i.e.

not 5 <> {1,2,3}

will select atoms that are further than five Angstrom apart from {1,2,3}

Two abbreviations exist for convenience:

Instead of writing aname=CA or aname=C or aname=O or aname=N, one can write aname=CA,N,C,O. For integral value ranges, one can use the colon syntax: instead of rnum>=10 and rnum<=20one can write \c rnum=10:20


The query language can also be used for numeric generic properties (i.e. FloatProp and IntProp), but the syntax is slightly different. To access any generic properties, it needs to be specified that they are generic and at which level they are defined. Therefore, all generic properties start with a g, followed by an a, r or c for atom, residue or chain level respectively.

# set generic properties for atom, residue, chain
atom_handle.SetFloatProp("testpropatom", 5.2)
resid_handle.SetFloatProp("testpropres", 1.1)
chain_handle.SetIntProp("testpropchain", 10)
# query statements

Since generic properties do not need to be defined for all parts of an entity (e.g. it could be specified for one single atomhandle), the query statement will throw an error unless you specify a default value in the query statement which can be done using a ':' character:

# if one or more atoms have no generic properties
# this will throw an error
# you can specify a default value:
# this will run through smoothly and use 1.0 as
# the default value for all atoms that do not
# have the generic property 'testprop'

Using this method, you will be warned if a generic property is not set for all atoms, residues or chains unless you specify a default value. So, be careful when you do.