public:
AnalysisTemplate();
- virtual Options &initOptions(TrajectoryAnalysisSettings *settings);
+ virtual void initOptions(Options *options,
+ TrajectoryAnalysisSettings *settings);
virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
const TopologyInformation &top);
private:
class ModuleData;
- Options options_;
-
std::string fnDist_;
double cutoff_;
Selection refsel_;
AnalysisTemplate::AnalysisTemplate()
- : options_("template", "Template options"), cutoff_(0.0)
+ : TrajectoryAnalysisModule("template", "Template analysis tool"),
+ cutoff_(0.0)
{
registerAnalysisDataset(&data_, "avedist");
}
-Options &
-AnalysisTemplate::initOptions(TrajectoryAnalysisSettings *settings)
+void
+AnalysisTemplate::initOptions(Options *options,
+ TrajectoryAnalysisSettings *settings)
{
static const char *const desc[] = {
"This is a template for writing your own analysis tools for",
"analysis groups."
};
- options_.setDescription(concatenateStrings(desc));
+ options->setDescription(concatenateStrings(desc));
- options_.addOption(FileNameOption("o")
+ options->addOption(FileNameOption("o")
.filetype(eftPlot).outputFile()
.store(&fnDist_).defaultValueIfSet("avedist")
.description("Average distances from reference group"));
- options_.addOption(SelectionOption("reference")
+ options->addOption(SelectionOption("reference")
.store(&refsel_).required()
.description("Reference group to calculate distances from"));
- options_.addOption(SelectionOption("select")
+ options->addOption(SelectionOption("select")
.storeVector(&sel_).required().multiValue()
.description("Groups to calculate distances to"));
- options_.addOption(DoubleOption("cutoff").store(&cutoff_)
+ options->addOption(DoubleOption("cutoff").store(&cutoff_)
.description("Cutoff for distance calculation (0 = no cutoff)"));
settings->setFlag(TrajectoryAnalysisSettings::efRequireTop);
-
- return options_;
}
* to set up options understood by the module, as well as for setting up
* different options through gmx::TrajectoryAnalysisSettings (see the
* documentation of that class for more details):
- * \skip Options &
- * \until return options_;
+ * \skip void
+ * \until settings->
* \until }
* For the template, we first set a description text for the tool (used for
* help text). Then we declare an option to specify the output file name,
*
* To adjust settings or selection options (e.g., the number of accepted
* selections) based on option values, you need to override
- * gmx::TrajectoryAnalysisModule::initOptionsDone(). For simplicity,
+ * gmx::TrajectoryAnalysisModule::optionsFinished(). For simplicity,
* this is not done in the template.
*
*
#include "../legacyheaders/typedefs.h"
#include "../onlinehelp/helptopicinterface.h"
-#include "../options/options.h"
#include "../utility/uniqueptr.h"
#include "indexutil.h"
#include "poscalc.h"
//! Internal data, used for interfacing with old C code.
gmx_ana_selcollection_t sc_;
- //! Options object for setting global properties on the collection.
- Options options_;
//! Default reference position type for selections.
std::string rpost_;
//! Default output position type for selections.
*/
SelectionCollection::Impl::Impl()
- : options_("selection", "Common selection control"),
- debugLevel_(0), bExternalGroupsSet_(false), grps_(NULL)
+ : debugLevel_(0), bExternalGroupsSet_(false), grps_(NULL)
{
sc_.root = NULL;
sc_.nvars = 0;
}
-Options &
-SelectionCollection::initOptions()
+void
+SelectionCollection::initOptions(Options *options)
{
static const char * const debug_levels[]
= {"no", "basic", "compile", "eval", "full", NULL};
options.setDescription(desc);
*/
- Options &options = impl_->options_;
const char *const *postypes = PositionCalculationCollection::typeEnumValues;
- options.addOption(StringOption("selrpos").enumValue(postypes)
- .store(&impl_->rpost_).defaultValue(postypes[0])
- .description("Selection reference positions"));
- options.addOption(StringOption("seltype").enumValue(postypes)
- .store(&impl_->spost_).defaultValue(postypes[0])
- .description("Default selection output positions"));
+ options->addOption(StringOption("selrpos").enumValue(postypes)
+ .store(&impl_->rpost_).defaultValue(postypes[0])
+ .description("Selection reference positions"));
+ options->addOption(StringOption("seltype").enumValue(postypes)
+ .store(&impl_->spost_).defaultValue(postypes[0])
+ .description("Default selection output positions"));
GMX_RELEASE_ASSERT(impl_->debugLevel_ >= 0 && impl_->debugLevel_ <= 4,
"Debug level out of range");
- options.addOption(StringOption("seldebug").hidden(impl_->debugLevel_ == 0)
- .enumValue(debug_levels)
- .defaultValue(debug_levels[impl_->debugLevel_])
- .storeEnumIndex(&impl_->debugLevel_)
- .description("Print out selection trees for debugging"));
-
- return impl_->options_;
+ options->addOption(StringOption("seldebug").hidden(impl_->debugLevel_ == 0)
+ .enumValue(debug_levels)
+ .defaultValue(debug_levels[impl_->debugLevel_])
+ .storeEnumIndex(&impl_->debugLevel_)
+ .description("Print out selection trees for debugging"));
}
/*! \brief
* Initializes options for setting global properties on the collection.
*
- * \returns Initialized options object.
- * \throws std::bad_alloc if out of memory.
+ * \param[in,out] options Options object to initialize.
+ * \throws std::bad_alloc if out of memory.
*
- * The returned options can be used to set the default position types
- * (see setReferencePosType() and setOutputPosType()) and debugging
- * options.
+ * Adds options to \p options that can be used to set the default
+ * position types (see setReferencePosType() and setOutputPosType())
+ * and debugging flags.
*/
- Options &initOptions();
+ void initOptions(Options *options);
/*! \brief
* Sets the default reference position handling for a selection
//! Container that associates a AnalysisData object with its name.
typedef std::map<std::string, AnalysisData *> AnalysisDatasetContainer;
+ //! Initializes analysis module data with given name and description.
+ Impl(const char *name, const char *description)
+ : name_(name), description_(description)
+ {
+ }
+
+ //! Name of the module.
+ std::string name_;
+ //! Description of the module.
+ std::string description_;
//! List of registered data set names.
std::vector<std::string> datasetNames_;
/*! \brief
* TrajectoryAnalysisModule
*/
-TrajectoryAnalysisModule::TrajectoryAnalysisModule()
- : impl_(new Impl)
+TrajectoryAnalysisModule::TrajectoryAnalysisModule(const char *name,
+ const char *description)
+ : impl_(new Impl(name, description))
{
}
}
-void TrajectoryAnalysisModule::initOptionsDone(TrajectoryAnalysisSettings * /*settings*/)
+void TrajectoryAnalysisModule::optionsFinished(
+ Options * /*options*/,
+ TrajectoryAnalysisSettings * /*settings*/)
{
}
}
+const char *TrajectoryAnalysisModule::name() const
+{
+ return impl_->name_.c_str();
+}
+
+
+const char *TrajectoryAnalysisModule::description() const
+{
+ return impl_->description_.c_str();
+}
+
+
int TrajectoryAnalysisModule::datasetCount() const
{
return impl_->datasetNames_.size();
*
* Trajectory analysis methods should derive from this class and override the
* necessary virtual methods to implement initialization (initOptions(),
- * initOptionsDone(), initAnalysis(), initAfterFirstFrame()), per-frame analysis
+ * optionsFinished(), initAnalysis(), initAfterFirstFrame()), per-frame analysis
* (analyzeFrame()), and final processing (finishFrames(), finishAnalysis(),
* writeOutput()).
*
/*! \brief
* Initializes options understood by the module.
*
+ * \param[in,out] options Options object to add the options to.
* \param[in,out] settings Settings to pass to and from the module.
- * \returns Reference to options that are accepted by the module.
*
- * Typical implementation returns a reference to a member variable
- * after first adding necessary options to that object. Output values
+ * This method is called first after the constructor, and it should
+ * add options understood by the module to \p options. Output values
* from options (including selections) should be stored in member
* variables.
*
* \p settings object; see TrajectoryAnalysisSettings for more details.
*
* If settings depend on the option values provided by the user, see
- * initOptionsDone().
+ * optionsFinished().
*/
- virtual Options &initOptions(TrajectoryAnalysisSettings *settings) = 0;
+ virtual void initOptions(Options *options,
+ TrajectoryAnalysisSettings *settings) = 0;
/*! \brief
* Called after all option values have been set.
*
+ * \param[in,out] options Options object in which options are stored.
* \param[in,out] settings Settings to pass to and from the module.
*
* This method is called after option values have been assigned (but
*
* The default implementation does nothing.
*/
- virtual void initOptionsDone(TrajectoryAnalysisSettings *settings);
+ virtual void optionsFinished(Options *options,
+ TrajectoryAnalysisSettings *settings);
/*! \brief
* Initializes the analysis.
*
*/
virtual void writeOutput() = 0;
+ /*! \brief
+ * Returns the name of the analysis module.
+ *
+ * Does not throw.
+ */
+ const char *name() const;
+ /*! \brief
+ * Returns short description for the analysis module.
+ *
+ * Does not throw.
+ */
+ const char *description() const;
/*! \brief
* Returns the number of datasets provided by the module.
*
/*! \brief
* Initializes the dataset registration mechanism.
*
- * \throws std::bad_alloc if out of memory.
+ * \param[in] name Name for the module.
+ * \param[in] description One-line description for the module.
+ * \throws std::bad_alloc if out of memory.
*/
- TrajectoryAnalysisModule();
+ TrajectoryAnalysisModule(const char *name, const char *description);
/*! \brief
* Registers a dataset that exports data.
*
* Returns the value set with setPBC() and/or overridden by the user.
* The user-provided value can be accessed in
- * TrajectoryAnalysisModule::initOptionsDone(), and can be overridden
+ * TrajectoryAnalysisModule::optionsFinished(), and can be overridden
* with a call to setPBC().
*/
bool hasPBC() const;
bool parseOptions(TrajectoryAnalysisSettings *settings,
TrajectoryAnalysisRunnerCommon *common,
SelectionCollection *selections,
- SelectionOptionManager *seloptManager,
- Options *options,
int *argc, char *argv[]);
TrajectoryAnalysisModule *module_;
TrajectoryAnalysisSettings *settings,
TrajectoryAnalysisRunnerCommon *common,
SelectionCollection *selections,
- SelectionOptionManager *seloptManager,
- Options *options,
int *argc, char *argv[])
{
- Options &moduleOptions = module_->initOptions(settings);
- Options &commonOptions = common->initOptions();
- Options &selectionOptions = selections->initOptions();
+ Options options(NULL, NULL);
+ Options moduleOptions(module_->name(), module_->description());
+ Options commonOptions("common", "Common analysis control");
+ Options selectionOptions("selection", "Common selection control");
+ module_->initOptions(&moduleOptions, settings);
+ common->initOptions(&commonOptions);
+ selections->initOptions(&selectionOptions);
- options->addSubSection(&commonOptions);
- options->addSubSection(&selectionOptions);
- options->addSubSection(&moduleOptions);
+ options.addSubSection(&commonOptions);
+ options.addSubSection(&selectionOptions);
+ options.addSubSection(&moduleOptions);
- setManagerForSelectionOptions(options, seloptManager);
+ SelectionOptionManager seloptManager(selections);
+ setManagerForSelectionOptions(&options, &seloptManager);
{
- CommandLineParser parser(options);
+ CommandLineParser parser(&options);
try
{
parser.parse(argc, argv);
}
catch (const UserInputError &ex)
{
- printHelp(*options, *settings, *common);
+ printHelp(options, *settings, *common);
throw;
}
- printHelp(*options, *settings, *common);
- common->scaleTimeOptions(options);
- options->finish();
+ printHelp(options, *settings, *common);
+ common->scaleTimeOptions(&options);
+ options.finish();
}
- if (!common->initOptionsDone())
+ if (!common->optionsFinished(&commonOptions))
{
return false;
}
- module_->initOptionsDone(settings);
+ module_->optionsFinished(&moduleOptions, settings);
common->initIndexGroups(selections);
// TODO: Check whether the input is a pipe.
bool bInteractive = true;
- seloptManager->parseRequestedFromStdin(bInteractive);
+ seloptManager.parseRequestedFromStdin(bInteractive);
common->doneIndexGroups(selections);
return true;
SelectionCollection selections;
selections.setDebugLevel(impl_->debugLevel_);
- SelectionOptionManager seloptManager(&selections);
TrajectoryAnalysisSettings settings;
TrajectoryAnalysisRunnerCommon common(&settings);
- Options options(NULL, NULL);
- if (!impl_->parseOptions(&settings, &common, &selections, &seloptManager,
- &options, &argc, argv))
+ if (!impl_->parseOptions(&settings, &common, &selections, &argc, argv))
{
return 0;
}
// TODO: This method duplicates some code from run() and Impl::printHelp().
// See how to best refactor it to share the common code.
SelectionCollection selections;
- SelectionOptionManager seloptManager(&selections);
TrajectoryAnalysisSettings settings;
TrajectoryAnalysisRunnerCommon common(&settings);
- Options options(NULL, NULL);
- Options &moduleOptions = impl_->module_->initOptions(&settings);
- Options &commonOptions = common.initOptions();
- Options &selectionOptions = selections.initOptions();
+ Options options(NULL, NULL);
+ Options moduleOptions(impl_->module_->name(), impl_->module_->description());
+ Options commonOptions("common", "Common analysis control");
+ Options selectionOptions("selection", "Common selection control");
+
+ impl_->module_->initOptions(&moduleOptions, &settings);
+ common.initOptions(&commonOptions);
+ selections.initOptions(&selectionOptions);
options.addSubSection(&commonOptions);
options.addSubSection(&selectionOptions);
options.addSubSection(&moduleOptions);
+ SelectionOptionManager seloptManager(&selections);
setManagerForSelectionOptions(&options, &seloptManager);
CommandLineHelpWriter(options)
"Calculate angles";
Angle::Angle()
- : options_(name, shortDescription),
+ : TrajectoryAnalysisModule(name, shortDescription),
sel1info_(NULL), sel2info_(NULL),
bSplit1_(false), bSplit2_(false), bMulti_(false), bAll_(false),
bDumpDist_(false), natoms1_(0), natoms2_(0), vt0_(NULL)
}
-Options &
-Angle::initOptions(TrajectoryAnalysisSettings *settings)
+void
+Angle::initOptions(Options *options, TrajectoryAnalysisSettings * /*settings*/)
{
static const char *const desc[] = {
"g_angle computes different types of angles between vectors.",
static const char *const cGroup2TypeEnum[] =
{ "none", "vector", "plane", "t0", "z", "sphnorm", NULL };
- options_.setDescription(concatenateStrings(desc));
+ options->setDescription(concatenateStrings(desc));
- options_.addOption(FileNameOption("o").filetype(eftPlot).outputFile()
+ options->addOption(FileNameOption("o").filetype(eftPlot).outputFile()
.store(&fnAngle_).defaultValueIfSet("angle")
.description("Computed angles"));
- options_.addOption(FileNameOption("od").filetype(eftPlot).outputFile()
+ options->addOption(FileNameOption("od").filetype(eftPlot).outputFile()
.store(&fnDump_).defaultValueIfSet("angdump")
.description("Individual angles on separate lines"));
- options_.addOption(StringOption("g1").enumValue(cGroup1TypeEnum)
+ options->addOption(StringOption("g1").enumValue(cGroup1TypeEnum)
.defaultEnumIndex(0).store(&g1type_)
.description("Type of analysis/first vector group"));
- options_.addOption(StringOption("g2").enumValue(cGroup2TypeEnum)
+ options->addOption(StringOption("g2").enumValue(cGroup2TypeEnum)
.defaultEnumIndex(0).store(&g2type_)
.description("Type of second vector group"));
- options_.addOption(BooleanOption("split1").store(&bSplit1_)
+ options->addOption(BooleanOption("split1").store(&bSplit1_)
.description("Each position of first group in separate selection"));
- options_.addOption(BooleanOption("split2").store(&bSplit2_)
+ options->addOption(BooleanOption("split2").store(&bSplit2_)
.description("Each position of second group in separate selection"));
- options_.addOption(BooleanOption("multi").store(&bMulti_)
+ options->addOption(BooleanOption("multi").store(&bMulti_)
.description("Analyze multiple sets of angles/dihedrals"));
- options_.addOption(BooleanOption("all").store(&bAll_)
+ options->addOption(BooleanOption("all").store(&bAll_)
.description("Print individual angles together with the average"));
- options_.addOption(BooleanOption("dumpd").store(&bDumpDist_)
+ options->addOption(BooleanOption("dumpd").store(&bDumpDist_)
.description("Write also distances with -od"));
- options_.addOption(SelectionOption("group1").multiValue().required()
+ options->addOption(SelectionOption("group1").multiValue().required()
.dynamicOnlyWhole().storeVector(&sel1_).getAdjuster(&sel1info_)
.description("First analysis/vector selection"));
- options_.addOption(SelectionOption("group2").multiValue()
+ options->addOption(SelectionOption("group2").multiValue()
.dynamicOnlyWhole().storeVector(&sel2_).getAdjuster(&sel2info_)
.description("Second analysis/vector selection"));
-
- return options_;
}
void
-Angle::initOptionsDone(TrajectoryAnalysisSettings *settings)
+Angle::optionsFinished(Options *options, TrajectoryAnalysisSettings *settings)
{
// Validity checks.
bool bSingle = (g1type_[0] == 'a' || g1type_[0] == 'd');
GMX_THROW(InconsistentInputError("Cannot use a second group (-g2) with "
"-g1 angle or dihedral"));
}
- if (bSingle && options_.isSet("group2"))
+ if (bSingle && options->isSet("group2"))
{
GMX_THROW(InconsistentInputError("Cannot provide a second selection "
"(-group2) with -g1 angle or dihedral"));
default:
GMX_THROW(InternalError("invalid -g2 value"));
}
- if (natoms2_ == 0 && options_.isSet("group2"))
+ if (natoms2_ == 0 && options->isSet("group2"))
{
GMX_THROW(InconsistentInputError("Cannot provide a second selection (-group2) with -g2 t0 or z"));
}
#include "../analysismodule.h"
#include "gromacs/analysisdata/analysisdata.h"
-#include "gromacs/options/options.h"
#include "gromacs/selection/selection.h"
namespace gmx
Angle();
virtual ~Angle();
- virtual Options &initOptions(TrajectoryAnalysisSettings *settings);
- virtual void initOptionsDone(TrajectoryAnalysisSettings *settings);
+ virtual void initOptions(Options *options,
+ TrajectoryAnalysisSettings *settings);
+ virtual void optionsFinished(Options *options,
+ TrajectoryAnalysisSettings *settings);
virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
const TopologyInformation &top);
void checkSelections(const SelectionList &sel1,
const SelectionList &sel2) const;
- Options options_;
-
SelectionList sel1_;
SelectionList sel2_;
SelectionOptionInfo *sel1info_;
"Calculate distances";
Distance::Distance()
- : options_(name, shortDescription), avem_(new AnalysisDataAverageModule())
+ : TrajectoryAnalysisModule(name, shortDescription),
+ avem_(new AnalysisDataAverageModule())
{
data_.setColumnCount(4);
registerAnalysisDataset(&data_, "distance");
}
-Options &
-Distance::initOptions(TrajectoryAnalysisSettings *settings)
+void
+Distance::initOptions(Options *options, TrajectoryAnalysisSettings * /*settings*/)
{
static const char *const desc[] = {
"g_dist can calculate the distance between two positions as",
"x, y and z components are plotted."
};
- options_.setDescription(concatenateStrings(desc));
+ options->setDescription(concatenateStrings(desc));
- options_.addOption(FileNameOption("o").filetype(eftPlot).outputFile()
+ options->addOption(FileNameOption("o").filetype(eftPlot).outputFile()
.store(&fnDist_).defaultValueIfSet("dist")
.description("Computed distances"));
- options_.addOption(SelectionOption("select").required().valueCount(2)
+ options->addOption(SelectionOption("select").required().valueCount(2)
.store(sel_));
- return options_;
}
#include "../analysismodule.h"
#include "gromacs/analysisdata/analysisdata.h"
#include "gromacs/analysisdata/modules/average.h"
-#include "gromacs/options/options.h"
#include "gromacs/selection/selection.h"
namespace gmx
Distance();
virtual ~Distance();
- virtual Options &initOptions(TrajectoryAnalysisSettings *settings);
+ virtual void initOptions(Options *options,
+ TrajectoryAnalysisSettings *settings);
virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
const TopologyInformation &top);
virtual void writeOutput();
private:
- Options options_;
std::string fnDist_;
Selection sel_[2];
AnalysisData data_;
"Print general information about selections";
Select::Select()
- : options_(name, shortDescription),
+ : TrajectoryAnalysisModule(name, shortDescription),
bDump_(false), bTotNorm_(false), bFracNorm_(false), bResInd_(false),
top_(NULL)
{
}
-Options &
-Select::initOptions(TrajectoryAnalysisSettings *settings)
+void
+Select::initOptions(Options *options, TrajectoryAnalysisSettings * /*settings*/)
{
static const char *const desc[] = {
"[TT]g_select[tt] writes out basic data about dynamic selections.",
"With [TT]-dump[tt], the frame time is omitted from the output."
};
- options_.setDescription(concatenateStrings(desc));
+ options->setDescription(concatenateStrings(desc));
- options_.addOption(FileNameOption("os").filetype(eftPlot).outputFile()
+ options->addOption(FileNameOption("os").filetype(eftPlot).outputFile()
.store(&fnSize_).defaultValueIfSet("size")
.description("Number of positions in each selection"));
- options_.addOption(FileNameOption("oc").filetype(eftPlot).outputFile()
+ options->addOption(FileNameOption("oc").filetype(eftPlot).outputFile()
.store(&fnFrac_).defaultValueIfSet("frac")
.description("Covered fraction for each selection"));
- options_.addOption(FileNameOption("oi").filetype(eftGenericData).outputFile()
+ options->addOption(FileNameOption("oi").filetype(eftGenericData).outputFile()
.store(&fnIndex_).defaultValueIfSet("index")
.description("Indices selected by each selection"));
- options_.addOption(FileNameOption("on").filetype(eftIndex).outputFile()
+ options->addOption(FileNameOption("on").filetype(eftIndex).outputFile()
.store(&fnNdx_).defaultValueIfSet("index")
.description("Index file from the selection"));
- options_.addOption(FileNameOption("om").filetype(eftPlot).outputFile()
+ options->addOption(FileNameOption("om").filetype(eftPlot).outputFile()
.store(&fnMask_).defaultValueIfSet("mask")
.description("Mask for selected positions"));
- options_.addOption(SelectionOption("select").storeVector(&sel_)
+ options->addOption(SelectionOption("select").storeVector(&sel_)
.required().multiValue()
.description("Selections to analyze"));
- options_.addOption(BooleanOption("dump").store(&bDump_)
+ options->addOption(BooleanOption("dump").store(&bDump_)
.description("Do not print the frame time (-om, -oi) or the index size (-oi)"));
- options_.addOption(BooleanOption("norm").store(&bTotNorm_)
+ options->addOption(BooleanOption("norm").store(&bTotNorm_)
.description("Normalize by total number of positions with -os"));
- options_.addOption(BooleanOption("cfnorm").store(&bFracNorm_)
+ options->addOption(BooleanOption("cfnorm").store(&bFracNorm_)
.description("Normalize by covered fraction with -os"));
const char *const cResNumberEnum[] = { "number", "index", NULL };
- options_.addOption(StringOption("resnr").store(&resNumberType_)
+ options->addOption(StringOption("resnr").store(&resNumberType_)
.enumValue(cResNumberEnum).defaultEnumIndex(0)
.description("Residue number output type"));
-
- return options_;
}
#include "../analysismodule.h"
#include "gromacs/analysisdata/analysisdata.h"
-#include "gromacs/options/options.h"
#include "gromacs/selection/selection.h"
namespace gmx
Select();
virtual ~Select();
- virtual Options &initOptions(TrajectoryAnalysisSettings *settings);
+ virtual void initOptions(Options *options,
+ TrajectoryAnalysisSettings *settings);
virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
const TopologyInformation &top);
virtual void writeOutput();
private:
- Options options_;
SelectionList sel_;
std::string fnSize_;
void finishTrajectory();
TrajectoryAnalysisSettings &settings_;
- Options options_;
TopologyInformation topInfo_;
bool bHelp_;
TrajectoryAnalysisRunnerCommon::Impl::Impl(TrajectoryAnalysisSettings *settings)
- : settings_(*settings), options_("common", "Common analysis control"),
+ : settings_(*settings),
bHelp_(false), bShowHidden_(false), bQuiet_(false),
startTime_(0.0), endTime_(0.0), deltaTime_(0.0),
grps_(NULL),
}
-Options &
-TrajectoryAnalysisRunnerCommon::initOptions()
+void
+TrajectoryAnalysisRunnerCommon::initOptions(Options *options)
{
TrajectoryAnalysisSettings &settings = impl_->settings_;
- Options &options = impl_->options_;
// Add options for help.
- options.addOption(BooleanOption("h").store(&impl_->bHelp_)
- .description("Print help and quit"));
- options.addOption(BooleanOption("hidden").store(&impl_->bShowHidden_)
- .hidden()
- .description("Show hidden options"));
- options.addOption(BooleanOption("quiet").store(&impl_->bQuiet_)
- .hidden()
- .description("Hide options in normal run"));
+ options->addOption(BooleanOption("h").store(&impl_->bHelp_)
+ .description("Print help and quit"));
+ options->addOption(BooleanOption("hidden").store(&impl_->bShowHidden_)
+ .hidden()
+ .description("Show hidden options"));
+ options->addOption(BooleanOption("quiet").store(&impl_->bQuiet_)
+ .hidden()
+ .description("Hide options in normal run"));
// Add common file name arguments.
- options.addOption(FileNameOption("f")
- .filetype(eftTrajectory).inputFile()
- .store(&impl_->trjfile_)
- .defaultValueIfSet("traj")
- .description("Input trajectory or single configuration"));
- options.addOption(FileNameOption("s")
- .filetype(eftTopology).inputFile()
- .store(&impl_->topfile_)
- .defaultValueIfSet("topol")
- .description("Input structure"));
- options.addOption(FileNameOption("n")
- .filetype(eftIndex).inputFile()
- .store(&impl_->ndxfile_)
- .defaultValueIfSet("index")
- .description("Extra index groups"));
- options.addOption(SelectionFileOption("sf"));
+ options->addOption(FileNameOption("f")
+ .filetype(eftTrajectory).inputFile()
+ .store(&impl_->trjfile_)
+ .defaultValueIfSet("traj")
+ .description("Input trajectory or single configuration"));
+ options->addOption(FileNameOption("s")
+ .filetype(eftTopology).inputFile()
+ .store(&impl_->topfile_)
+ .defaultValueIfSet("topol")
+ .description("Input structure"));
+ options->addOption(FileNameOption("n")
+ .filetype(eftIndex).inputFile()
+ .store(&impl_->ndxfile_)
+ .defaultValueIfSet("index")
+ .description("Extra index groups"));
+ options->addOption(SelectionFileOption("sf"));
// Add options for trajectory time control.
- options.addOption(DoubleOption("b").store(&impl_->startTime_).timeValue()
- .description("First frame (%t) to read from trajectory"));
- options.addOption(DoubleOption("e").store(&impl_->endTime_).timeValue()
- .description("Last frame (%t) to read from trajectory"));
- options.addOption(DoubleOption("dt").store(&impl_->deltaTime_).timeValue()
- .description("Only use frame if t MOD dt == first time (%t)"));
+ options->addOption(DoubleOption("b").store(&impl_->startTime_).timeValue()
+ .description("First frame (%t) to read from trajectory"));
+ options->addOption(DoubleOption("e").store(&impl_->endTime_).timeValue()
+ .description("Last frame (%t) to read from trajectory"));
+ options->addOption(DoubleOption("dt").store(&impl_->deltaTime_).timeValue()
+ .description("Only use frame if t MOD dt == first time (%t)"));
// Add time unit option.
- settings.impl_->timeUnitManager.addTimeUnitOption(&options, "tu");
+ settings.impl_->timeUnitManager.addTimeUnitOption(options, "tu");
// Add plot options.
- settings.impl_->plotSettings.addOptions(&options);
+ settings.impl_->plotSettings.addOptions(options);
// Add common options for trajectory processing.
if (!settings.hasFlag(TrajectoryAnalysisSettings::efNoUserRmPBC))
{
- options.addOption(BooleanOption("rmpbc").store(&settings.impl_->bRmPBC)
- .description("Make molecules whole for each frame"));
+ options->addOption(BooleanOption("rmpbc").store(&settings.impl_->bRmPBC)
+ .description("Make molecules whole for each frame"));
}
if (!settings.hasFlag(TrajectoryAnalysisSettings::efNoUserPBC))
{
- options.addOption(BooleanOption("pbc").store(&settings.impl_->bPBC)
- .description("Use periodic boundary conditions for distance calculation"));
+ options->addOption(BooleanOption("pbc").store(&settings.impl_->bPBC)
+ .description("Use periodic boundary conditions for distance calculation"));
}
-
- return impl_->options_;
}
bool
-TrajectoryAnalysisRunnerCommon::initOptionsDone()
+TrajectoryAnalysisRunnerCommon::optionsFinished(Options *options)
{
if (impl_->bHelp_)
{
GMX_THROW(InconsistentInputError("No trajectory or topology provided, nothing to do!"));
}
- if (impl_->options_.isSet("b"))
+ if (options->isSet("b"))
setTimeValue(TBEGIN, impl_->startTime_);
- if (impl_->options_.isSet("e"))
+ if (options->isSet("e"))
setTimeValue(TEND, impl_->endTime_);
- if (impl_->options_.isSet("dt"))
+ if (options->isSet("dt"))
setTimeValue(TDELTA, impl_->deltaTime_);
return true;
explicit TrajectoryAnalysisRunnerCommon(TrajectoryAnalysisSettings *settings);
~TrajectoryAnalysisRunnerCommon();
- //! Initializes common options for trajectory analysis.
- Options &initOptions();
+ /*! \brief
+ * Initializes common options for trajectory analysis.
+ *
+ * \param[in,out] options Options object to add the options to.
+ */
+ void initOptions(Options *options);
//! Scales time option values according to the time unit set.
void scaleTimeOptions(Options *options);
/*! \brief
* Processes common option values after they have been parsed.
*
- * \returns false if the tool should exit after printing help.
+ * \param[in,out] options Options object in which options are stored.
+ * \returns false if the tool should exit after printing help.
*/
- bool initOptionsDone();
+ bool optionsFinished(Options *options);
//! Initialize index groups for selections.
void initIndexGroups(SelectionCollection *selections);
//! Free memory allocated for index groups.
SelectionTester();
virtual ~SelectionTester();
- virtual Options &initOptions(TrajectoryAnalysisSettings *settings);
+ virtual void initOptions(Options *options,
+ TrajectoryAnalysisSettings *settings);
virtual void initAnalysis(const TrajectoryAnalysisSettings &settings,
const TopologyInformation &top);
private:
void printSelections();
- Options options_;
SelectionList selections_;
int nmaxind_;
};
SelectionTester::SelectionTester()
- : options_("testing", "Selection testing and debugging"),
+ : TrajectoryAnalysisModule("testing", "Selection testing and debugging"),
nmaxind_(20)
{
}
fprintf(stderr, "\n");
}
-Options &
-SelectionTester::initOptions(TrajectoryAnalysisSettings * /*settings*/)
+void
+SelectionTester::initOptions(Options *options,
+ TrajectoryAnalysisSettings * /*settings*/)
{
static const char *const desc[] = {
"This is a test program for selections."
};
- options_.setDescription(concatenateStrings(desc));
+ options->setDescription(concatenateStrings(desc));
- options_.addOption(SelectionOption("select").storeVector(&selections_)
+ options->addOption(SelectionOption("select").storeVector(&selections_)
.required().multiValue()
.description("Selections to test"));
- options_.addOption(IntegerOption("pmax").store(&nmaxind_)
+ options->addOption(IntegerOption("pmax").store(&nmaxind_)
.description("Maximum number of indices to print in lists (-1 = print all)"));
-
- return options_;
}
void