pydft_qmmm.system.selection_utils

A module containing helper functions for selection query parsing.

pydft_qmmm.system.selection_utils.FAST_SELECTORS

The system attribute name and type indexed by the query attribute name for attributes that are expected to change every step of a simulation.

pydft_qmmm.system.selection_utils.SLOW_SELECTORS

The system attribute name and type indexed by the query attribute name for attributes that are not expected to change every step of a simulation.

pydft_qmmm.system.selection_utils.SELECT_KEYWORDS

The list of other keywords over which the keyword takes precedence and a function applying the keyword indexed by the keyword.

pydft_qmmm.system.selection_utils.FAST_VARIABLES

The system attribute name and a column index indexed by variable name for variables that are expected to change every step of a simulation.

pydft_qmmm.system.selection_utils.SLOW_VARIABLES

The system attribute name and a column index indexed by variable name for variables that are not expected to change every step of a simulation.

pydft_qmmm.system.selection_utils.OPERATORS

The list of other operators over which the operator takes precedence and a function applying the operator indexed by the operator’s symbol.

pydft_qmmm.system.selection_utils.FUNCTIONS

Functions indexed by their possible names in the query.

pydft_qmmm.system.selection_utils.SELECTORS

The system attribute name and type indexed by the query attribute name for all attributes.

pydft_qmmm.system.selection_utils.VARIABLES

The system attribute name and a column index indexed by variable name for all variables.

pydft_qmmm.system.selection_utils.FAST_KEYWORDS

The system attribute name indexed by variable name or query attribute name for variables or selectors that are expected to change every step of a simulation.

pydft_qmmm.system.selection_utils.SLOW_KEYWORDS

The system attribute name indexed by variable name or query attribute name for variables or selectors that are not expected to change every step of a simulation.

pydft_qmmm.system.selection_utils.MATH_KEYWORDS

A set of variable names, operator symbols, and function names.

pydft_qmmm.system.selection_utils.KEYWORDS

A set of selection keywords and math keywords.

Functions

decompose(text)

Decompose an atom selection query into meaningful components.

evaluate(text, system)

Evaluate a part of an atom selection query.

evaluate_math(line, system)

Evaluate strings corresponding to a mathematical expression.

interpret(line, system)

Interpret a line of atom selection query language.

isvalue(text)

Determine if a string is a numerical value.

line_slice(line, start[, low_priority])

Find the slice of a query within parentheses.

pydft_qmmm.system.selection_utils.decompose(text)[source]

Decompose an atom selection query into meaningful components.

Parameters:

text (str) – The atom selection query.

Return type:

list[str]

Returns:

The atom selection query broken into meaningful parts, demarcated by keywords.

pydft_qmmm.system.selection_utils.evaluate(text, system)[source]

Evaluate a part of an atom selection query.

Parameters:
  • text (str) – A single contained statement from an atom selection query.

  • system (System) – The system whose atoms will be selected by evaluating a single query statement.

Return type:

frozenset[int]

Returns:

The set of atom indices selected by the query statement.

pydft_qmmm.system.selection_utils.evaluate_math(line, system)[source]

Evaluate strings corresponding to a mathematical expression.

Parameters:
  • line (list[str]) – The strings to evaluate.

  • system (System) – The system whose attributes will figure into the mathematical evaluation.

Return type:

ndarray[tuple[Any, ...], dtype[float64]]

Returns:

The result of evaluating the mathematical expression in the context of the given system.

pydft_qmmm.system.selection_utils.interpret(line, system)[source]

Interpret a line of atom selection query language.

This has been written to follow VMD selection language.

Parameters:
  • line (list[str]) – The atom selection query, broken into meaningful components.

  • system (System) – The system whose atoms will be selected by interpreting the selection query.

Return type:

frozenset[int]

Returns:

The set of atom indices selected by the query.

pydft_qmmm.system.selection_utils.isvalue(text)[source]

Determine if a string is a numerical value.

Parameters:

text (str) – The string to evaluate.

Return type:

bool

Returns:

Whether or not the text is a numerical value.

pydft_qmmm.system.selection_utils.line_slice(line, start, low_priority=[])[source]

Find the slice of a query within parentheses.

Parameters:
  • line (list[str]) – The atom selection query, broken into meaningful components.

  • start (int) – The index of the line where the statement within parentheses begins.

  • low_priority (list[str], default: []) – Strings which have a lower operator precedence.

Return type:

slice

Returns:

The slice whose start and stop corresponds to the phrase contained by parentheses.