You are reading the documentation for version 2.5 of OpenStructure. You may also want to read the documentation for:
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.7.1
1.8
1.9
1.10
1.11
2.0
2.1
2.2
2.3
2.3.1
2.4
devel
Queries¶OpenStructure includes a powerful query system that allows you to perform custom selections on a molecular entity in a convenient way. The Basics¶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. Selections are carried out mainly by calling the Select method made available by EntityHandle and arginines = model.Select('rname=ARG')
A simple selection query (called a predicate) consists of a property (here,
rname), a comparison operator (here, =) and an argument (here, ARG). The
return value of a call to the c_betas = model.Select('aname=CB')
As before, c_betas is an instance of an Both the selection statements that have been used so far take strings as their arguments. However, selection properties such as rnum (residue number), take numeric arguments. With numeric arguments it is possible to use identity operators ( != and =). It is also possible to compare them using the >, <, >= and <= operators. For example, the 20 N-terminal residues of a protein can be selected with: n_term = model.Select('rnum<=20')
If you want to supply arguments with special characters they need to be put in quotation marks (‘ or ”). For instance, this is needed for any chain name containing spaces as in: model.Select('cname=" "')
Almost any name can be quoted with Combining predicates¶Selection predicates can be combined with boolean operators. For example , you might want to select all C atoms with crystallographic occupancy higher than 50. These atoms must match the predicate ele=C in addition to the predicate occ>50. In the query language this can be written as: model.Select('ele=C and occ>50')
Compact forms are available for several selection statements. For example, to select all arginines and aspargines, one could use a statement like: arg_and_asn = model.Select('rname=ARG or rname=ASN')
However, this is rather cumbersome as it requires the word rname to be typed twice. Since the only difference between the two parts of the selection is the argument that follows the word rname, the statement can also be written in an abbreviated form: arg_and_asn = model.Select('rname=ARG,ASN')
Another example: to select residues with numbers in the range 130 to 200, one could use the following statement center = model.Select('rnum>=130 and rnum<=200')
or alternatively use the much nicer syntax: center = model.Select('rnum=130:200')
This last statement is completely equivalent to the previous one. This syntax can be used when the selection statement requires a range of integer values within a closed interval. Distance Queries¶The query around_center = model.Select('5 <> {0,0,0}')
selects all chains, residues and atoms that lie with 5 Å to the origin of the reference system ({0,0,0}). The <> operator is called the ‘within’ operator. Instead of a point, the within statements can also be used to return a view containing all chains, residues and atoms within a radius of another selection statement applied to the same entity. Square brackets are used to delimit the inner query statement. around_hem = model.Select('5 <> [rname=HEM]')
model.Select('5 <> [rname=HEM and ele=C] and rname!=HEM')
Bonds and Queries¶When an Whole Residue Queries¶If the parameter MATCH_RESIDUES is passed when the Select method is called,
the resulting More Query Usage¶The high level interface for queries are the Select methods of the
EntityHandle and Queries also offer a second interface: IsAtomSelected(), IsResidueSelected() and IsChainSelected() take an atom, residue or chain as their argument and return true or false, depending on whether the element fulfills the predicates. Generic Properties in Queries¶The query language can also be used for numeric generic properties (i.e. float and int), 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
sel_a = e.Select("gatestpropatom<=10.0")
sel_r = e.Select("grtestpropres=1.0")
sel_c = e.Select("gctestpropchain>5")
Since generic properties do not need to be defined for all parts of an entity
(e.g. it could be specified for one single # if one or more atoms have no generic properties
sel = e.Select("gatestprop=5")
# this will throw an error
# you can specify a default value:
sel = e.Select("gatestprop:1.0=5")
# 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. Available Properties¶The following properties may be used in predicates. The type is given for each property. Properties of Chains¶cname/chain (str) Properties of Residues¶rname (str): rnum (int): rtype (str): Residue type as given by the DSSP code (e.g. “H” for alpha
helix, “E” for extended), “helix” for all helix types, “ext” or “strand” for
all beta sheets or “coil” for any type of coil (see rindex (int): peptide (bool): Whether the residue is nucleotide (bool): Whether the residue is protein (bool): Whether the residue is considered to be
rbfac (float): average B (temperature) factor of residue ligand (bool) Whether the residue is a water (bool) Whether the residue is water. Properties of Atoms¶aname (str): ele (str): occ (float): abfac (float): x (float): y (float): z (float): aindex (int): ishetatm (bool): Whether the atom is a acharge (float): Query API documentation¶In the following, the interface of the query class is described. In general, you will not have to use this interface but will pass the query as string directly.
|
ContentsSearchEnter search terms or a module, class or function name. Previous topicNext topicYou are here |