PatternQuery:Language Reference

From WebChem Wiki
Jump to: navigation, search

Contents

Introduction

PatternQuery (PQ) is a user friendly chemical language primarily designed for defining atom patterns in molecules. PQ combines the clarity and brevity of programming languages with the versatility of natural language, aiming for an efficient inclusion of chemical and biochemical knowledge into the definition of patterns. PQ allows definitions based on chemical connectivity and three-dimensional structure at the same time. Additionally, in the case of molecules based on residue chains (such as proteins, nucleic acids, saccharides, etc.), PQ allows the user to include any amount of information regarding the residue level structure directly into the definition of the patternss.

PatternQuery is a subset of the Python programming language. Therefore, if you have experience with it, it should not be a problem to use PQ as well.

  • The language is case sensitive - "filter" is NOT the same as "FiLtEr".

Some of the functions return PatternSeq while other return Pattern.

  • Pattern is a set of atoms.
  • PatternSeq is a sequence of Pattern (the sets of atoms).

When a molecule is queried, say using the expression Rings(5 * ["C"] + ["O"]) a sequences of patterns each containing 6 atoms (5 C and 1 O) is returned. However, some functions such as Filter need to operate on a single pattern (the set of atoms) - not the whole sequences. The query Residues().Filter(lambda r: r.Count(Atoms()) > 10) first finds all residue patterns (PatternSeq) and then passes every single Pattern (set of atoms) to a function that counts the atoms in the pattern and returns True if there is at least 11 of them. This is the reasoning behind these two types.

Basic Query Functions

Basic building blocks of the language - i.e. atoms, residues, and the like.

AminoAcids

AminoAcids() -> Residues
Sequence of all residues with the 20 basic amino acid names.

Options
ChargeType: String = "" - Specify type of the charge. Allowed values: Positive, Negative, Aromatic, Polar, NonPolar.
Examples
AminoAcids()
All amino acids.
AminoAcids(ChargeType = "Polar")
Amino acids with polar charge.

AtomIdRange

AtomIdRange(minId: Integer, maxId: ?Integer) -> Atoms
Sequence of atoms with minId <= atomId <= maxId.

Arguments
minId: Integer - Minimum id.
maxId: ?Integer - Maximum id. If not specified, maxId = minId.
Examples
AtomIdRange(152, 161)
Returns all atoms with id between 152 and 161 inclusive.

AtomIds

AtomIds(ids: Integer+) -> Atoms
Sequence of atoms with specified identifiers.

Arguments
ids: Integer+ - Identifiers.
Examples
AtomIds(1, 2, 3)
Returns atoms with ids 1, 2, 3.

AtomNames

AtomNames(names: String+) -> Atoms
Sequence of atoms with specified names.

Arguments
names: String+ - Allowed names.
Examples
AtomNames("O1","NH1")
Returns all atoms with names O1 or NH1.

Atoms

Atoms(symbols: String*) -> Atoms
Sequence of atoms with specified element symbols. If no symbols are specified, yields all atoms one by one.

Arguments
symbols: String* - Allowed element symbols.
Examples
Atoms("Zn","Ca")
Returns all atoms with element symbol Zn or Ca

Chains

Chains(identifiers: Value*) -> PatternSeq
Splits the structures into chains. If no identifiers are specified, all chains are returned.

Arguments
identifiers: Value* - Chain identifiers.
Examples
Chains()
Returns all chains.
Chains("")
Returns chains without specific identifier.
Chains("A", "B")
Returns chains A and B.

Helices

Helices() -> PatternSeq
Returns all helices. This assumes the information about helices was present in the input structure.

Examples
Helices()
Returns all helices.

HetResidues

HetResidues() -> Residues
Sequence of all residues that contain HET atoms.

Options
NoWaters: Bool = True - Ignore water residues such as HOH.
Examples
HetResidues()
Returns all residues that contain HET atoms (ignores water).
HetResidues(NoWaters=False)
Returns all residues that contain HET atoms (includes water).

ModifiedResidues

ModifiedResidues(parentNames: String*) -> Residues
Sequence of modified residues that originate from the specified name. If no names are specified, yields all modified residues one by one.

Arguments
parentNames: String* - Parent residue names.
Examples
ModifiedResidues("MET")
Returns all residues modified from MET (for example MSE).

Named

Named(patterns: PatternSeq) -> PatternSeq
'Names' the pattern by its lowest atom id.

Arguments
patterns: PatternSeq - Patterns to name.
Examples
Atoms("Zn").Named().AmbientAtoms(7)
When exported, the result files will have names in the format '[parent id]_[pseudorandom number]_[zn atomid]'. If the Named function was not used, the name would be just '[parent id]_[pseudorandom number]'.

NotAminoAcids

NotAminoAcids() -> Residues
Sequence of all residues that are not any of the 20 basic amino acids.

Options
NoWaters: Bool = True - Ignore water residues such as HOH.
Examples
NotAminoAcids()
Returns all residues that are not amino acids.

NotAtomIds

NotAtomIds(ids: Integer+) -> Atoms
Sequence of atoms that do not have specified identifiers.

Arguments
ids: Integer+ - Identifiers.
Examples
NotAtomIds(1, 2, 3)
Returns atoms that do not have id 1, 2, nor 3.

NotAtomNames

NotAtomNames(names: String+) -> Atoms
Sequence of atoms that do not have a specified name.

Arguments
names: String+ - Forbidden names.
Examples
NotAtomNames("O4")
Returns all atoms that are not called O4.

NotAtoms

NotAtoms(symbols: String+) -> Atoms
Sequence of atoms that are not particular elements.

Arguments
symbols: String+ - Forbidden element symbols.
Examples
NotAtoms("O")
Returns all atoms that are not O.

NotResidues

NotResidues(names: Value+) -> Residues
Sequence of residues that are not called by the specified names.

Arguments
names: Value+ - Forbidden residue names.
Examples
NotResidues("THR","CYS")
Returns all residues that are not THR or CYS.

RegularMotifs

RegularMotifs(regex: Value) -> PatternSeq
Identifies regular motifs. The protein is split into individual chains and the residues are sorted by their Sequence Number before the motifs are identified. The query does not check if adjacent residues have consecutive Sequence Numbers. The query works in two modes: Amino and Nucleotide, on amino acids and nucleotides respectively. In the Amino mode, all the derivatives of standard residues are treated as the standard residues, as long as this information is properly annotated in MODRES or _pdbx_struct_mod_residue field. The default mode is 'Amino'

Arguments
regex: Value - Regular expression on one letter abbreviations of amino acids.
Options
Type: String = "Amino" - Determines the type of the query. Allowed values: Amino, Nucleotide.
Examples
RegularMotifs("RGD")
Finds all RGD motifs.
RegularMotifs("ACGTU", Type = 'Nucleotide')
Finds all consecutive occurrences of the ACGTU nucleotides.
RegularMotifs(".HC.").Filter(lambda m: m.IsConnected())
Finds all 4 residue motifs with ?-HIS-CYS-? that are connected.

ResidueIdRange

ResidueIdRange(chain: String, min: Integer, max: ?Integer) -> Residues
Sequence of residues with specific chain and min <= sequence number <= max.

Arguments
chain: String - Chain identifier. Case sensitive (a != A).
min: Integer - Minimum sequence number.
max: ?Integer - Maximum sequence number. If not specified, max = min.
Examples
ResidueIdRange("A", 161, 165)
Returns all residues on chain A with seq. number between 161 and 165 inclusive.

ResidueIds

ResidueIds(ids: String+) -> Residues
Sequence of residues with specific identifiers. If the structure does not contain a residue with the given identifier, it is skipped.

Arguments
ids: String+ - One or more identifiers in the format 'NUMBER [CHAIN] [i:INSERTIONCODE]' (parameters in [] are optional, for example '175 i:12' or '143 B'). Case sensitive (a != A).
Examples
ResidueIds("132 A", "178 A")
Returns residues A 123 and A 178 (provided the input structure contains them).

Residues

Residues(names: String*) -> Residues
Sequence of residues with specified names. If no names are specified, yields all residues one by one.

Arguments
names: String* - Allowed residue names.
Examples
Residues("HIS", "CYS")
Returns all HIS or CYS residues.

RingAtoms

RingAtoms(atom: Atoms, ring: ?Rings) -> Atoms
Returns all rings atoms.

Arguments
atom: Atoms - Atom types.
ring: ?Rings - Specific ring.
Examples
RingAtoms(Atoms("C"), Rings(4 * ["C"] + ["O"]))
Returns all C atoms on a ring with 4C and O.

Rings

Rings(atoms: Value*) -> Rings
Sequence of rings with particular atoms. If no atoms are specified, yields all rings (cycles) one by one. The order of atoms matters.

Arguments
atoms: Value* - Ring atoms.
Examples
Rings()
Returns all rings.
Rings(5 * ["C"] + ["O"])
Returns all rings with 5C and 1O atoms.
Rings(["C", "C", "N", "C", "N"])
Returns all rings with C-C-N-C-N atoms.
Or(Rings(["C", "C", "N", "C", "N"]), Rings(["C", "C", "C", "N", "N"]))
Returns all rings with C-C-N-C-N or C-C-C-N-N atoms.

Sheets

Sheets() -> PatternSeq
Returns all sheets. This assumes the information about sheets was present in the input structure.

Examples
Sheets()
Returns all sheets.


Advanced Query Functions

Advanced building blocks of the language.

Flatten

Flatten(patterns: PatternSeq, selector: Pattern->PatternSeq) -> PatternSeq
Converts a sequence of sequence of patterns into a single 'flat' sequence.

Arguments
patterns: PatternSeq - Patterns to project.
selector: Pattern->PatternSeq - The selector.
Examples
Residues("HIS").Flatten(lambda m: m.Find(Atoms("C")))
Returns all C atoms on HIS residues.

Inside

Inside(patterns: PatternSeq, where: PatternSeq) -> PatternSeq
Finds patterns within another pattern. Equivalent to where.Flatten(lambda m: m.Find(patterns))

Arguments
patterns: PatternSeq - Patterns to find.
where: PatternSeq - Where to find them.
Examples
Atoms("C").Inside(Residues("HIS"))
Returns all C atoms on HIS residues.

Or

Or(patterns: PatternSeq+) -> PatternSeq
Merges several pattern sequences into one.

Arguments
patterns: PatternSeq+ - Patterns to merge.
Examples
Or(Atoms("Zn").ConnectedResidues(1), Rings())
Finds all zincs and their connected residues or rings.

ToAtoms

ToAtoms(patterns: PatternSeq) -> PatternSeq
Collects all 'inner' patterns and yields all unique atoms one by one.

Arguments
patterns: PatternSeq - Patterns to split.
Examples
Residues("HIS").ToAtoms()
Returns all atoms on HIS residues one by one.

ToResidues

ToResidues(patterns: PatternSeq) -> PatternSeq
Collects all 'inner' patterns and yields all unique residues one by one. The residues contain only the atoms that have been yielded by the inner query.

Arguments
patterns: PatternSeq - Patterns to split.
Examples
Atoms("C").ToResidues()
Returns all C atoms grouped by residues.

Union

Union(patterns: PatternSeq) -> PatternSeq
Collects all 'inner' patterns and yields one created from their unique atoms.

Arguments
patterns: PatternSeq - Patterns to merge.
Examples
Rings().Union()
Creates a single pattern that contains all rings.


Filter Functions

Functions useful for filtering patterns.

Contains

Contains(where: Pattern, what: PatternSeq) -> Bool
Checks if a pattern is contained within another one. Equivalent to where.Count(what) > 0.

Arguments
where: Pattern - Where to look.
what: PatternSeq - What to find.
Examples
HetResidues().Filter(lambda m: m.Contains(Rings(5*['C']+['O'])).Not())
Returns all HET residues that do not contain a 5CO ring.

Count

Count(where: Pattern, what: PatternSeq) -> Integer
Counts all occurrences of pattern 'what' in pattern 'where'.

Arguments
where: Pattern - Where to count it.
what: PatternSeq - What pattern to count.
Examples
m.Count(Residues("HIS"))
Returns the count of HIS residues in the pattern m. Where m is a Pattern (for example when using the Filter function or returned by the ToPattern() function). This example will not work directly and is here to illustrate a concept.
Atoms("Zn").ConnectedResidues(1).Filter(lambda m: m.Count(Residues("HIS")) == 2)
Patterns with Zn atoms and its connected residues with exactly 2 HIS residues.

ExecuteIf

ExecuteIf(query: PatternSeq, condition: Pattern->Bool) -> PatternSeq
Executes a query only if the condition is met. Otherwise, return an empty sequence of patterns.

Arguments
query: PatternSeq - Query to execute.
condition: Pattern->Bool - Condition that must be satisfied for the parent structure/pattern.
Examples
Residues().ExecuteIf(lambda p: p.Resolution() <= 2.4)
Returns residues in structures that have resolution lower than 2.4ang.
AminoAcids().ExecuteIf(lambda p: p.Count(Atoms('Fe')) > 3)
Returns all amino acids in structures that have at least 3 Fe atoms.

Filter

Filter(patterns: PatternSeq, filter: Pattern->Bool) -> PatternSeq
Filters a sequence of patterns with a given predicate.

Arguments
patterns: PatternSeq - Patterns to filter.
filter: Pattern->Bool - Filter predicate.
Examples
Residues().Filter(lambda m: m.Count(Atoms("C")) >= 3)
Returns all residues that contain at least 3 C atoms.

IsConnected

IsConnected(pattern: Pattern) -> Bool
Checks if a particular pattern is a connected graph.

Arguments
pattern: Pattern - A pattern to test.
Examples
Atoms("Zn").AmbientResidues(3).Filter(lambda m: m.IsConnected())
Finds all patterns with a Zn and residues within 3 ang, where all the ambient residues are connected to the central atom.

IsConnectedTo

IsConnectedTo(where: Pattern, patterns: PatternSeq) -> Bool
Checks if a particular pattern is connected to any other specified pattern. The patterns must have empty intersection for this function to return true.

Arguments
where: Pattern - A pattern to test.
patterns: PatternSeq - Pattern sequence to test against.
Examples
Atoms().Filter(lambda a: a.IsConnectedTo(Rings()))
Finds all atoms that are connected to a ring they do not belong to.

IsNotConnectedTo

IsNotConnectedTo(what: Pattern, patterns: PatternSeq) -> Bool
Checks if a particular pattern is not connected to any other specified pattern. The patterns must have empty intersection for this function to return true.

Arguments
what: Pattern - A pattern to test.
patterns: PatternSeq - Pattern sequence to test against.
Examples
Residues().Filter(lambda r: r.IsNotConnectedTo(Atoms("Ca")))
Finds all residues that are not connected to Ca atoms. The residue itself can still contain Ca atoms.

NearestDistanceTo

NearestDistanceTo(where: Pattern, patterns: PatternSeq) -> Real
Finds the distance to a particular pattern.

Arguments
where: Pattern - A pattern to test.
patterns: PatternSeq - Pattern sequence to test against.
Examples
Atoms().Filter(lambda m: m.NearestDistanceTo(Residues("ASP")) >= 5)
Finds all atoms that are at least 5 (angstroms) away from any ASP residue.

SeqCount

SeqCount(what: PatternSeq) -> Integer
Counts the length of a sequence of motifs.

Arguments
what: PatternSeq - What pattern sequence to count.
Examples
Atoms("Zn").AmbientResidues(3).Filter(lambda m: m.Find(Residues("HIS")).SeqCount() > 1)
Returns a sequence of patterns with Zn atom and residues within 3ang if the pattern contains at least 2 HIS residues.


Topology Functions

Functions that rely on the topology of patterns.

ConnectedAtoms

ConnectedAtoms(pattern: PatternSeq, n: Integer) -> PatternSeq
Surrounds the inner pattern by n layers of atoms.

Arguments
pattern: PatternSeq - Basic pattern.
n: Integer - Number of atom layers to connect.
Options
YieldNamedDuplicates: Bool = False - Yield duplicate patterns if they have a different name.
Examples
Residues("MAN").ConnectedAtoms(2)
Finds all MAN residues and then adds two connected levels of atoms to them.

ConnectedResidues

ConnectedResidues(pattern: PatternSeq, n: Integer) -> PatternSeq
Surrounds the inner pattern by n layers of residues.

Arguments
pattern: PatternSeq - Basic pattern.
n: Integer - Number of residue layers to connect.
Options
YieldNamedDuplicates: Bool = False - Yield duplicate patterns if they have a different name.
Examples
Atoms("Zn").ConnectedResidues(1)
Finds all Zn atoms and adds all residues that are connected to them.

Path

Path(patterns: PatternSeq+) -> PatternSeq
Creates a new pattern from 'connected' parts.

Arguments
patterns: PatternSeq+ - Patterns to path.
Examples
Path(Atoms("O"), Atoms("C"), Atoms("O"))
Finds patterns with two O and one C atoms where the C atoms is connected to the O ones.

Star

Star(center: PatternSeq, patterns: PatternSeq+) -> PatternSeq
Creates a new pattern from a central one and connected parts.

Arguments
center: PatternSeq - Center pattern.
patterns: PatternSeq+ - Patterns to chain.
Examples
Star(Atoms("C"), Atoms("O"), Atoms("O"))
Finds patterns with two O atoms and one C atom in the center.
Atoms("C").Star(Atoms("O"), Atoms("O"))
Finds patterns with two O atoms and one C atom in the center.


Geometry Functions

Functions that rely on the geometry of patterns.

AmbientAtoms

AmbientAtoms(pattern: PatternSeq, r: Number) -> PatternSeq
Surrounds the inner pattern by atoms that within the given radius from the inner pattern.

Arguments
pattern: PatternSeq - Basic pattern.
r: Number - Radius.
Options
ExcludeBase: Bool = False - Exclude the central original pattern.
NoWaters: Bool = True - Ignore water residues such as HOH.
YieldNamedDuplicates: Bool = False - Yield duplicate patterns if they have a different name.
Examples
Atoms("Fe").AmbientAtoms(4)
Finds Fe atoms and all atoms within 4 (angstroms) from each of them.

AmbientResidues

AmbientResidues(pattern: PatternSeq, r: Number) -> PatternSeq
Surrounds the inner pattern by residues that have at least one atom within the given radius from the inner pattern.

Arguments
pattern: PatternSeq - Basic pattern.
r: Number - Radius.
Options
ExcludeBase: Bool = False - Exclude the central original pattern.
NoWaters: Bool = True - Ignore water residues such as HOH.
YieldNamedDuplicates: Bool = False - Yield duplicate patterns if they have a different name.
Examples
Rings(6 * ["C"]).AmbientResidues(4)
Finds rings with 6C atoms and all residues within 4 (angstroms) from each of them.

Cluster

Cluster(r: Number, patterns: PatternSeq+) -> PatternSeq
Clusters all patterns that are pairwise closer than r (angstroms).

Arguments
r: Number - Maximum distance between two patterns in the cluster.
patterns: PatternSeq+ - Patterns to cluster.
Examples
Cluster(4, Atoms("Ca"), Rings(5 * ["C"] + ["O"]))
Finds all instance of one or more rings with 5C and O atoms and one or more Ca atoms that are closer than 4 (angstroms).

Filled

Filled(pattern: PatternSeq) -> PatternSeq
Adds all atoms that fall within the circumsphere (with radius multiplied by the factor) of the basic pattern.

Arguments
pattern: PatternSeq - Basic pattern.
Options
NoWaters: Bool = True - Ignore water residues such as HOH.
RadiusFactor: Number = 0.75 - Circumsphere radius factor.
Examples
Cluster(4, Residues("HIS")).Filled(RadiusFactor = 0.75)
Finds clusters of HIS residues and all atoms within the circumsphere.

Near

Near(r: Number, patterns: PatternSeq+) -> PatternSeq
Clusters all patterns that are pairwise closer than r (angstroms) and checks if the "counts" match.

Arguments
r: Number - Maximum distance between two sub-patterns in the pattern.
patterns: PatternSeq+ - Patterns to 'cluster'.
Examples
Near(4, Atoms("Ca"), Atoms("Ca"), Rings(5 * ["C"] + ["O"]))
Finds all instance of a single ring with 5C and O atoms and two Ca atoms that are closer than 4 (angstroms).

Spherify

Spherify(pattern: PatternSeq, r: Number) -> PatternSeq
Identifies the geometrical center of the base pattern and then includes all atoms within the specified radius.

Arguments
pattern: PatternSeq - Basic pattern.
r: Number - Radius.
Options
ExcludeBase: Bool = False - Exclude the central original pattern.
NoWaters: Bool = True - Ignore water residues such as HOH.
YieldNamedDuplicates: Bool = False - Yield duplicate patterns if they have a different name.
Examples

Rings(6 * ["C"]).Spherify(5)
Finds benzene moiety, computes centroid of each pattern, and includes all atoms within 5 angstroms from it.

Meta-data Functions

Functions dealing with meta-data about structures such as release date or authors.

Authors

Authors(pattern: Pattern) -> String
Returns authors of the parent structure separated by a semicolon. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.

ECNumbers

ECNumbers(pattern: Pattern) -> String
Returns Enzymatic Commission numbers assigned to enzymes in the parent structure separated by a semicolon. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.

EntitySources

EntitySources(pattern: Pattern) -> String
Returns entity sources of the parent structure separated by a semicolon. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.

ExperimentMethod

ExperimentMethod(pattern: Pattern) -> String
Get the experiment method. The value is always an upper-case string. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.
Examples
Residues().ExecuteIf(lambda p: p.ExperimentMethod() == "INFRARED SPECTROSCOPY")
Returns residues in structures that satisfy the property.

HasAllAuthors

HasAllAuthors(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains all given authors. The comparison is case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAllAuthors("Holmes", "Watson"))
Returns residues in structures that contain all given properties.

HasAllECNumbers

HasAllECNumbers(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains all given Enzymatic Commission numbers. It is possible to enter just a number prefix without the '.'. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAllECNumbers("3.2.1.18", "3.3"))
Returns residues in structures that contain all given properties.

HasAllEntitySources

HasAllEntitySources(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains all given entity sources. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAllEntitySources("GMO", "Natural", "Synthetic"))
Returns residues in structures that contain all given properties.

HasAllHostOrganismGenus

HasAllHostOrganismGenus(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains all given host organism identifiers. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAllHostOrganismGenus("X", "Y"))
Returns residues in structures that contain all given properties.

HasAllHostOrganismIds

HasAllHostOrganismIds(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains all given host organism identifiers. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAllHostOrganismIds("7108", "11244"))
Returns residues in structures that contain all given properties.

HasAllHostOrganisms

HasAllHostOrganisms(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains all given host organism names. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAllHostOrganisms("Spodoptera frugiperda", "Mus musculus"))
Returns residues in structures that contain all given properties.

HasAllKeywords

HasAllKeywords(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains all given keywords. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAllKeywords("membrane", "glycoprotein"))
Returns residues in structures that contain all given properties.

HasAllOriginOrganismGenus

HasAllOriginOrganismGenus(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains all given origin organism identifiers. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAllOriginOrganismGenus("X", "Y"))
Returns residues in structures that contain all given properties.

HasAllOriginOrganismIds

HasAllOriginOrganismIds(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains all given origin organism identifiers. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAllOriginOrganismIds("121791", "10090"))
Returns residues in structures that contain all given properties.

HasAllOriginOrganisms

HasAllOriginOrganisms(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains all given origin organism names. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAllOriginOrganisms("Nipah virus", "Mus musculus"))
Returns residues in structures that contain all given properties.

HasAnyAuthor

HasAnyAuthor(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains any of the given authors. The comparison is case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAnyAuthor("Holmes", "Watson"))
Returns residues in structures that contain all given properties.

HasAnyECNumber

HasAnyECNumber(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains any of the given Enzymatic Commission number. It is possible to enter just a number prefix without the '.'s. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAnyECNumber("3.2.1.19", "3.3"))
Returns residues in structures that contain all given properties.

HasAnyEntitySources

HasAnyEntitySources(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains any of the given entity sources. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAnyEntitySources("GMO", "Natural", "Synthetic"))
Returns residues in structures that contain all given properties.

HasAnyHostOrganism

HasAnyHostOrganism(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains any of the given host organism names. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAnyHostOrganism("Spodoptera frugiperda", "Mus musculus"))
Returns residues in structures that contain all given properties.

HasAnyHostOrganismGenus

HasAnyHostOrganismGenus(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains any of the given host organism identifierss. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAnyHostOrganismGenus("X", "Y"))
Returns residues in structures that contain all given properties.

HasAnyHostOrganismId

HasAnyHostOrganismId(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains any of the given host organism identifierss. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAnyHostOrganismId("7108", "11244"))
Returns residues in structures that contain all given properties.

HasAnyKeyword

HasAnyKeyword(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains any of the given keywords. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAnyKeyword("membrane", "glycoprotein"))
Returns residues in structures that contain all given properties.

HasAnyOriginOrganism

HasAnyOriginOrganism(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains any of the given origin organism names. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAnyOriginOrganism("Nipah virus", "Mus musculus"))
Returns residues in structures that contain all given properties.

HasAnyOriginOrganismGenus

HasAnyOriginOrganismGenus(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains any of the given origin organism identifierss. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAnyOriginOrganismGenus("X", "Y"))
Returns residues in structures that contain all given properties.

HasAnyOriginOrganismId

HasAnyOriginOrganismId(pattern: Pattern, properties: String+) -> Bool
Determines if the parent structure contains any of the given origin organism identifierss. The comparison is not case sensitive.

Arguments
pattern: Pattern - Pattern.
properties: String+ - Properties.
Examples
Residues().ExecuteIf(lambda p: p.HasAnyOriginOrganismId("121791", "10090"))
Returns residues in structures that contain all given properties.

HostOrganismGenus

HostOrganismGenus(pattern: Pattern) -> String
Returns host organism identifiers of the parent structure separated by a semicolon. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.

HostOrganismIds

HostOrganismIds(pattern: Pattern) -> String
Returns host organism identifiers of the parent structure separated by a semicolon. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.

HostOrganisms

HostOrganisms(pattern: Pattern) -> String
Returns host organism names of the parent structure separated by a semicolon. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.

Keywords

Keywords(pattern: Pattern) -> String
Returns keywords of the parent structure separated by a semicolon. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.

LatestRevisionDate

LatestRevisionDate(pattern: Pattern) -> Value
Get the latest revision date of the parent structure. The value has to be compared to the DateTime(year, month, day) object. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.
Examples
Residues().ExecuteIf(lambda p: p.LatestRevisionDate() >= DateTime(2008, 1, 1))
Returns residues in structures that satisfy the property.

LatestRevisionYear

LatestRevisionYear(pattern: Pattern) -> Integer
Get the latest revision year of the parent structure. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.
Examples
Residues().ExecuteIf(lambda p: p.LatestRevisionYear() == 2006)
Returns residues in structures that satisfy the property.

OriginOrganismGenus

OriginOrganismGenus(pattern: Pattern) -> String
Returns origin organism identifiers of the parent structure separated by a semicolon. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.

OriginOrganismIds

OriginOrganismIds(pattern: Pattern) -> String
Returns origin organism identifiers of the parent structure separated by a semicolon. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.

OriginOrganisms

OriginOrganisms(pattern: Pattern) -> String
Returns origin organism names of the parent structure separated by a semicolon. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.

PolymerType

PolymerType(pattern: Pattern) -> String
Get the polymer type of the structure. Possible values are: NotAssigned, Protein, DNA, RNA, ProteinDNA, ProteinRNA, NucleicAcids, Mixture, Sugar, Other. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.
Examples
Residues().ExecuteIf(lambda p: p.PolymerType() == "ProteinDNA")
Returns residues in structures that satisfy the property.

ProteinStoichiometry

ProteinStoichiometry(pattern: Pattern) -> String
Get the protein stoichiometry of the parent structure. Possible values are: NotAssigned, Monomer, Homomer, Heteromer. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.
Examples
Residues().ExecuteIf(lambda p: p.ProteinStoichiometry() == "Heteromer")
Returns residues in structures that satisfy the property.

ProteinStoichiometryString

ProteinStoichiometryString(pattern: Pattern) -> String
Get the protein stoichiometry string of the parent structure. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.

ReleaseDate

ReleaseDate(pattern: Pattern) -> Value
Get the release date of the parent structure. The value has to be compared to the DateTime(year, month, day) object. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.
Examples
Residues().ExecuteIf(lambda p: p.ReleaseDate() >= DateTime(2008, 1, 1))
Returns residues in structures that satisfy the property.

ReleaseYear

ReleaseYear(pattern: Pattern) -> Integer
Get the release year of the parent structure. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.
Examples
Residues().ExecuteIf(lambda p: p.ReleaseYear() == 2006)
Returns residues in structures that satisfy the property.

Resolution

Resolution(pattern: Pattern) -> Real
Get the resolution in angstroms of the parent structure. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.
Examples
Residues().ExecuteIf(lambda p: p.Resolution() <= 2.4)
Returns residues in structures that satisfy the property.

Weight

Weight(pattern: Pattern) -> Real
Get the weight of the molecule in kDa. If the value is not available, null is returned.

Arguments
pattern: Pattern - Pattern.
Examples
Residues().ExecuteIf(lambda p: p.Weight() > 100000.0)
Returns residues in structures that satisfy the property.


Miscellaneous Functions

Various useful functions. These function often require a special setup (i.e. only useful in Scripting window or in specific applications).

AminoSequenceString

AminoSequenceString(pattern: Pattern) -> String
Returns a string of single-letter amino acids contained in the pattern.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Arguments
pattern: Pattern - Pattern to convert.
Examples
Pattern("1tqn_12").AminoSequenceString()
Returns a string representing amino acids in the pattern '1tqn_12'.
RegularMotifs(Pattern("1tqn_12").AminoSequenceString())
Returns all regular patterns that correspond to the AMK sequence in 1tqn_12.

AtomProperty

AtomProperty(atomPattern: Pattern, name: String) -> ?
If the property exists and the pattern consists of a single atom, returns the property. Otherwise, returns Nothing.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Arguments
atomPattern: Pattern - Single atom pattern.
name: String - Property name.
Examples
a.AtomProperty("charge")
Gets the 'charge' property of the atom a. Where a is a single atom Pattern. This example will not work directly.
Atoms().Filter(lambda a: a.AtomProperty("charge") >= 2)
All atoms with the charge property greater or equal to 2. This example will only work in cases where a suitable property is defined. For example in Scripting window in the Charges app.

AtomSimilarity

AtomSimilarity(a: Pattern, b: Pattern) -> Real
Computes Jaccard/Tanimoto coefficient on atoms (element symbols) of both structures.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Arguments
a: Pattern - First pattern.
b: Pattern - Second pattern.
Examples
AtomSimilarity(Current(),Pattern("1tqn_12"))
Computes the atom similarity between the current pattern and 1tqn_12. This example can be used in SiteBinder to create a descriptor (assuming a structure with id '1tqn_12' is loaded).

CommonAtoms

CommonAtoms(modelId: String) -> PatternSeq
Returns a single pattern with atoms common with the model. Properties checked: atom id, element symbol, chain, residue number. This query is useful for example for atom selection in SiteBinder.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Arguments
modelId: String - Id of the model.
Examples
CommonAtoms("1tqn_12")
Returns a pattern formed by atoms common with the '1tqn_12' structure.

CSA

CSA() -> PatternSeq
Entries from Catalytic Site Atlas represented as patterns. Works only if used from the command line version of Queries and property configured.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Examples
CSA()
All CSA sites for the given structure. This example will only work if used from the command line version of Queries and property configured.

Current

Current() -> Pattern
A variable that is assigned by the application environment.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Examples
AtomSimilarity(Current(), Pattern("model"))
Returns the atom similarity of the current pattern and the model. This example will work for example when defining a structure descriptor in SiteBinder and there is a structure with id 'model' loaded.

Descriptor

Descriptor(pattern: Pattern, name: String) -> ?
Returns the descriptor. If the descriptor does not exist, 'null' is returned.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Arguments
pattern: Pattern - Pattern that represents entire structure.
name: String - Descriptor name.
Examples
Current().Descriptor("similarity") >= 0.75
Returns True if 'similarity' descriptor of the current pattern is at least 0.75. This example will work for example in SiteBinder's structure selection if the 'similarity' descriptor has been previously defined.

DynamicInvoke

DynamicInvoke(value: Value, name: String, isProperty: Bool, args: Value) -> Value
Dynamically invoke a member. (internal)
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Arguments
value: Value - InnerQuery.
name: String - Member name.
isProperty: Bool - Is this a property.
args: Value - Array of arguments.

Find

Find(source: Pattern, patterns: PatternSeq) -> PatternSeq
Converts the source pattern to a structure and finds patterns within it.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Arguments
source: Pattern - Where to look.
patterns: PatternSeq - Patterns to find.
Examples
AtomSimilarity(Current().Find(NotAtoms("N")).ToPattern(), Pattern("model").Find(NotAtoms("N")).ToPattern())
Computes the atom similarity of the 'current' and 'model' patterns, but ignores N atoms. This example can be used in SiteBinder to create a descriptor (assuming a structure with id 'model' is loaded).

GroupedAtoms

GroupedAtoms(symbols: String*) -> PatternSeq
Groups atoms using the element symbol and then returns each group as a single pattern.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Arguments
symbols: String* - Allowed element symbols.
Examples
GroupedAtoms()
Returns groups of all atom types. For example if the input has atoms 5xC-1xO, patterns with 5xC and 1xO atoms are returned.
GroupedAtoms('C', 'O')
Returns groups of all atom types. For example if the input has atoms 5xC-1xO-6xH, patterns with 5xC and 1xO atoms are returned (but the H atoms are ignored).

Pattern

Pattern(structureName: String) -> Pattern
Returns a structure represented as a pattern.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Arguments
structureName: String - Name of a structure.
Examples
Pattern("1tqn_12")
Returns the structure '1tqn_12' represented as a pattern. Usable in defining descriptors or in Scripting window (using MQ.Execute).

ResidueSimilarity

ResidueSimilarity(a: Pattern, b: Pattern) -> Real
Computes Jaccard/Tanimoto coefficient on residue names of both structures.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Arguments
a: Pattern - First pattern.
b: Pattern - Second pattern.
Examples
ResidueSimilarity(Current(), Pattern("1tqn_12"))
Computes the residue similarity between the current pattern and '1tqn_12'. This example can be used in SiteBinder to create a descriptor (assuming a structure with id '1tqn_12' is loaded).

ToPattern

ToPattern(patterns: PatternSeq) -> Pattern
Converts a sequence of Patterns (AtomSetSeq) to a single Pattern by merging all atoms into a single atom set. The Pattern type is required by some function such as AtomSimilarity.
Note: This function cannot be used directly to query patterns from MotiveExplorer or Queries service.

Arguments
patterns: PatternSeq - Patterns to convert.
Examples
Residues("HIS").ToPattern()
Converts a sequence of HIS residue Patterns to a single Pattern.
AtomSimilarity(Current().Find(NotAtoms("N")).ToPattern(), Pattern("model").Find(NotAtoms("N")).ToPattern())
Computes the atom similarity of the 'current' and 'model' patterns, but ignores N atoms.


Value Functions

Functions such as addition or comparison of numbers.

Abs

Abs(x: Number) -> Number
Computes the 'Abs' function of the argument.

Arguments
x: Number - Argument.
Examples
Abs(x)
Evaluates the expression.

Divide (/)

Divide(x: Number, y: Number) -> Number
Computes the 'Divide' function of the values.

Arguments
x: Number - Left argument.
y: Number - Right argument.
Examples
x / y
Evaluates the expression.

Equal (==)

Equal(x: Value, y: Value) -> Bool
Determines the 'Equal' relation between two values.

Arguments
x: Value - Left argument.
y: Value - Right argument.
Examples
x == y
Evaluates to True or False based on the value of x and y.

Greater (>)

Greater(x: Number, y: Number) -> Bool
Determines the 'Greater' relation between two values.

Arguments
x: Number - Left argument.
y: Number - Right argument.
Examples
x > y
Evaluates to True or False based on the value of x and y.

GreaterEqual (>=)

GreaterEqual(x: Number, y: Number) -> Bool
Determines the 'GreaterEqual' relation between two values.

Arguments
x: Number - Left argument.
y: Number - Right argument.
Examples
x >= y
Evaluates to True or False based on the value of x and y.

Less (<)

Less(x: Number, y: Number) -> Bool
Determines the 'Less' relation between two values.

Arguments
x: Number - Left argument.
y: Number - Right argument.
Examples
x < y
Evaluates to True or False based on the value of x and y.

LessEqual (<=)

LessEqual(x: Number, y: Number) -> Bool
Determines the 'LessEqual' relation between two values.

Arguments
x: Number - Left argument.
y: Number - Right argument.
Examples
x <= y
Evaluates to True or False based on the value of x and y.

LogicalAnd (&)

LogicalAnd(xs: Bool+) -> Bool
Computes 'LogicalAnd' of the input values.

Arguments
xs: Bool+ - Arguments.
Examples
x & y
Evaluates to True or False based on the values of x and y.

LogicalNot (Not)

LogicalNot(x: Bool) -> Bool
Computes 'LogicalNot' of the input value. This function can be called using the shorthand 'Not'.

Arguments
x: Bool - Argument.
Examples
LogicalNot(x)
Evaluates to True or False based on the value of x.
x.Not()
Evaluates to True or False based on the value of x.

LogicalOr (|)

LogicalOr(xs: Bool+) -> Bool
Computes 'LogicalOr' of the input values.

Arguments
xs: Bool+ - Arguments.
Examples
x | y
Evaluates to True or False based on the values of x and y.

LogicalXor (Xor)

LogicalXor(xs: Bool+) -> Bool
Computes 'LogicalXor' of the input values. This function can be called using the shorthand 'Xor'.

Arguments
xs: Bool+ - Arguments.
Examples
LogicalXor(x, y)
Evaluates to True or False based on the values of x and y.
Xor(x, y)
Evaluates to True or False based on the values of x and y.

Minus (-)

Minus(x: Number) -> Number
Computes the arithmetic negation of the argument.

Arguments
x: Number - Argument.
Examples
-x
Arithmetic negation of x.

NotEqual (!=)

NotEqual(x: Value, y: Value) -> Bool
Determines the 'NotEqual' relation between two values.

Arguments
x: Value - Left argument.
y: Value - Right argument.
Examples
x != y
Evaluates to True or False based on the value of x and y.

Plus (+)

Plus(x: Number, y: Number) -> Number
Computes the 'Plus' function of the values.

Arguments
x: Number - Left argument.
y: Number - Right argument.
Examples
x + y
Evaluates the expression.

Power (^)

Power(x: Number, y: Number) -> Number
Computes the 'Power' function of the values.

Arguments
x: Number - Left argument.
y: Number - Right argument.
Examples
x ^ y
Evaluates the expression.

Subtract (-)

Subtract(x: Number, y: Number) -> Number
Computes the 'Subtract' function of the values.

Arguments
x: Number - Left argument.
y: Number - Right argument.
Examples
x - y
Evaluates the expression.

Times (*)

Times(x: Number, y: Number) -> Number
Computes the 'Times' function of the values.

Arguments
x: Number - Left argument.
y: Number - Right argument.
Examples
x * y
Evaluates the expression.