Merge 'release-4-6' into master
[alexxy/gromacs.git] / src / gromacs / selection / selhelp.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 selhelp.h.
34  *
35  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
36  * \ingroup module_selection
37  */
38 #include <string>
39 #include <vector>
40 #include <utility>
41
42 #include <boost/scoped_ptr.hpp>
43
44 #include "gromacs/onlinehelp/helptopic.h"
45 #include "gromacs/onlinehelp/helpwritercontext.h"
46 #include "gromacs/utility/exceptions.h"
47 #include "gromacs/utility/file.h"
48 #include "gromacs/utility/stringutil.h"
49
50 #include "selhelp.h"
51 #include "selmethod.h"
52 #include "symrec.h"
53
54 namespace
55 {
56
57 struct CommonHelpText
58 {
59     static const char name[];
60     static const char title[];
61     static const char *const text[];
62 };
63
64 const char CommonHelpText::name[] = "selections";
65 const char CommonHelpText::title[] =
66     "Selection syntax and usage";
67 const char *const CommonHelpText::text[] = {
68     "Selections are used to select atoms/molecules/residues for analysis.",
69     "In contrast to traditional index files, selections can be dynamic, i.e.,",
70     "select different atoms for different trajectory frames.[PAR]",
71
72     "Each analysis tool requires a different number of selections and the",
73     "selections are interpreted differently. The general idea is still the",
74     "same: each selection evaluates to a set of positions, where a position",
75     "can be an atom position or center-of-mass or center-of-geometry of",
76     "a set of atoms. The tool then uses these positions for its analysis to",
77     "allow very flexible processing. Some analysis tools may have limitations",
78     "on the types of selections allowed.[PAR]",
79
80     "To get started with selections, run, e.g., [TT][PROGRAM] select[tt]",
81     "without specifying selections on the command-line and use the interactive",
82     "prompt to try out different selections.",
83     "This tool provides output options that allow one to see what is actually",
84     "selected by the given selections, and the interactive prompt reports",
85     "syntax errors immediately, allowing one to try again.",
86     "The subtopics listed below give more details on different aspects of",
87     "selections.",
88 };
89
90 struct ArithmeticHelpText
91 {
92     static const char name[];
93     static const char title[];
94     static const char *const text[];
95 };
96
97 const char ArithmeticHelpText::name[] = "arithmetic";
98 const char ArithmeticHelpText::title[] =
99     "Arithmetic expressions in selections";
100 const char *const ArithmeticHelpText::text[] = {
101     "Basic arithmetic evaluation is supported for numeric expressions.",
102     "Supported operations are addition, subtraction, negation, multiplication,",
103     "division, and exponentiation (using ^).",
104     "Result of a division by zero or other illegal operations is undefined.",
105 };
106
107 struct CmdLineHelpText
108 {
109     static const char name[];
110     static const char title[];
111     static const char *const text[];
112 };
113
114 const char CmdLineHelpText::name[] = "cmdline";
115 const char CmdLineHelpText::title[] =
116     "Specifying selections from command line";
117 const char *const CmdLineHelpText::text[] = {
118     "If no selections are provided on the command line, you are prompted to",
119     "type the selections interactively (a pipe can also be used to provide",
120     "the selections in this case for most tools). While this works well for",
121     "testing, it is easier to provide the selections from the command line",
122     "if they are complex or for scripting.[PAR]",
123
124     "Each tool has different command-line arguments for specifying selections",
125     "(listed by [TT][PROGRAM] help <tool>[tt]).",
126     "You can either pass a single string containing all selections (separated",
127     "by semicolons), or multiple strings, each containing one selection.",
128     "Note that you need to quote the selections to protect them from the",
129     "shell.[PAR]",
130
131     "If you set a selection command-line argument, but do not provide any",
132     "selections, you are prompted to type the selections for that argument",
133     "interactively. This is useful if that selection argument is optional,",
134     "in which case it is not normally prompted for.[PAR]",
135
136     "To provide selections from a file, use [TT]-sf file.dat[tt] in the place",
137     "of the selection for a selection argument (e.g.,",
138     "[TT]-select -sf file.dat[tt]). In general, the [TT]-sf[tt] argument reads",
139     "selections from the provided file and assigns them to selection arguments",
140     "that have been specified up to that point, but for which no selections",
141     "have been provided.",
142     "As a special case, [TT]-sf[tt] provided on its own, without preceding",
143     "selection arguments, assigns the selections to all (yet unset) required",
144     "selections (i.e., those that would be promted interactively if no",
145     "selections are provided on the command line).[PAR]",
146
147     "To use groups from a traditional index file, use argument [TT]-n[tt]",
148     "to provide a file. See the \"syntax\" subtopic for how to use them.",
149     "If this option is not provided, default groups are generated.",
150     "The default groups are generated by reading selections from a file",
151     "[TT]defselection.dat[tt]. If such a file is found in the current",
152     "directory, it is used instead of the one provided by default.[PAR]",
153
154     "Depending on the tool, two additional command-line arguments may be",
155     "available to control the behavior:[BR]",
156     "1. [TT]-seltype[tt] can be used to specify the default type of",
157     "positions to calculate for each selection.[BR]",
158     "2. [TT]-selrpos[tt] can be used to specify the default type of",
159     "positions used in selecting atoms by coordinates.[BR]",
160     "See the \"positions\" subtopic for more information on these options.",
161 };
162
163 struct EvaluationHelpText
164 {
165     static const char name[];
166     static const char title[];
167     static const char *const text[];
168 };
169
170 const char EvaluationHelpText::name[] = "evaluation";
171 const char EvaluationHelpText::title[] =
172     "Selection evaluation and optimization";
173 const char *const EvaluationHelpText::text[] = {
174     "Boolean evaluation proceeds from left to right and is short-circuiting",
175     "i.e., as soon as it is known whether an atom will be selected, the",
176     "remaining expressions are not evaluated at all.",
177     "This can be used to optimize the selections: you should write the",
178     "most restrictive and/or the most inexpensive expressions first in",
179     "boolean expressions.",
180     "The relative ordering between dynamic and static expressions does not",
181     "matter: all static expressions are evaluated only once, before the first",
182     "frame, and the result becomes the leftmost expression.[PAR]",
183
184     "Another point for optimization is in common subexpressions: they are not",
185     "automatically recognized, but can be manually optimized by the use of",
186     "variables. This can have a big impact on the performance of complex",
187     "selections, in particular if you define several index groups like this:",
188     "  [TT]rdist = distance from com of resnr 1 to 5;[tt][BR]",
189     "  [TT]resname RES and rdist < 2;[tt][BR]",
190     "  [TT]resname RES and rdist < 4;[tt][BR]",
191     "  [TT]resname RES and rdist < 6;[tt][BR]",
192     "Without the variable assignment, the distances would be evaluated three",
193     "times, although they are exactly the same within each selection.",
194     "Anything assigned into a variable becomes a common subexpression that",
195     "is evaluated only once during a frame.",
196     "Currently, in some cases the use of variables can actually lead to a small",
197     "performance loss because of the checks necessary to determine for which",
198     "atoms the expression has already been evaluated, but this should not be",
199     "a major problem.",
200 };
201
202 struct ExamplesHelpText
203 {
204     static const char name[];
205     static const char title[];
206     static const char *const text[];
207 };
208
209 const char ExamplesHelpText::name[] = "examples";
210 const char ExamplesHelpText::title[] =
211     "Selection examples";
212 const char *const ExamplesHelpText::text[] = {
213     // TODO: Once there are more tools available, use examples that invoke
214     // tools and explain what the selections do in those tools.
215     "Below, examples of increasingly complex selections are given.[PAR]",
216
217     "Selection of all water oxygens:[BR]",
218     "  resname SOL and name OW",
219     "[PAR]",
220
221     "Centers of mass of residues 1 to 5 and 10:[BR]",
222     "  res_com of resnr 1 to 5 10",
223     "[PAR]",
224
225     "All atoms farther than 1 nm of a fixed position:[BR]",
226     "  not within 1 of (1.2, 3.1, 2.4)",
227     "[PAR]",
228
229     "All atoms of a residue LIG within 0.5 nm of a protein (with a custom name):[BR]",
230     "  \"Close to protein\" resname LIG and within 0.5 of group \"Protein\"",
231     "[PAR]",
232
233     "All protein residues that have at least one atom within 0.5 nm of a residue LIG:[BR]",
234     "  group \"Protein\" and same residue as within 0.5 of resname LIG",
235     "[PAR]",
236
237     "All RES residues whose COM is between 2 and 4 nm from the COM of all of them:[BR]",
238     "  rdist = res_com distance from com of resname RES[BR]",
239     "  resname RES and rdist >= 2 and rdist <= 4",
240     "[PAR]",
241
242     "Selection like C1 C2 C2 C3 C3 C4 ... C8 C9 (e.g., for g_bond):[BR]",
243     "  name \"C[1-8]\" merge name \"C[2-9]\"",
244 };
245
246 struct KeywordsHelpText
247 {
248     static const char name[];
249     static const char title[];
250     static const char *const text[];
251 };
252
253 const char KeywordsHelpText::name[] = "keywords";
254 const char KeywordsHelpText::title[] =
255     "Selection keywords";
256 const char *const KeywordsHelpText::text[] = {
257     "The following selection keywords are currently available.",
258     "For keywords marked with a star, additional help is available through",
259     "a subtopic KEYWORD, where KEYWORD is the name of the keyword.",
260 };
261
262 struct LimitationsHelpText
263 {
264     static const char name[];
265     static const char title[];
266     static const char *const text[];
267 };
268
269 const char LimitationsHelpText::name[] = "limitations";
270 const char LimitationsHelpText::title[] =
271     "Selection limitations";
272 const char *const LimitationsHelpText::text[] = {
273     "Some analysis programs may require a special structure for the input",
274     "selections (e.g., [TT]g_angle[tt] requires the index group to be made",
275     "of groups of three or four atoms).",
276     "For such programs, it is up to the user to provide a proper selection",
277     "expression that always returns such positions.",
278     "[PAR]",
279
280     "Due to technical reasons, having a negative value as the first value in",
281     "expressions like[BR]",
282     "[TT]charge -1 to -0.7[tt][BR]",
283     "result in a syntax error. A workaround is to write[BR]",
284     "[TT]charge {-1 to -0.7}[tt][BR]",
285     "instead.[PAR]",
286
287     "When [TT]name[tt] selection keyword is used together with PDB input",
288     "files, the behavior may be unintuitive. When Gromacs reads in a PDB",
289     "file, 4 character atom names that start with a digit are transformed",
290     "such that, e.g., 1HG2 becomes HG21, and the latter is what is matched",
291     "by the [TT]name[tt] keyword. Use [TT]pdbname[tt] to match the atom name",
292     "as it appears in the input PDB file.",
293 };
294
295 struct PositionsHelpText
296 {
297     static const char name[];
298     static const char title[];
299     static const char *const text[];
300 };
301
302 const char PositionsHelpText::name[] = "positions";
303 const char PositionsHelpText::title[] =
304     "Specifying positions in selections";
305 const char *const PositionsHelpText::text[] = {
306     "Possible ways of specifying positions in selections are:[PAR]",
307
308     "1. A constant position can be defined as [TT][XX, YY, ZZ][tt], where",
309     "[TT]XX[tt], [TT]YY[tt] and [TT]ZZ[tt] are real numbers.[PAR]",
310
311     "2. [TT]com of ATOM_EXPR [pbc][tt] or [TT]cog of ATOM_EXPR [pbc][tt]",
312     "calculate the center of mass/geometry of [TT]ATOM_EXPR[tt]. If",
313     "[TT]pbc[tt] is specified, the center is calculated iteratively to try",
314     "to deal with cases where [TT]ATOM_EXPR[tt] wraps around periodic",
315     "boundary conditions.[PAR]",
316
317     "3. [TT]POSTYPE of ATOM_EXPR[tt] calculates the specified positions for",
318     "the atoms in [TT]ATOM_EXPR[tt].",
319     "[TT]POSTYPE[tt] can be [TT]atom[tt], [TT]res_com[tt], [TT]res_cog[tt],",
320     "[TT]mol_com[tt] or [TT]mol_cog[tt], with an optional prefix [TT]whole_[tt]",
321     "[TT]part_[tt] or [TT]dyn_[tt].",
322     "[TT]whole_[tt] calculates the centers for the whole residue/molecule,",
323     "even if only part of it is selected.",
324     "[TT]part_[tt] prefix calculates the centers for the selected atoms, but",
325     "uses always the same atoms for the same residue/molecule. The used atoms",
326     "are determined from the the largest group allowed by the selection.",
327     "[TT]dyn_[tt] calculates the centers strictly only for the selected atoms.",
328     "If no prefix is specified, whole selections default to [TT]part_[tt] and",
329     "other places default to [TT]whole_[tt].",
330     "The latter is often desirable to select the same molecules in different",
331     "tools, while the first is a compromise between speed ([TT]dyn_[tt]",
332     "positions can be slower to evaluate than [TT]part_[tt]) and intuitive",
333     "behavior.[PAR]",
334
335     "4. [TT]ATOM_EXPR[tt], when given for whole selections, is handled as 3.",
336     "above, using the position type from the command-line argument",
337     "[TT]-seltype[tt].[PAR]",
338
339     "Selection keywords that select atoms based on their positions, such as",
340     "[TT]dist from[tt], use by default the positions defined by the",
341     "[TT]-selrpos[tt] command-line option.",
342     "This can be overridden by prepending a [TT]POSTYPE[tt] specifier to the",
343     "keyword. For example, [TT]res_com dist from POS[tt] evaluates the",
344     "residue center of mass distances. In the example, all atoms of a residue",
345     "are either selected or not, based on the single distance calculated.",
346 };
347
348 struct SyntaxHelpText
349 {
350     static const char name[];
351     static const char title[];
352     static const char *const text[];
353 };
354
355 const char SyntaxHelpText::name[] = "syntax";
356 const char SyntaxHelpText::title[] =
357     "Selection syntax";
358 const char *const SyntaxHelpText::text[] = {
359     "A set of selections consists of one or more selections, separated by",
360     "semicolons. Each selection defines a set of positions for the analysis.",
361     "Each selection can also be preceded by a string that gives a name for",
362     "the selection for use in, e.g., graph legends.",
363     "If no name is provided, the string used for the selection is used",
364     "automatically as the name.[PAR]",
365
366     "For interactive input, the syntax is slightly altered: line breaks can",
367     "also be used to separate selections. \\ followed by a line break can",
368     "be used to continue a line if necessary.",
369     "Notice that the above only applies to real interactive input,",
370     "not if you provide the selections, e.g., from a pipe.[PAR]",
371
372     "It is possible to use variables to store selection expressions.",
373     "A variable is defined with the following syntax:[BR]",
374     "[TT]VARNAME = EXPR ;[tt][BR]",
375     "where [TT]EXPR[tt] is any valid selection expression.",
376     "After this, [TT]VARNAME[tt] can be used anywhere where [TT]EXPR[tt]",
377     "would be valid.[PAR]",
378
379     "Selections are composed of three main types of expressions, those that",
380     "define atoms ([TT]ATOM_EXPR[tt]s), those that define positions",
381     "([TT]POS_EXPR[tt]s), and those that evaluate to numeric values",
382     "([TT]NUM_EXPR[tt]s). Each selection should be a [TT]POS_EXPR[tt]",
383     "or a [TT]ATOM_EXPR[tt] (the latter is automatically converted to",
384     "positions). The basic rules are as follows:[BR]",
385     "1. An expression like [TT]NUM_EXPR1 < NUM_EXPR2[tt] evaluates to an",
386     "[TT]ATOM_EXPR[tt] that selects all the atoms for which the comparison",
387     "is true.[BR]",
388     "2. Atom expressions can be combined with boolean operations such as",
389     "[TT]not ATOM_EXPR[tt], [TT]ATOM_EXPR and ATOM_EXPR[tt], or",
390     "[TT]ATOM_EXPR or ATOM_EXPR[tt]. Parentheses can be used to alter the",
391     "evaluation order.[BR]",
392     "3. [TT]ATOM_EXPR[tt] expressions can be converted into [TT]POS_EXPR[tt]",
393     "expressions in various ways, see the \"positions\" subtopic for more",
394     "details.[PAR]",
395
396     "Some keywords select atoms based on string values such as the atom name.",
397     "For these keywords, it is possible to use wildcards ([TT]name \"C*\"[tt])",
398     "or regular expressions (e.g., [TT]resname \"R[AB]\"[tt]).",
399     "The match type is automatically guessed from the string: if it contains",
400     "other characters than letters, numbers, '*', or '?', it is interpreted",
401     "as a regular expression.",
402     "To force the matching to use literal string matching, use",
403     "[TT]name = \"C*\"[tt] to match a literal C*.",
404     "To force other type of matching, use '?' or '~' in place of '=' to force",
405     "wildcard or regular expression matching, respectively.[PAR]",
406
407     "Strings that contain non-alphanumeric characters should be enclosed in",
408     "double quotes as in the examples. For other strings, the quotes are",
409     "optional, but if the value conflicts with a reserved keyword, a syntax",
410     "error will occur. If your strings contain uppercase letters, this should",
411     "not happen.[PAR]",
412
413     "Index groups provided with the [TT]-n[tt] command-line option or",
414     "generated by default can be accessed with [TT]group NR[tt] or",
415     "[TT]group NAME[tt], where [TT]NR[tt] is a zero-based index of the group",
416     "and [TT]NAME[tt] is part of the name of the desired group.",
417     "The keyword [TT]group[tt] is optional if the whole selection is",
418     "provided from an index group.",
419     "To see a list of available groups in the interactive mode, press enter",
420     "in the beginning of a line.",
421 };
422
423 } // namespace
424
425 namespace gmx
426 {
427
428 namespace
429 {
430
431 /*! \internal \brief
432  * Help topic implementation for an individual selection method.
433  *
434  * \ingroup module_selection
435  */
436 class KeywordDetailsHelpTopic : public AbstractSimpleHelpTopic
437 {
438     public:
439         //! Initialize help topic for the given selection method.
440         KeywordDetailsHelpTopic(const std::string &name,
441                                 const gmx_ana_selmethod_t &method)
442             : name_(name), method_(method)
443         {
444         }
445
446         virtual const char *name() const
447         {
448             return name_.c_str();
449         }
450         virtual const char *title() const
451         {
452             return NULL;
453         }
454
455     protected:
456         virtual std::string helpText() const
457         {
458             return concatenateStrings(method_.help.help, method_.help.nlhelp);
459         }
460
461     private:
462         std::string                name_;
463         const gmx_ana_selmethod_t &method_;
464
465         GMX_DISALLOW_COPY_AND_ASSIGN(KeywordDetailsHelpTopic);
466 };
467
468 /*! \internal \brief
469  * Custom help topic for printing a list of selection keywords.
470  *
471  * \ingroup module_selection
472  */
473 class KeywordsHelpTopic : public CompositeHelpTopic<KeywordsHelpText>
474 {
475     public:
476         KeywordsHelpTopic();
477
478         virtual void writeHelp(const HelpWriterContext &context) const;
479
480     private:
481         /*! \brief
482          * Container for known selection methods.
483          *
484          * The first item in the pair is the name of the selection method, and
485          * the second points to the static data structure that describes the
486          * method.
487          * The name in the first item may differ from the name of the static
488          * data structure if an alias is defined for that method.
489          */
490         typedef std::vector<std::pair<std::string,
491                                       const gmx_ana_selmethod_t *> >
492                 MethodList;
493
494         /*! \brief
495          * Prints a brief list of keywords (selection methods) available.
496          *
497          * \param[in] context  Context for printing the help.
498          * \param[in] type     Only methods that return this type are printed.
499          * \param[in] bModifiers  If false, \ref SMETH_MODIFIER methods are
500          *      excluded, otherwise only them are printed.
501          */
502         void printKeywordList(const HelpWriterContext &context,
503                               e_selvalue_t type, bool bModifiers) const;
504
505         MethodList              methods_;
506 };
507
508 KeywordsHelpTopic::KeywordsHelpTopic()
509 {
510     // TODO: This is not a very elegant way of getting the list of selection
511     // methods, but this needs to be rewritten in any case if/when #652 is
512     // implemented.
513     boost::scoped_ptr<SelectionParserSymbolTable> symtab(
514             new SelectionParserSymbolTable);
515     gmx_ana_selmethod_register_defaults(symtab.get());
516
517     SelectionParserSymbolIterator symbol
518         = symtab->beginIterator(SelectionParserSymbol::MethodSymbol);
519     while (symbol != symtab->endIterator())
520     {
521         const std::string &symname = symbol->name();
522         const gmx_ana_selmethod_t *method = symbol->methodValue();
523         methods_.push_back(std::make_pair(std::string(symname), method));
524         if (method->help.nlhelp > 0 && method->help.help != NULL)
525         {
526             addSubTopic(HelpTopicPointer(
527                         new KeywordDetailsHelpTopic(symname, *method)));
528         }
529         ++symbol;
530     }
531 }
532
533 void KeywordsHelpTopic::writeHelp(const HelpWriterContext &context) const
534 {
535     if (context.outputFormat() != eHelpOutputFormat_Console)
536     {
537         GMX_THROW(NotImplementedError(
538                     "Selection help is not implemented for this output format"));
539     }
540     // TODO: The markup here is not really appropriate, and printKeywordList()
541     // still prints raw text, but these are waiting for discussion of the
542     // markup format in #969.
543     writeBasicHelpTopic(context, *this, helpText());
544     context.writeTextBlock("[BR]");
545
546     // Print the list of keywords
547     context.writeTextBlock(
548             "Keywords that select atoms by an integer property:[BR]"
549             "(use in expressions or like \"atomnr 1 to 5 7 9\")[BR]");
550     printKeywordList(context, INT_VALUE, false);
551     context.writeTextBlock("[BR]");
552
553     context.writeTextBlock(
554             "Keywords that select atoms by a numeric property:[BR]"
555             "(use in expressions or like \"occupancy 0.5 to 1\")[BR]");
556     printKeywordList(context, REAL_VALUE, false);
557     context.writeTextBlock("[BR]");
558
559     context.writeTextBlock(
560             "Keywords that select atoms by a string property:[BR]"
561             "(use like \"name PATTERN [PATTERN] ...\")[BR]");
562     printKeywordList(context, STR_VALUE, false);
563     context.writeTextBlock("[BR]");
564
565     context.writeTextBlock(
566             "Additional keywords that directly select atoms:[BR]");
567     printKeywordList(context, GROUP_VALUE, false);
568     context.writeTextBlock("[BR]");
569
570     context.writeTextBlock(
571             "Keywords that directly evaluate to positions:[BR]"
572             "(see also \"positions\" subtopic)[BR]");
573     printKeywordList(context, POS_VALUE, false);
574     context.writeTextBlock("[BR]");
575
576     context.writeTextBlock("Additional keywords:[BR]");
577     printKeywordList(context, POS_VALUE, true);
578     printKeywordList(context, NO_VALUE, true);
579 }
580
581 void KeywordsHelpTopic::printKeywordList(const HelpWriterContext &context,
582                                          e_selvalue_t type,
583                                          bool bModifiers) const
584 {
585     File &file = context.outputFile();
586     MethodList::const_iterator iter;
587     for (iter = methods_.begin(); iter != methods_.end(); ++iter)
588     {
589         const gmx_ana_selmethod_t &method = *iter->second;
590         bool bIsModifier = (method.flags & SMETH_MODIFIER) != 0;
591         if (method.type == type && bModifiers == bIsModifier)
592         {
593             bool bHasHelp = (method.help.nlhelp > 0 && method.help.help != NULL);
594             file.writeString(formatString(" %c ", bHasHelp ? '*' : ' '));
595             if (method.help.syntax != NULL)
596             {
597                 file.writeLine(method.help.syntax);
598             }
599             else
600             {
601                 std::string symname = iter->first;
602                 if (symname != method.name)
603                 {
604                     symname.append(formatString(" (synonym for %s)", method.name));
605                 }
606                 file.writeLine(symname);
607             }
608         }
609     }
610 }
611
612 } // namespace
613
614 /*! \cond internal */
615 HelpTopicPointer createSelectionHelpTopic()
616 {
617     CompositeHelpTopicPointer root(new CompositeHelpTopic<CommonHelpText>);
618     root->registerSubTopic<SimpleHelpTopic<ArithmeticHelpText> >();
619     root->registerSubTopic<SimpleHelpTopic<CmdLineHelpText> >();
620     root->registerSubTopic<SimpleHelpTopic<EvaluationHelpText> >();
621     root->registerSubTopic<SimpleHelpTopic<ExamplesHelpText> >();
622     root->registerSubTopic<KeywordsHelpTopic>();
623     root->registerSubTopic<SimpleHelpTopic<LimitationsHelpText> >();
624     root->registerSubTopic<SimpleHelpTopic<PositionsHelpText> >();
625     root->registerSubTopic<SimpleHelpTopic<SyntaxHelpText> >();
626     return move(root);
627 }
628 //! \endcond
629
630 } // namespace gmx