CHFL_SELECTION¶
-
typedef struct CHFL_SELECTION CHFL_SELECTION¶
An opaque type handling a selection.
CHFL_SELECTIONallow to select atoms in aCHFL_FRAME, from a selection language. The selection language is built by combining basic operations. Each basic operation follows the<selector>[(<variable>)] <operator> <value>structure, where<operator>is a comparison operator in== != < <= > >=.
Here is the full list of functions acting on CHFL_SELECTION:
-
CHFL_SELECTION *chfl_selection(const char *selection)¶
Create a new selection from the given
selectionstring.The caller of this function should free the associated memory using
chfl_free.- Returns:
A pointer to the selection, or NULL in case of error. You can use
chfl_last_errorto learn about the error.
-
CHFL_SELECTION *chfl_selection_copy(const CHFL_SELECTION *selection)¶
Get a copy of a
selection.The copy does not contains any state, and
chfl_selection_evaluatemust be called again before usingchfl_selection_matches.The caller of this function should free the associated memory using
chfl_free.- Returns:
A pointer to the new selection, or NULL in case of error. You can use
chfl_last_errorto learn about the error.
-
chfl_status chfl_selection_size(const CHFL_SELECTION *selection, uint64_t *size)¶
Get the size of a
selectioninsize.The size of a selection is the number of atoms we are selecting together. This value is 1 for the ‘atom’ context, 2 for the ‘pair’ and ‘bond’ context, 3 for the ‘three’ and ‘angles’ contexts and 4 for the ‘four’ and ‘dihedral’ contexts.
- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_selection_string(const CHFL_SELECTION *selection, char *string, uint64_t buffsize)¶
Get the selection string used to create a given
selectionin thestringbuffer.The buffer size must be passed in
buffsize. This function will truncate the selection string to fit in the buffer.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_selection_evaluate(CHFL_SELECTION *selection, const CHFL_FRAME *frame, uint64_t *n_matches)¶
Evaluate a
selectionfor a givenframe, and store the number of matches inn_matches.Use the
chfl_selection_matchesfunction to get the matches for this selection.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
chfl_status chfl_selection_matches(const CHFL_SELECTION *selection, chfl_match matches[], uint64_t n_matches)¶
Get the matches for a
selectionafter a call tochfl_selection_evaluate, inmatches.The size of the
matchesarray must be passed inn_matches.- Returns:
The operation status code. You can use
chfl_last_errorto learn about the error if the status code is notCHFL_SUCCESS.
-
struct chfl_match¶
A
chfl_matchis a set of atomic indexes matching a given selection. The size of a match depends on the associated selection, and can vary from 1 toCHFL_MAX_SELECTION_SIZE.
-
CHFL_MAX_SELECTION_SIZE¶
Maximal size for a selection match.