File: selection.h

package info (click to toggle)
gromacs 4.5.5-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 79,700 kB
  • sloc: asm: 789,508; ansic: 424,578; fortran: 94,172; sh: 10,808; makefile: 2,170; cpp: 1,169; csh: 708; perl: 687; python: 264
file content (195 lines) | stat: -rw-r--r-- 7,450 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
 *
 *                This source code is part of
 *
 *                 G   R   O   M   A   C   S
 *
 *          GROningen MAchine for Chemical Simulations
 *
 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
 * Copyright (c) 2001-2009, The GROMACS development team,
 * check out http://www.gromacs.org for more information.

 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * If you want to redistribute modifications, please consider that
 * scientific software is very special. Version control is crucial -
 * bugs must be traceable. We will be happy to consider code for
 * inclusion in the official distribution, but derived work must not
 * be called official GROMACS. Details are found in the README & COPYING
 * files - if they are missing, get the official version at www.gromacs.org.
 *
 * To help us fund GROMACS development, we humbly ask that you cite
 * the papers on the package - you can find them in the top README file.
 *
 * For more info, check our website at http://www.gromacs.org
 */
/*! \file
 * \brief API for handling selection (the \c gmx_ana_selection_t structure and related functions).
 *
 * There should be no need to use the data structures or call the
 * functions in this file directly unless using the selection routines outside
 * the main trajectory analysis API.
 */
#ifndef SELECTION_H
#define SELECTION_H

#include "position.h"
#include "indexutil.h"

#ifdef __cplusplus
extern "C"
{
#endif

/** Information for a collection of selections. */
typedef struct gmx_ana_selcollection_t gmx_ana_selcollection_t;

struct gmx_ana_poscalc_coll_t;

/** Defines the type of covered fraction. */
typedef enum
{
    CFRAC_NONE,         /**< No covered fraction (everything covered). */
    CFRAC_SOLIDANGLE    /**< Fraction of a solid (3D) angle covered. */
} e_coverfrac_t;

/*! \brief
 * Describes a single selection.
 */
typedef struct gmx_ana_selection_t
{
    /** Name of the selection. */
    char                   *name;
    /** The actual selection string. */
    char                   *selstr;
    /** Selected positions. */
    gmx_ana_pos_t           p;
    /** Masses associated with the positions. */
    real                   *m;
    /** Charges associated with the positions. */
    real                   *q;
    /** Pointer to the index group that holds the selected atoms. */
    struct gmx_ana_index_t *g;
    /** TRUE if the value can change as a function of time. */
    gmx_bool                    bDynamic;
    /** Type of the covered fraction. */
    e_coverfrac_t           cfractype;
    /** TRUE if the covered fraction depends on the frame. */
    gmx_bool                    bCFracDyn;
    /** Covered fraction of the selection for the current frame. */
    real                    cfrac;
    /** The average covered fraction (over the trajectory). */
    real                    avecfrac;

    /*! \brief
     * Pointer to the root of the selection element tree (internal use only).
     *
     * \internal
     * This field is NULL if the selection has been loaded directly from an
     * index file.
     */
    struct t_selelem       *selelem;
    /** Original masses of all possible positions (internal use only). */
    real                   *orgm;
    /** Original charges of all possible positions (internal use only). */
    real                   *orgq;
} gmx_ana_selection_t;

/** Frees the memory allocated for a selection. */
void
gmx_ana_selection_free(gmx_ana_selection_t *sel);
/** Returns the name of a selection. */
char *
gmx_ana_selection_name(gmx_ana_selection_t *sel);
/** Prints out the selection information. */
void
gmx_ana_selection_print_info(gmx_ana_selection_t *sel);
/** Initializes the information for covered fraction. */
gmx_bool
gmx_ana_selection_init_coverfrac(gmx_ana_selection_t *sel, e_coverfrac_t type);

/** Creates a new empty selection collection. */
int
gmx_ana_selcollection_create(gmx_ana_selcollection_t **sc,
                             struct gmx_ana_poscalc_coll_t *pcc);
/** Frees the memory allocated for a selection collection. */
void
gmx_ana_selcollection_free(gmx_ana_selcollection_t *sc);
/** Sets the default reference position handling for a selection collection. */
void
gmx_ana_selcollection_set_refpostype(gmx_ana_selcollection_t *sc, const char *type);
/** Sets the default output position handling for a selection collection. */
void
gmx_ana_selcollection_set_outpostype(gmx_ana_selcollection_t *sc,
                                     const char *type, gmx_bool bMaskOnly);
/** Request evaluation of velocities for selections. */
void
gmx_ana_selcollection_set_veloutput(gmx_ana_selcollection_t *sc,
                                    gmx_bool bVelOut);
/** Request evaluation of forces for selections. */
void
gmx_ana_selcollection_set_forceoutput(gmx_ana_selcollection_t *sc,
                                      gmx_bool bForceOut);
/** Sets the topology for a selection collection. */
int
gmx_ana_selcollection_set_topology(gmx_ana_selcollection_t *sc, t_topology *top,
                                   int natoms);
/** Returns the number of selections specified by a selection collection. */
int
gmx_ana_selcollection_get_count(gmx_ana_selcollection_t *sc);
/** Returns a selection by index. */
gmx_ana_selection_t *
gmx_ana_selcollection_get_selection(gmx_ana_selcollection_t *sc, int i);
/** Returns TRUE if the collection requires topology information for evaluation. */
gmx_bool
gmx_ana_selcollection_requires_top(gmx_ana_selcollection_t *sc);
/** Prints a human-readable version of the internal selection element tree. */
void
gmx_ana_selcollection_print_tree(FILE *fp, gmx_ana_selcollection_t *sc, gmx_bool bValues);
/** Prints the selection strings into an XVGR file as comments. */
void
xvgr_selcollection(FILE *fp, gmx_ana_selcollection_t *sc, 
                   const output_env_t oenv);

/* In parsetree.c */
/** Parses selection(s) from standard input. */
int
gmx_ana_selcollection_parse_stdin(gmx_ana_selcollection_t *sc, int nr,
                                  gmx_ana_indexgrps_t *grps,
                                  gmx_bool bInteractive);
/** Parses selection(s) from a file. */
int
gmx_ana_selcollection_parse_file(gmx_ana_selcollection_t *sc, const char *fnm,
                                  gmx_ana_indexgrps_t *grps);
/** Parses selection(s) from a string. */
int
gmx_ana_selcollection_parse_str(gmx_ana_selcollection_t *sc, const char *str,
                                gmx_ana_indexgrps_t *grps);

/* In compiler.c */
/** Set debugging flag for selection compilation. */
void
gmx_ana_selcollection_set_compile_debug(gmx_ana_selcollection_t *sc, gmx_bool bDebug);
/** Prepares the selections for evaluation and performs some optimizations. */
int
gmx_ana_selcollection_compile(gmx_ana_selcollection_t *sc);

/* In evaluate.c */
/** Evaluates the selection. */
int
gmx_ana_selcollection_evaluate(gmx_ana_selcollection_t *sc,
                               t_trxframe *fr, t_pbc *pbc);
/** Evaluates the largest possible index groups from dynamic selections. */
int
gmx_ana_selcollection_evaluate_fin(gmx_ana_selcollection_t *sc, int nframes);

#ifdef __cplusplus
}
#endif

#endif