2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2010-2018, The GROMACS development team.
5 * Copyright (c) 2019, by the GROMACS development team, led by
6 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7 * and including many others, as listed in the AUTHORS file in the
8 * top-level source directory and at http://www.gromacs.org.
10 * GROMACS is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1
13 * of the License, or (at your option) any later version.
15 * GROMACS is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with GROMACS; if not, see
22 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * If you want to redistribute modifications to GROMACS, please
26 * consider that scientific software is very special. Version
27 * control is crucial - bugs must be traceable. We will be happy to
28 * consider code for inclusion in the official distribution, but
29 * derived work must not be called official GROMACS. Details are found
30 * in the README & COPYING files - if they are missing, get the
31 * official version at http://www.gromacs.org.
33 * To help us fund GROMACS development, we humbly ask that you cite
34 * the research papers on the package. Check out http://www.gromacs.org.
38 * Implements gmx::SelectionCollection.
40 * \author Teemu Murtola <teemu.murtola@gmail.com>
41 * \ingroup module_selection
45 #include "selectioncollection.h"
54 #include "gromacs/onlinehelp/helpmanager.h"
55 #include "gromacs/onlinehelp/helpwritercontext.h"
56 #include "gromacs/options/basicoptions.h"
57 #include "gromacs/options/ioptionscontainer.h"
58 #include "gromacs/selection/selection.h"
59 #include "gromacs/selection/selhelp.h"
60 #include "gromacs/topology/mtop_util.h"
61 #include "gromacs/topology/topology.h"
62 #include "gromacs/trajectory/trajectoryframe.h"
63 #include "gromacs/utility/exceptions.h"
64 #include "gromacs/utility/filestream.h"
65 #include "gromacs/utility/gmxassert.h"
66 #include "gromacs/utility/smalloc.h"
67 #include "gromacs/utility/stringutil.h"
68 #include "gromacs/utility/textwriter.h"
75 #include "selectioncollection_impl.h"
77 #include "selmethod.h"
83 /********************************************************************
84 * SelectionCollection::Impl
87 SelectionCollection::Impl::Impl() : debugLevel_(0), bExternalGroupsSet_(false), grps_(nullptr)
90 sc_.varstrs = nullptr;
92 gmx_ana_index_clear(&sc_.gall);
93 sc_.mempool = nullptr;
94 sc_.symtab = std::make_unique<SelectionParserSymbolTable>();
95 gmx_ana_index_clear(&requiredAtoms_);
96 gmx_ana_selmethod_register_defaults(sc_.symtab.get());
100 SelectionCollection::Impl::~Impl()
103 // The tree must be freed before the SelectionData objects, since the
104 // tree may hold references to the position data in SelectionData.
107 for (int i = 0; i < sc_.nvars; ++i)
109 sfree(sc_.varstrs[i]);
112 gmx_ana_index_deinit(&sc_.gall);
115 _gmx_sel_mempool_destroy(sc_.mempool);
117 gmx_ana_index_deinit(&requiredAtoms_);
121 void SelectionCollection::Impl::clearSymbolTable()
131 * Reads a single selection line from stdin.
133 * \param[in] inputStream Stream to read from (typically the StandardInputStream).
134 * \param[in] statusWriter Stream to print prompts to (if NULL, no output is done).
135 * \param[out] line The read line in stored here.
136 * \returns true if something was read, false if at end of input.
138 * Handles line continuation, reading also the continuing line(s) in one call.
140 bool promptLine(TextInputStream* inputStream, TextWriter* statusWriter, std::string* line)
142 if (statusWriter != nullptr)
144 statusWriter->writeString("> ");
146 if (!inputStream->readLine(line))
150 while (endsWith(*line, "\\\n"))
152 line->resize(line->length() - 2);
153 if (statusWriter != nullptr)
155 statusWriter->writeString("... ");
158 // Return value ignored, buffer remains empty and works correctly
159 // if there is nothing to read.
160 inputStream->readLine(&buffer);
161 line->append(buffer);
163 if (endsWith(*line, "\n"))
165 line->resize(line->length() - 1);
167 else if (statusWriter != nullptr)
169 statusWriter->writeLine();
175 * Helper function for tokenizing the input and pushing them to the parser.
177 * \param scanner Tokenizer data structure.
178 * \param parserState Parser data structure.
179 * \param[in] bInteractive Whether to operate in interactive mode.
181 * Repeatedly reads tokens using \p scanner and pushes them to the parser with
182 * \p parserState until there is no more input, or until enough input is given
183 * (only in interactive mode).
185 int runParserLoop(yyscan_t scanner, _gmx_sel_yypstate* parserState, bool bInteractive)
187 int status = YYPUSH_MORE;
192 int token = _gmx_sel_yylex(&value, &location, scanner);
193 if (bInteractive && token == 0)
197 status = _gmx_sel_yypush_parse(parserState, token, &value, &location, scanner);
198 } while (status == YYPUSH_MORE);
199 _gmx_sel_lexer_rethrow_exception_if_occurred(scanner);
204 * Print current status in response to empty line in interactive input.
206 * \param[in] writer Writer to use for the output.
207 * \param[in] sc Selection collection data structure.
208 * \param[in] grps Available index groups.
209 * \param[in] firstSelection Index of first selection from this interactive
211 * \param[in] maxCount Maximum number of selections.
212 * \param[in] context Context to print for what the selections are for.
213 * \param[in] bFirst Whether this is the header that is printed before
216 * Prints the available index groups and currently provided selections.
218 void printCurrentStatus(TextWriter* writer,
219 gmx_ana_selcollection_t* sc,
220 gmx_ana_indexgrps_t* grps,
221 size_t firstSelection,
223 const std::string& context,
228 writer->writeLine("Available static index groups:");
229 gmx_ana_indexgrps_print(writer, grps, 0);
231 writer->writeString("Specify ");
234 writer->writeString("any number of selections");
236 else if (maxCount == 1)
238 writer->writeString("a selection");
242 writer->writeString(formatString("%d selections", maxCount));
244 writer->writeString(formatString("%s%s:\n", context.empty() ? "" : " ", context.c_str()));
246 formatString("(one per line, <enter> for status/groups, 'help' for help%s)\n",
247 maxCount < 0 ? ", Ctrl-D to end" : ""));
248 if (!bFirst && (sc->nvars > 0 || sc->sel.size() > firstSelection))
250 writer->writeLine("Currently provided selections:");
251 for (int i = 0; i < sc->nvars; ++i)
253 writer->writeString(formatString(" %s\n", sc->varstrs[i]));
255 for (size_t i = firstSelection; i < sc->sel.size(); ++i)
257 writer->writeString(formatString(" %2d. %s\n", static_cast<int>(i - firstSelection + 1),
258 sc->sel[i]->selectionText()));
262 const int remaining = maxCount - static_cast<int>(sc->sel.size() - firstSelection);
263 writer->writeString(formatString("(%d more selection%s required)\n", remaining,
264 remaining > 1 ? "s" : ""));
270 * Prints selection help in interactive selection input.
272 * \param[in] writer Writer to use for the output.
273 * \param[in] sc Selection collection data structure.
274 * \param[in] line Line of user input requesting help (starting with `help`).
276 * Initializes the selection help if not yet initialized, and finds the help
277 * topic based on words on the input line.
279 void printHelp(TextWriter* writer, gmx_ana_selcollection_t* sc, const std::string& line)
281 if (sc->rootHelp.get() == nullptr)
283 sc->rootHelp = createSelectionHelpTopic();
285 HelpWriterContext context(writer, eHelpOutputFormat_Console);
286 HelpManager manager(*sc->rootHelp, context);
289 std::vector<std::string> topic = splitString(line);
290 std::vector<std::string>::const_iterator value;
291 // First item in the list is the 'help' token.
292 for (value = topic.begin() + 1; value != topic.end(); ++value)
294 manager.enterTopic(*value);
297 catch (const InvalidInputError& ex)
299 writer->writeLine(ex.what());
302 manager.writeCurrentTopic();
306 * Helper function that runs the parser once the tokenizer has been
309 * \param[in,out] scanner Scanner data structure.
310 * \param[in] inputStream Stream to use for input (currently only with
311 * `bInteractive==true`).
312 * \param[in] bInteractive Whether to use a line-based reading
313 * algorithm designed for interactive input.
314 * \param[in] maxnr Maximum number of selections to parse
315 * (if -1, parse as many as provided by the user).
316 * \param[in] context Context to print for what the selections are for.
317 * \returns Vector of parsed selections.
318 * \throws std::bad_alloc if out of memory.
319 * \throws InvalidInputError if there is a parsing error.
321 * Used internally to implement parseInteractive(), parseFromFile() and
324 SelectionList runParser(yyscan_t scanner,
325 TextInputStream* inputStream,
328 const std::string& context)
330 std::shared_ptr<void> scannerGuard(scanner, &_gmx_sel_free_lexer);
331 gmx_ana_selcollection_t* sc = _gmx_sel_lexer_selcollection(scanner);
332 gmx_ana_indexgrps_t* grps = _gmx_sel_lexer_indexgrps(scanner);
334 size_t oldCount = sc->sel.size();
336 std::shared_ptr<_gmx_sel_yypstate> parserState(_gmx_sel_yypstate_new(), &_gmx_sel_yypstate_delete);
339 TextWriter* statusWriter = _gmx_sel_lexer_get_status_writer(scanner);
340 if (statusWriter != nullptr)
342 printCurrentStatus(statusWriter, sc, grps, oldCount, maxnr, context, true);
346 while (promptLine(inputStream, statusWriter, &line))
348 if (statusWriter != nullptr)
350 line = stripString(line);
353 printCurrentStatus(statusWriter, sc, grps, oldCount, maxnr, context, false);
356 if (startsWith(line, "help") && (line[4] == 0 || (std::isspace(line[4]) != 0)))
358 printHelp(statusWriter, sc, line);
363 _gmx_sel_set_lex_input_str(scanner, line.c_str());
364 status = runParserLoop(scanner, parserState.get(), true);
365 if (status != YYPUSH_MORE)
367 // TODO: Check if there is more input, and issue an
368 // error/warning if some input was ignored.
369 goto early_termination;
374 status = _gmx_sel_yypush_parse(parserState.get(), 0, nullptr, &location, scanner);
376 // TODO: Remove added selections from the collection if parsing failed?
377 _gmx_sel_lexer_rethrow_exception_if_occurred(scanner);
379 GMX_RELEASE_ASSERT(status == 0, "Parser errors should have resulted in an exception");
383 int status = runParserLoop(scanner, parserState.get(), false);
384 GMX_RELEASE_ASSERT(status == 0, "Parser errors should have resulted in an exception");
387 scannerGuard.reset();
388 int nr = sc->sel.size() - oldCount;
389 if (maxnr > 0 && nr != maxnr)
391 std::string message = formatString("Too few selections provided; got %d, expected %d", nr, maxnr);
392 GMX_THROW(InvalidInputError(message));
395 SelectionList result;
396 SelectionDataList::const_iterator i;
398 for (i = sc->sel.begin() + oldCount; i != sc->sel.end(); ++i)
400 result.emplace_back(i->get());
406 * Checks that index groups have valid atom indices.
408 * \param[in] root Root of selection tree to process.
409 * \param[in] natoms Maximum number of atoms that the selections are set
411 * \param errors Object for reporting any error messages.
412 * \throws std::bad_alloc if out of memory.
414 * Recursively checks the selection tree for index groups.
415 * Each found group is checked that it only contains atom indices that match
416 * the topology/maximum number of atoms set for the selection collection.
417 * Any issues are reported to \p errors.
419 void checkExternalGroups(const SelectionTreeElementPointer& root, int natoms, ExceptionInitializer* errors)
421 if (root->type == SEL_CONST && root->v.type == GROUP_VALUE)
425 root->checkIndexGroup(natoms);
427 catch (const UserInputError&)
429 errors->addCurrentExceptionAsNested();
433 SelectionTreeElementPointer child = root->child;
436 checkExternalGroups(child, natoms, errors);
441 //! Checks whether the given topology properties are available.
442 void checkTopologyProperties(const gmx_mtop_t* top, const SelectionTopologyProperties& props)
448 GMX_THROW(InconsistentInputError(
449 "Selection requires topology information, but none provided"));
453 if (props.needsMasses && !gmx_mtop_has_masses(top))
455 GMX_THROW(InconsistentInputError(
456 "Selection requires mass information, but it is not available in the topology"));
463 void SelectionCollection::Impl::resolveExternalGroups(const SelectionTreeElementPointer& root,
464 ExceptionInitializer* errors)
467 if (root->type == SEL_GROUPREF)
471 root->resolveIndexGroupReference(grps_, sc_.gall.isize);
473 catch (const UserInputError&)
475 errors->addCurrentExceptionAsNested();
479 SelectionTreeElementPointer child = root->child;
482 resolveExternalGroups(child, errors);
483 root->flags |= (child->flags & SEL_UNSORTED);
489 bool SelectionCollection::Impl::areForcesRequested() const
491 for (const auto& sel : sc_.sel)
493 if (sel->hasFlag(gmx::efSelection_EvaluateForces))
502 SelectionTopologyProperties
503 SelectionCollection::Impl::requiredTopologyPropertiesForPositionType(const std::string& post, bool forces) const
505 SelectionTopologyProperties props;
508 switch (PositionCalculationCollection::requiredTopologyInfoForType(post.c_str(), forces))
510 case PositionCalculationCollection::RequiredTopologyInfo::None: break;
511 case PositionCalculationCollection::RequiredTopologyInfo::Topology:
512 props.merge(SelectionTopologyProperties::topology());
514 case PositionCalculationCollection::RequiredTopologyInfo::TopologyAndMasses:
515 props.merge(SelectionTopologyProperties::masses());
523 /********************************************************************
524 * SelectionCollection
527 SelectionCollection::SelectionCollection() : impl_(new Impl) {}
530 SelectionCollection::~SelectionCollection() {}
533 void SelectionCollection::initOptions(IOptionsContainer* options, SelectionTypeOption selectionTypeOption)
535 const char* const debug_levels[] = { "no", "basic", "compile", "eval", "full" };
537 const char* const* postypes = PositionCalculationCollection::typeEnumValues;
538 options->addOption(StringOption("selrpos")
539 .enumValueFromNullTerminatedArray(postypes)
540 .store(&impl_->rpost_)
541 .defaultValue(postypes[0])
542 .description("Selection reference positions"));
543 if (selectionTypeOption == IncludeSelectionTypeOption)
545 options->addOption(StringOption("seltype")
546 .enumValueFromNullTerminatedArray(postypes)
547 .store(&impl_->spost_)
548 .defaultValue(postypes[0])
549 .description("Default selection output positions"));
553 impl_->spost_ = postypes[0];
555 GMX_RELEASE_ASSERT(impl_->debugLevel_ >= 0 && impl_->debugLevel_ <= 4,
556 "Debug level out of range");
557 options->addOption(EnumIntOption("seldebug")
558 .hidden(impl_->debugLevel_ == 0)
559 .enumValue(debug_levels)
560 .store(&impl_->debugLevel_)
561 .description("Print out selection trees for debugging"));
565 void SelectionCollection::setReferencePosType(const char* type)
567 GMX_RELEASE_ASSERT(type != nullptr, "Cannot assign NULL position type");
568 // Check that the type is valid, throw if it is not.
569 e_poscalc_t dummytype;
571 PositionCalculationCollection::typeFromEnum(type, &dummytype, &dummyflags);
572 impl_->rpost_ = type;
576 void SelectionCollection::setOutputPosType(const char* type)
578 GMX_RELEASE_ASSERT(type != nullptr, "Cannot assign NULL position type");
579 // Check that the type is valid, throw if it is not.
580 e_poscalc_t dummytype;
582 PositionCalculationCollection::typeFromEnum(type, &dummytype, &dummyflags);
583 impl_->spost_ = type;
587 void SelectionCollection::setDebugLevel(int debugLevel)
589 impl_->debugLevel_ = debugLevel;
593 void SelectionCollection::setTopology(gmx_mtop_t* top, int natoms)
595 GMX_RELEASE_ASSERT(natoms > 0 || top != nullptr,
596 "The number of atoms must be given if there is no topology");
597 checkTopologyProperties(top, requiredTopologyProperties());
598 // Get the number of atoms from the topology if it is not given.
601 natoms = top->natoms;
603 if (impl_->bExternalGroupsSet_)
605 ExceptionInitializer errors("Invalid index group references encountered");
606 SelectionTreeElementPointer root = impl_->sc_.root;
609 checkExternalGroups(root, natoms, &errors);
612 if (errors.hasNestedExceptions())
614 GMX_THROW(InconsistentInputError(errors));
617 gmx_ana_selcollection_t* sc = &impl_->sc_;
618 // Do this first, as it allocates memory, while the others don't throw.
619 gmx_ana_index_init_simple(&sc->gall, natoms);
621 sc->pcc.setTopology(top);
625 void SelectionCollection::setIndexGroups(gmx_ana_indexgrps_t* grps)
627 GMX_RELEASE_ASSERT(grps == nullptr || !impl_->bExternalGroupsSet_,
628 "Can only set external groups once or clear them afterwards");
630 impl_->bExternalGroupsSet_ = true;
632 ExceptionInitializer errors("Invalid index group reference(s)");
633 SelectionTreeElementPointer root = impl_->sc_.root;
636 impl_->resolveExternalGroups(root, &errors);
637 root->checkUnsortedAtoms(true, &errors);
640 if (errors.hasNestedExceptions())
642 GMX_THROW(InconsistentInputError(errors));
644 for (size_t i = 0; i < impl_->sc_.sel.size(); ++i)
646 impl_->sc_.sel[i]->refreshName();
650 SelectionTopologyProperties SelectionCollection::requiredTopologyProperties() const
652 SelectionTopologyProperties props;
654 // These should not throw, because has been checked earlier.
655 props.merge(impl_->requiredTopologyPropertiesForPositionType(impl_->rpost_, false));
656 const bool forcesRequested = impl_->areForcesRequested();
657 props.merge(impl_->requiredTopologyPropertiesForPositionType(impl_->spost_, forcesRequested));
659 SelectionTreeElementPointer sel = impl_->sc_.root;
660 while (sel && !props.hasAll())
662 props.merge(sel->requiredTopologyProperties());
669 bool SelectionCollection::requiresIndexGroups() const
671 SelectionTreeElementPointer sel = impl_->sc_.root;
674 if (sel->requiresIndexGroups())
684 SelectionList SelectionCollection::parseFromStdin(int count, bool bInteractive, const std::string& context)
686 return parseInteractive(count, &StandardInputStream::instance(),
687 bInteractive ? &TextOutputFile::standardError() : nullptr, context);
693 //! Helper function to initialize status writer for interactive selection parsing.
694 std::unique_ptr<TextWriter> initStatusWriter(TextOutputStream* statusStream)
696 std::unique_ptr<TextWriter> statusWriter;
697 if (statusStream != nullptr)
699 statusWriter = std::make_unique<TextWriter>(statusStream);
700 statusWriter->wrapperSettings().setLineLength(78);
707 SelectionList SelectionCollection::parseInteractive(int count,
708 TextInputStream* inputStream,
709 TextOutputStream* statusStream,
710 const std::string& context)
714 const std::unique_ptr<TextWriter> statusWriter(initStatusWriter(statusStream));
715 _gmx_sel_init_lexer(&scanner, &impl_->sc_, statusWriter.get(), count,
716 impl_->bExternalGroupsSet_, impl_->grps_);
717 return runParser(scanner, inputStream, true, count, context);
721 SelectionList SelectionCollection::parseFromFile(const std::string& filename)
727 TextInputFile file(filename);
728 // TODO: Exception-safe way of using the lexer.
729 _gmx_sel_init_lexer(&scanner, &impl_->sc_, nullptr, -1, impl_->bExternalGroupsSet_, impl_->grps_);
730 _gmx_sel_set_lex_input_file(scanner, file.handle());
731 return runParser(scanner, nullptr, false, -1, std::string());
733 catch (GromacsException& ex)
735 ex.prependContext(formatString("Error in parsing selections from file '%s'", filename.c_str()));
741 SelectionList SelectionCollection::parseFromString(const std::string& str)
745 _gmx_sel_init_lexer(&scanner, &impl_->sc_, nullptr, -1, impl_->bExternalGroupsSet_, impl_->grps_);
746 _gmx_sel_set_lex_input_str(scanner, str.c_str());
747 return runParser(scanner, nullptr, false, -1, std::string());
751 void SelectionCollection::compile()
753 checkTopologyProperties(impl_->sc_.top, requiredTopologyProperties());
754 if (!impl_->bExternalGroupsSet_)
756 setIndexGroups(nullptr);
758 if (impl_->debugLevel_ >= 1)
760 printTree(stderr, false);
763 SelectionCompiler compiler;
764 compiler.compile(this);
766 if (impl_->debugLevel_ >= 1)
768 std::fprintf(stderr, "\n");
769 printTree(stderr, false);
770 std::fprintf(stderr, "\n");
771 impl_->sc_.pcc.printTree(stderr);
772 std::fprintf(stderr, "\n");
774 impl_->sc_.pcc.initEvaluation();
775 if (impl_->debugLevel_ >= 1)
777 impl_->sc_.pcc.printTree(stderr);
778 std::fprintf(stderr, "\n");
781 // TODO: It would be nicer to associate the name of the selection option
782 // (if available) to the error message.
783 SelectionDataList::const_iterator iter;
784 for (iter = impl_->sc_.sel.begin(); iter != impl_->sc_.sel.end(); ++iter)
786 const internal::SelectionData& sel = **iter;
787 if (sel.hasFlag(efSelection_OnlyAtoms))
789 if (!sel.hasOnlyAtoms())
791 std::string message = formatString(
792 "Selection '%s' does not evaluate to individual atoms. "
793 "This is not allowed in this context.",
794 sel.selectionText());
795 GMX_THROW(InvalidInputError(message));
797 if (sel.hasFlag(efSelection_OnlySorted))
799 if (!sel.hasSortedAtomIndices())
801 const std::string message = formatString(
802 "Selection '%s' does not evaluate to atoms in an "
803 "ascending (sorted) order. "
804 "This is not allowed in this context.",
805 sel.selectionText());
806 GMX_THROW(InvalidInputError(message));
810 if (sel.hasFlag(efSelection_DisallowEmpty))
812 if (sel.posCount() == 0)
814 std::string message =
815 formatString("Selection '%s' never matches any atoms.", sel.selectionText());
816 GMX_THROW(InvalidInputError(message));
820 impl_->rpost_.clear();
821 impl_->spost_.clear();
825 void SelectionCollection::evaluate(t_trxframe* fr, t_pbc* pbc)
827 checkTopologyProperties(impl_->sc_.top, requiredTopologyProperties());
831 gmx_ana_index_set(&g, fr->natoms, fr->index, 0);
832 GMX_RELEASE_ASSERT(gmx_ana_index_check_sorted(&g),
833 "Only trajectories with atoms in ascending order "
834 "are currently supported");
835 if (!gmx_ana_index_contains(&g, &impl_->requiredAtoms_))
837 const std::string message = formatString(
838 "Trajectory does not contain all atoms required for "
839 "evaluating the provided selections.");
840 GMX_THROW(InconsistentInputError(message));
845 const int maxAtomIndex = gmx_ana_index_get_max_index(&impl_->requiredAtoms_);
846 if (fr->natoms <= maxAtomIndex)
848 const std::string message = formatString(
849 "Trajectory has less atoms (%d) than what is required for "
850 "evaluating the provided selections (atoms up to index %d "
852 fr->natoms, maxAtomIndex + 1);
853 GMX_THROW(InconsistentInputError(message));
856 impl_->sc_.pcc.initFrame(fr);
858 SelectionEvaluator evaluator;
859 evaluator.evaluate(this, fr, pbc);
861 if (impl_->debugLevel_ >= 3)
863 std::fprintf(stderr, "\n");
864 printTree(stderr, true);
869 void SelectionCollection::evaluateFinal(int nframes)
871 SelectionEvaluator evaluator;
872 evaluator.evaluateFinal(this, nframes);
876 void SelectionCollection::printTree(FILE* fp, bool bValues) const
878 SelectionTreeElementPointer sel = impl_->sc_.root;
881 _gmx_selelem_print_tree(fp, *sel, bValues, 0);
887 void SelectionCollection::printXvgrInfo(FILE* out) const
889 const gmx_ana_selcollection_t& sc = impl_->sc_;
890 std::fprintf(out, "# Selections:\n");
891 for (int i = 0; i < sc.nvars; ++i)
893 std::fprintf(out, "# %s\n", sc.varstrs[i]);
895 for (size_t i = 0; i < sc.sel.size(); ++i)
897 std::fprintf(out, "# %s\n", sc.sel[i]->selectionText());
899 std::fprintf(out, "#\n");