Add pdbname selection keyword.
[alexxy/gromacs.git] / src / gromacs / selection / selmethod.cpp
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
9  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11  * Copyright (c) 2001-2009, The GROMACS development team,
12  * check out http://www.gromacs.org for more information.
13
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * If you want to redistribute modifications, please consider that
20  * scientific software is very special. Version control is crucial -
21  * bugs must be traceable. We will be happy to consider code for
22  * inclusion in the official distribution, but derived work must not
23  * be called official GROMACS. Details are found in the README & COPYING
24  * files - if they are missing, get the official version at www.gromacs.org.
25  *
26  * To help us fund GROMACS development, we humbly ask that you cite
27  * the papers on the package - you can find them in the top README file.
28  *
29  * For more info, check our website at http://www.gromacs.org
30  */
31 /*! \internal \file
32  * \brief
33  * Implements functions in selmethod.h.
34  *
35  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
36  * \ingroup module_selection
37  */
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include <ctype.h>
43 #include <stdarg.h>
44
45 #include "gromacs/legacyheaders/macros.h"
46 #include "gromacs/legacyheaders/string2.h"
47
48 #include "gromacs/selection/selmethod.h"
49 #include "gromacs/utility/exceptions.h"
50
51 #include "symrec.h"
52
53 /*
54  * These global variables cannot be const because gmx_ana_selmethod_register()
55  * modifies them to set some defaults. This is a small price to pay for the
56  * convenience of not having to remember exactly how the selection compiler
57  * expects the structures to be filled, and even more so if the expectations
58  * change. Also, even if the gmx_ana_selmethod_t structures were made const,
59  * the parameters could not be without typecasts somewhere, because the param
60  * field in gmx_ana_selmethod_t cannot be declared const.
61  *
62  * Even though the variables may be modified, this should be thread-safe as
63  * modifications are done only in gmx_ana_selmethod_register(), and it should
64  * work even if called more than once for the same structure, and even if
65  * called concurrently from multiple threads (as long as the selection
66  * collection is not the same).
67  *
68  * All of these problems should go away if/when the selection methods are
69  * implemented as C++ classes.
70  */
71
72 /* From sm_com.c */
73 extern gmx_ana_selmethod_t sm_cog;
74 extern gmx_ana_selmethod_t sm_com;
75 /* From sm_simple.c */
76 extern gmx_ana_selmethod_t sm_all;
77 extern gmx_ana_selmethod_t sm_none;
78 extern gmx_ana_selmethod_t sm_atomnr;
79 extern gmx_ana_selmethod_t sm_resnr;
80 extern gmx_ana_selmethod_t sm_resindex;
81 extern gmx_ana_selmethod_t sm_molindex;
82 extern gmx_ana_selmethod_t sm_atomname;
83 extern gmx_ana_selmethod_t sm_pdbatomname;
84 extern gmx_ana_selmethod_t sm_atomtype;
85 extern gmx_ana_selmethod_t sm_resname;
86 extern gmx_ana_selmethod_t sm_insertcode;
87 extern gmx_ana_selmethod_t sm_chain;
88 extern gmx_ana_selmethod_t sm_mass;
89 extern gmx_ana_selmethod_t sm_charge;
90 extern gmx_ana_selmethod_t sm_altloc;
91 extern gmx_ana_selmethod_t sm_occupancy;
92 extern gmx_ana_selmethod_t sm_betafactor;
93 extern gmx_ana_selmethod_t sm_x;
94 extern gmx_ana_selmethod_t sm_y;
95 extern gmx_ana_selmethod_t sm_z;
96 /* From sm_distance.c */
97 extern gmx_ana_selmethod_t sm_distance;
98 extern gmx_ana_selmethod_t sm_mindistance;
99 extern gmx_ana_selmethod_t sm_within;
100 /* From sm_insolidangle.c */
101 extern gmx_ana_selmethod_t sm_insolidangle;
102 /* From sm_same.c */
103 extern gmx_ana_selmethod_t sm_same;
104
105 /* From sm_merge.c */
106 extern gmx_ana_selmethod_t sm_merge;
107 extern gmx_ana_selmethod_t sm_plus;
108 /* From sm_permute.c */
109 extern gmx_ana_selmethod_t sm_permute;
110
111 /*! \internal \brief
112  * Helper structure for defining selection methods.
113  */
114 typedef struct {
115     /*! \brief
116      * Name to register the method under.
117      *
118      * If NULL, use the actual name of the method.
119      * This field is used for defining synonyms.
120      */
121     const char            *name;
122     /** Method data structure to register. */
123     gmx_ana_selmethod_t   *method;
124 } t_register_method;
125
126 /** Array of selection methods defined in the library. */
127 static const t_register_method smtable_def[] = {
128     {NULL,         &sm_cog},
129     {NULL,         &sm_com},
130
131     {NULL,         &sm_all},
132     {NULL,         &sm_none},
133     {NULL,         &sm_atomnr},
134     {NULL,         &sm_resnr},
135     {"resid",      &sm_resnr},
136     {NULL,         &sm_resindex},
137     {"residue",    &sm_resindex},
138     {NULL,         &sm_molindex},
139     {"mol",        &sm_molindex},
140     {"molecule",   &sm_molindex},
141     {NULL,         &sm_atomname},
142     {"name",       &sm_atomname},
143     {NULL,         &sm_pdbatomname},
144     {"pdbname",    &sm_pdbatomname},
145     {NULL,         &sm_atomtype},
146     {"type",       &sm_atomtype},
147     {NULL,         &sm_resname},
148     {NULL,         &sm_insertcode},
149     {NULL,         &sm_chain},
150     {NULL,         &sm_mass},
151     {NULL,         &sm_charge},
152     {NULL,         &sm_altloc},
153     {NULL,         &sm_occupancy},
154     {NULL,         &sm_betafactor},
155     {NULL,         &sm_x},
156     {NULL,         &sm_y},
157     {NULL,         &sm_z},
158
159     {NULL,         &sm_distance},
160     {NULL,         &sm_mindistance},
161     {NULL,         &sm_within},
162     {NULL,         &sm_insolidangle},
163     {NULL,         &sm_same},
164
165     {NULL,         &sm_merge},
166     {NULL,         &sm_plus},
167     {NULL,         &sm_permute},
168 };
169
170 /*! \brief
171  * Convenience function for reporting errors found in selection methods.
172  */
173 static void
174 report_error(FILE *fp, const char *name, const char *fmt, ...)
175 {
176     va_list ap;
177     va_start(ap, fmt);
178     if (fp)
179     {
180         fprintf(fp, "selection method '%s': ", name);
181         vfprintf(fp, fmt, ap);
182         fprintf(fp, "\n");
183     }
184     va_end(ap);
185 }
186
187 /*! \brief
188  * Convenience function for reporting errors found in selection method parameters.
189  */
190 static void
191 report_param_error(FILE *fp, const char *mname, const char *pname,
192                    const char *fmt, ...)
193 {
194     va_list ap;
195     va_start(ap, fmt);
196     if (fp)
197     {
198         fprintf(fp, "selection method '%s': parameter '%s': ", mname, pname);
199         vfprintf(fp, fmt, ap);
200         fprintf(fp, "\n");
201     }
202     va_end(ap);
203 }
204
205 /*! \brief
206  * Checks the validity of parameters.
207  *
208  * \param[in]     fp      File handle to use for diagnostic messages
209  *   (can be NULL).
210  * \param[in]     name    Name of the method (used for error messages).
211  * \param[in]     nparams Number of parameters in \p param.
212  * \param[in,out] param   Parameter array
213  *   (only the \c flags field of boolean parameters may be modified).
214  * \param[in]     symtab  Symbol table (used for checking overlaps).
215  * \returns       true if there are no problems with the parameters,
216  *   false otherwise.
217  *
218  * This function performs some checks common to both check_method() and
219  * check_modifier().
220  * The purpose of these checks is to ensure that the selection parser does not
221  * need to check for the validity of the parameters at each turn, and to
222  * report programming errors as early as possible.
223  * If you remove a check, make sure that the parameter parser can handle the
224  * resulting parameters.
225  */
226 static bool
227 check_params(FILE *fp, const char *name, int nparams, gmx_ana_selparam_t param[],
228              const gmx::SelectionParserSymbolTable &symtab)
229 {
230     bool              bOk = true;
231     int               i, j;
232
233     if (nparams > 0 && !param)
234     {
235         report_error(fp, name, "error: missing parameter data");
236         return false;
237     }
238     if (nparams == 0 && param)
239     {
240         report_error(fp, name, "warning: parameter data unused because nparams=0");
241     }
242     /* Check each parameter */
243     for (i = 0; i < nparams; ++i)
244     {
245         /* Check that there is at most one NULL name, in the beginning */
246         if (param[i].name == NULL && i > 0)
247         {
248             report_error(fp, name, "error: NULL parameter should be the first one");
249             bOk = false;
250             continue;
251         }
252         /* Check for duplicates */
253         for (j = 0; j < i; ++j)
254         {
255             if (param[j].name == NULL)
256             {
257                 continue;
258             }
259             if (!gmx_strcasecmp(param[i].name, param[j].name))
260             {
261                 report_error(fp, name, "error: duplicate parameter name '%s'", param[i].name);
262                 bOk = false;
263                 break;
264             }
265         }
266         /* Check flags */
267         if (param[i].flags & SPAR_SET)
268         {
269             report_param_error(fp, name, param[i].name, "warning: flag SPAR_SET is set");
270             param[i].flags &= ~SPAR_SET;
271         }
272         if (param[i].flags & SPAR_RANGES)
273         {
274             if (param[i].val.type != INT_VALUE && param[i].val.type != REAL_VALUE)
275             {
276                 report_param_error(fp, name, param[i].name, "error: SPAR_RANGES cannot be set for a non-numeric parameter");
277                 bOk = false;
278             }
279             if (param[i].flags & SPAR_DYNAMIC)
280             {
281                 report_param_error(fp, name, param[i].name, "warning: SPAR_DYNAMIC does not have effect with SPAR_RANGES");
282                 param[i].flags &= ~SPAR_DYNAMIC;
283             }
284             if (!(param[i].flags & SPAR_VARNUM) && param[i].val.nr != 1)
285             {
286                 report_param_error(fp, name, param[i].name, "error: range should take either one or an arbitrary number of values");
287                 bOk = false;
288             }
289             if (param[i].flags & SPAR_ATOMVAL)
290             {
291                 report_param_error(fp, name, param[i].name, "error: SPAR_RANGES and SPAR_ATOMVAL both set");
292                 bOk = false;
293             }
294         }
295         if ((param[i].flags & SPAR_VARNUM) && (param[i].flags & SPAR_ATOMVAL))
296         {
297             report_param_error(fp, name, param[i].name, "error: SPAR_VARNUM and SPAR_ATOMVAL both set");
298             bOk = false;
299         }
300         if (param[i].flags & SPAR_ENUMVAL)
301         {
302             if (param[i].val.type != STR_VALUE)
303             {
304                 report_param_error(fp, name, param[i].name, "error: SPAR_ENUMVAL can only be set for string parameters");
305                 bOk = false;
306             }
307             if (param[i].val.nr != 1)
308             {
309                 report_param_error(fp, name, param[i].name, "error: SPAR_ENUMVAL parameters should take exactly one value");
310                 bOk = false;
311             }
312             if (param[i].flags & (SPAR_DYNAMIC | SPAR_VARNUM | SPAR_ATOMVAL))
313             {
314                 report_param_error(fp, name, param[i].name, "error: only SPAR_OPTIONAL supported with SPAR_ENUMVAL");
315                 bOk = false;
316             }
317         }
318         /* Check boolean parameters */
319         if (param[i].val.type == NO_VALUE)
320         {
321             if (param[i].val.nr != 0)
322             {
323                 report_param_error(fp, name, param[i].name, "error: number of values should be zero for boolean parameters");
324                 bOk = false;
325             }
326             /* The boolean parameters should always be optional, so set the
327              * flag for convenience. */
328             param[i].flags |= SPAR_OPTIONAL;
329             /* Any other flags should not be specified */
330             if (param[i].flags & ~SPAR_OPTIONAL)
331             {
332                 report_param_error(fp, name, param[i].name, "error: boolean parameter should not have any flags set");
333                 bOk = false;
334             }
335         }
336         /* Check val.nr */
337         if (param[i].flags & (SPAR_VARNUM | SPAR_ATOMVAL))
338         {
339             if (param[i].val.nr != -1)
340             {
341                 report_param_error(fp, name, param[i].name, "warning: val.nr is not -1 although SPAR_VARNUM/SPAR_ATOMVAL is set");
342             }
343             param[i].val.nr = -1;
344         }
345         else if (param[i].val.type != NO_VALUE)
346         {
347             if (param[i].val.nr <= 0)
348             {
349                 report_param_error(fp, name, param[i].name, "error: val.nr <= 0");
350                 bOk = false;
351             }
352         }
353         /* Check that the value pointer is NULL */
354         if (param[i].nvalptr != NULL)
355         {
356             report_param_error(fp, name, param[i].name, "warning: nvalptr is set");
357         }
358         if (param[i].val.u.ptr != NULL && !(param[i].flags & SPAR_ENUMVAL))
359         {
360             report_param_error(fp, name, param[i].name, "warning: value pointer is set");
361         }
362         /* Check that the name contains only valid characters */
363         if (param[i].name == NULL)
364         {
365             continue;
366         }
367         if (!isalpha(param[i].name[0]))
368         {
369             report_param_error(fp, name, param[i].name, "error: name does not begin with a letter");
370             bOk = false;
371             continue;
372         }
373         for (j = 1; param[i].name[j] != 0; ++j)
374         {
375             if (param[i].name[j] != '_' && !isalnum(param[i].name[j]))
376             {
377                 report_param_error(fp, name, param[i].name, "error: name contains non-alphanumeric characters");
378                 bOk = false;
379                 break;
380             }
381         }
382         if (param[i].name[j] != 0)
383         {
384             continue;
385         }
386         /* Check that the name does not conflict with a method */
387         if (symtab.findSymbol(param[i].name, true))
388         {
389             report_param_error(fp, name, param[i].name, "error: name conflicts with another method or a keyword");
390             bOk = false;
391         }
392     } /* End of parameter loop */
393     /* Check parameters of existing methods */
394     gmx::SelectionParserSymbolIterator symbol
395         = symtab.beginIterator(gmx::SelectionParserSymbol::MethodSymbol);
396     while (symbol != symtab.endIterator())
397     {
398         gmx_ana_selmethod_t *method = symbol->methodValue();
399         gmx_ana_selparam_t  *param =
400             gmx_ana_selmethod_find_param(name, method);
401         if (param)
402         {
403             report_param_error(fp, method->name, param->name, "error: name conflicts with another method or a keyword");
404             bOk = false;
405         }
406         ++symbol;
407     }
408     return bOk;
409 }
410
411 /*! \brief
412  * Checks the validity of selection method callback functions.
413  *
414  * \param[in] fp        File handle to use for diagnostic messages
415  *   (can be NULL).
416  * \param[in] method    The method to check.
417  * \returns   true if there are no problems, false otherwise.
418  *
419  * This function performs some checks common to both check_method() and
420  * check_modifier().
421  * This function checks that all the required callbacks are defined, i.e.,
422  * not NULL, to find programming errors.
423  */
424 static bool
425 check_callbacks(FILE *fp, gmx_ana_selmethod_t *method)
426 {
427     bool         bOk = true;
428     bool         bNeedInit;
429     int          i;
430
431     /* Make some checks on init_data and free */
432     if (method->nparams > 0 && !method->init_data)
433     {
434         report_error(fp, method->name, "error: init_data should be provided because the method has parameters");
435         bOk = false;
436     }
437     if (method->free && !method->init_data)
438     {
439         report_error(fp, method->name, "warning: free is not used because of missing init_data");
440     }
441     /* Check presence of outinit for position-valued methods */
442     if (method->type == POS_VALUE && !method->outinit)
443     {
444         report_error(fp, method->name, "error: outinit should be provided because the method has POS_VALUE");
445         bOk = false;
446     }
447     /* Warn of dynamic callbacks in static methods */
448     if (!(method->flags & SMETH_MODIFIER))
449     {
450         if (method->pupdate && !(method->flags & SMETH_DYNAMIC))
451         {
452             report_error(fp, method->name, "warning: pupdate not used because the method is static");
453             method->pupdate = NULL;
454         }
455     }
456     /* Check that there is an evaluation function */
457     if (method->type != NO_VALUE && !method->update && !method->pupdate)
458     {
459         report_error(fp, method->name, "error: evaluation function missing");
460         bOk = false;
461     }
462     /* Loop through the parameters to determine if initialization callbacks
463      * are needed. */
464     bNeedInit = false;
465     for (i = 0; i < method->nparams; ++i)
466     {
467         if (method->param[i].val.type != POS_VALUE
468             && (method->param[i].flags & (SPAR_VARNUM | SPAR_ATOMVAL)))
469         {
470             bNeedInit = true;
471         }
472     }
473     /* Check that the callbacks required by the parameters are present */
474     if (bNeedInit && !method->init)
475     {
476         report_error(fp, method->name, "error: init should be provided");
477         bOk = false;
478     }
479     return bOk;
480 }
481
482 /*!
483  * Checks the validity of a selection method.
484  *
485  * \param[in]     fp     File handle to use for diagnostic messages
486  *   (can be NULL).
487  * \param[in,out] method Method to check.
488  * \param[in]     symtab Symbol table (used for checking overlaps).
489  *
490  * Checks the validity of the given selection method data structure
491  * that does not have \ref SMETH_MODIFIER set.
492  * If you remove a check, please make sure that the selection parser,
493  * compiler, and evaluation functions can deal with the method.
494  */
495 static bool
496 check_method(FILE *fp, gmx_ana_selmethod_t *method,
497              const gmx::SelectionParserSymbolTable &symtab)
498 {
499     bool         bOk = true;
500
501     /* Check the type */
502     if (method->type == NO_VALUE)
503     {
504         report_error(fp, method->name, "error: no value type specified");
505         bOk = false;
506     }
507     if (method->type == STR_VALUE && method->nparams > 0)
508     {
509         report_error(fp, method->name, "error: evaluates to a string but is not a keyword");
510         bOk = false;
511     }
512     /* Check flags */
513     if (method->type == GROUP_VALUE)
514     {
515         /* Group methods should always have SMETH_SINGLEVAL,
516          * so set it for convenience. */
517         method->flags |= SMETH_SINGLEVAL;
518         /* Check that conflicting flags are not present. */
519         if (method->flags & SMETH_VARNUMVAL)
520         {
521             report_error(fp, method->name, "error: SMETH_VARNUMVAL cannot be set for group-valued methods");
522             bOk = false;
523         }
524     }
525     else
526     {
527         if ((method->flags & SMETH_SINGLEVAL)
528             && (method->flags & SMETH_VARNUMVAL))
529         {
530             report_error(fp, method->name, "error: SMETH_SINGLEVAL and SMETH_VARNUMVAL both set");
531             bOk = false;
532         }
533     }
534     if ((method->flags & SMETH_CHARVAL) && method->type != STR_VALUE)
535     {
536         report_error(fp, method->name, "error: SMETH_CHARVAL can only be specified for STR_VALUE methods");
537         bOk = false;
538     }
539     /* Check the parameters */
540     if (!check_params(fp, method->name, method->nparams, method->param, symtab))
541     {
542         bOk = false;
543     }
544     /* Check the callback pointers */
545     if (!check_callbacks(fp, method))
546     {
547         bOk = false;
548     }
549
550     return bOk;
551 }
552
553 /*!
554  * Checks the validity of a selection modifier method.
555  *
556  * \param[in]     fp     File handle to use for diagnostic messages
557  *   (can be NULL).
558  * \param[in,out] method Method to check.
559  * \param[in]     symtab Symbol table (used for checking overlaps).
560  *
561  * Checks the validity of the given selection method data structure
562  * that has \ref SMETH_MODIFIER set.
563  * If you remove a check, please make sure that the selection parser,
564  * compiler, and evaluation functions can deal with the method.
565  */
566 static bool
567 check_modifier(FILE *fp, gmx_ana_selmethod_t *method,
568                const gmx::SelectionParserSymbolTable &symtab)
569 {
570     bool         bOk = true;
571
572     /* Check the type */
573     if (method->type != NO_VALUE && method->type != POS_VALUE)
574     {
575         report_error(fp, method->name, "error: modifier should have type POS_VALUE or NO_VALUE");
576         bOk = false;
577     }
578     /* Check flags */
579     if (method->flags & (SMETH_SINGLEVAL | SMETH_VARNUMVAL))
580     {
581         report_error(fp, method->name, "error: modifier should not have SMETH_SINGLEVAL or SMETH_VARNUMVAL set");
582         bOk = false;
583     }
584     /* Check the parameters */
585     /* The first parameter is skipped */
586     if (!check_params(fp, method->name, method->nparams-1, method->param+1, symtab))
587     {
588         bOk = false;
589     }
590     /* Check the callback pointers */
591     if (!check_callbacks(fp, method))
592     {
593         bOk = false;
594     }
595     if (method->update)
596     {
597         report_error(fp, method->name, "error: modifier should not have update");
598         bOk = false;
599     }
600     if (method->type == POS_VALUE && !method->pupdate)
601     {
602         report_error(fp, method->name, "error: evaluation function missing");
603         bOk = false;
604     }
605
606     return bOk;
607 }
608
609 /*!
610  * \param[in,out] symtab Symbol table to register the method to.
611  * \param[in]     name   Name under which the method should be registered.
612  * \param[in]     method Method to register.
613  * \returns       0 on success, EINVAL if there was something wrong with the
614  *   method.
615  *
616  * \p name does not need to match the name of the method, and the same
617  * method can be registered multiple times under different names.
618  * If \p name equals some previously registered name,
619  * an error message is printed and the method is not registered.
620  *
621  * The function also performs some sanity checking on the input method,
622  * and refuses to register it if there are problems.
623  * Some problems only generate warnings.
624  * All problems are described to \p stderr.
625  */
626 int
627 gmx_ana_selmethod_register(gmx::SelectionParserSymbolTable *symtab,
628                            const char *name, gmx_ana_selmethod_t *method)
629 {
630     bool bOk;
631
632     /* Check the method */
633     if (method->flags & SMETH_MODIFIER)
634     {
635         bOk = check_modifier(stderr, method, *symtab);
636     }
637     else
638     {
639         bOk = check_method(stderr, method, *symtab);
640     }
641     /* Try to register the method if everything is ok */
642     if (bOk)
643     {
644         try
645         {
646             symtab->addMethod(name, method);
647         }
648         catch (const gmx::APIError &ex)
649         {
650             report_error(stderr, name, ex.what());
651             bOk = false;
652         }
653     }
654     if (!bOk)
655     {
656         report_error(stderr, name, "warning: not registered");
657         return EINVAL;
658     }
659     return 0;
660 }
661
662 /*!
663  * \param[in,out] symtab Symbol table to register the methods to.
664  * \returns       0 on success, -1 if any of the default methods could not be
665  *   registered.
666  */
667 int
668 gmx_ana_selmethod_register_defaults(gmx::SelectionParserSymbolTable *symtab)
669 {
670     size_t i;
671     int  rc;
672     bool bOk;
673
674     bOk = true;
675     for (i = 0; i < asize(smtable_def); ++i)
676     {
677         gmx_ana_selmethod_t *method = smtable_def[i].method;
678
679         if (smtable_def[i].name == NULL)
680         {
681             rc = gmx_ana_selmethod_register(symtab, method->name, method);
682         }
683         else
684         {
685             rc = gmx_ana_selmethod_register(symtab, smtable_def[i].name, method);
686         }
687         if (rc != 0)
688         {
689             bOk = false;
690         }
691     }
692     return bOk ? 0 : -1;
693 }
694
695 /*!
696  * \param[in] name   Name of the parameter to search.
697  * \param[in] method Method to search for the parameter.
698  * \returns   Pointer to the parameter in the
699  *   \ref gmx_ana_selmethod_t::param "method->param" array,
700  *   or NULL if no parameter with name \p name was found.
701  *
702  * This is a simple wrapper for gmx_ana_selparam_find().
703  */
704 gmx_ana_selparam_t *
705 gmx_ana_selmethod_find_param(const char *name, gmx_ana_selmethod_t *method)
706 {
707     return gmx_ana_selparam_find(name, method->nparams, method->param);
708 }