void
TrajectoryAnalysisRunnerCommon::initOptions(Options *options)
{
    TrajectoryAnalysisSettings &settings = impl_->settings_;

    // 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"));

    // Add common file name arguments.
    options->addOption(FileNameOption("f")
                           .filetype(eftTrajectory).inputFile()
                           .store(&impl_->trjfile_)
                           .defaultBasename("traj")
                           .description("Input trajectory or single configuration"));
    options->addOption(FileNameOption("s")
                           .filetype(eftTopology).inputFile()
                           .store(&impl_->topfile_)
                           .defaultBasename("topol")
                           .description("Input structure"));
    options->addOption(FileNameOption("n")
                           .filetype(eftIndex).inputFile()
                           .store(&impl_->ndxfile_)
                           .defaultBasename("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)"));

    // Add time unit option.
    settings.impl_->timeUnitManager.addTimeUnitOption(options, "tu");

    // Add plot 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"));
    }
    if (!settings.hasFlag(TrajectoryAnalysisSettings::efNoUserPBC))
    {
        options->addOption(BooleanOption("pbc").store(&settings.impl_->bPBC)
                               .description("Use periodic boundary conditions for distance calculation"));
    }
}
Beispiel #2
0
void
TrajectoryAnalysisRunnerCommon::initOptions(IOptionsContainer *options,
                                            TimeUnitBehavior  *timeUnitBehavior)
{
    TrajectoryAnalysisSettings &settings = impl_->settings_;

    // Add common file name arguments.
    options->addOption(FileNameOption("f")
                           .filetype(eftTrajectory).inputFile()
                           .store(&impl_->trjfile_)
                           .defaultBasename("traj")
                           .description("Input trajectory or single configuration"));
    options->addOption(FileNameOption("s")
                           .filetype(eftTopology).inputFile()
                           .store(&impl_->topfile_)
                           .defaultBasename("topol")
                           .description("Input structure"));

    // Add options for trajectory time control.
    options->addOption(DoubleOption("b")
                           .store(&impl_->startTime_).storeIsSet(&impl_->bStartTimeSet_)
                           .timeValue()
                           .description("First frame (%t) to read from trajectory"));
    options->addOption(DoubleOption("e")
                           .store(&impl_->endTime_).storeIsSet(&impl_->bEndTimeSet_)
                           .timeValue()
                           .description("Last frame (%t) to read from trajectory"));
    options->addOption(DoubleOption("dt")
                           .store(&impl_->deltaTime_).storeIsSet(&impl_->bDeltaTimeSet_)
                           .timeValue()
                           .description("Only use frame if t MOD dt == first time (%t)"));

    // Add time unit option.
    timeUnitBehavior->setTimeUnitFromEnvironment();
    timeUnitBehavior->addTimeUnitOption(options, "tu");
    timeUnitBehavior->setTimeUnitStore(&impl_->settings_.impl_->timeUnit);

    options->addOption(SelectionOption("fgroup")
                           .store(&impl_->trajectoryGroup_)
                           .onlySortedAtoms().onlyStatic()
                           .description("Atoms stored in the trajectory file "
                                        "(if not set, assume first N atoms)"));

    // Add plot options.
    settings.impl_->plotSettings.initOptions(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"));
    }
    if (!settings.hasFlag(TrajectoryAnalysisSettings::efNoUserPBC))
    {
        options->addOption(BooleanOption("pbc").store(&settings.impl_->bPBC)
                               .description("Use periodic boundary conditions for distance calculation"));
    }
}
Beispiel #3
0
void
Distance::initOptions(Options *options, TrajectoryAnalysisSettings * /*settings*/)
{
    static const char *const desc[] = {
        "g_dist can calculate the distance between two positions as",
        "a function of time. The total distance and its",
        "x, y and z components are plotted."
    };

    options->setDescription(concatenateStrings(desc));

    options->addOption(FileNameOption("o").filetype(eftPlot).outputFile()
                           .store(&fnDist_).defaultBasename("dist")
                           .description("Computed distances"));
    options->addOption(SelectionOption("select").required().valueCount(2)
                           .store(sel_));
}
Beispiel #4
0
void
Angle::initOptions(Options *options, TrajectoryAnalysisSettings * /*settings*/)
{
    static const char *const desc[] = {
        "g_angle computes different types of angles between vectors.",
        "It supports both vectors defined by two positions and normals of",
        "planes defined by three positions.",
        "The z axis or the local normal of a sphere can also be used as",
        "one of the vectors.",
        "There are also convenience options 'angle' and 'dihedral' for",
        "calculating bond angles and dihedrals defined by three/four",
        "positions.[PAR]",
        "The type of the angle is specified with [TT]-g1[tt] and [TT]-g2[tt].",
        "If [TT]-g1[tt] is [TT]angle[tt] or [TT]dihedral[tt], [TT]-g2[tt]",
        "should not be specified.",
        "In this case, [TT]-group1[tt] should specify one selection,",
        "and it should contain triplets or quartets of positions that define",
        "the angles to be calculated.[PAR]",
        "If [TT]-g1[tt] is [TT]vector[tt] or [TT]plane[tt], [TT]-group1[tt]",
        "should specify a selection that has either pairs ([TT]vector[tt])",
        "or triplets ([TT]plane[tt]) of positions. For vectors, the positions",
        "set the endpoints of the vector, and for planes, the three positions",
        "are used to calculate the normal of the plane. In both cases,",
        "[TT]-g2[tt] specifies the other vector to use (see below).[PAR]",
        "With [TT]-g2 vector[tt] or [TT]-g2 plane[tt], [TT]-group2[tt] should",
        "specify another set of vectors. Both selections should specify the",
        "same number of vectors.[PAR]",
        "With [TT]-g2 sphnorm[tt], [TT]-group2[tt] should specify a single",
        "position that is the center of the sphere. The second vector is then",
        "calculated as the vector from the center to the midpoint of the",
        "positions specified by [TT]-group1[tt].[PAR]",
        "With [TT]-g2 z[tt], [TT]-group2[tt] is not necessary, and angles",
        "between the first vectors and the positive Z axis are calculated.[PAR]",
        "With [TT]-g2 t0[tt], [TT]-group2[tt] is not necessary, and angles",
        "are calculated from the vectors as they are in the first frame.[PAR]",
        "There are two options for output:",
        "[TT]-oav[tt] writes an xvgr file with the time and the average angle",
        "for each frame.",
        "[TT]-oall[tt] writes all the individual angles."
        /* TODO: Consider if the dump option is necessary and how to best
         * implement it.
           "[TT]-od[tt] can be used to dump all the individual angles,",
           "each on a separate line. This format is better suited for",
           "further processing, e.g., if angles from multiple runs are needed."
         */
    };
    static const char *const cGroup1TypeEnum[] =
    { "angle", "dihedral", "vector", "plane" };
    static const char *const cGroup2TypeEnum[] =
    { "none", "vector", "plane", "t0", "z", "sphnorm" };

    options->setDescription(concatenateStrings(desc));

    options->addOption(FileNameOption("oav").filetype(eftPlot).outputFile()
                           .store(&fnAverage_).defaultBasename("angaver")
                           .description("Average angles as a function of time"));
    options->addOption(FileNameOption("oall").filetype(eftPlot).outputFile()
                           .store(&fnAll_).defaultBasename("angles")
                           .description("All angles as a function of time"));
    // TODO: Add histogram output.

    options->addOption(StringOption("g1").enumValue(cGroup1TypeEnum)
                           .defaultEnumIndex(0).store(&g1type_)
                           .description("Type of analysis/first vector group"));
    options->addOption(StringOption("g2").enumValue(cGroup2TypeEnum)
                           .defaultEnumIndex(0).store(&g2type_)
                           .description("Type of second vector group"));

    // TODO: Allow multiple angles to be computed in one invocation.
    // Most of the code already supports it, but requires a solution for
    // Redmine issue #1010.
    // TODO: Consider what is the best way to support dynamic selections.
    // Again, most of the code already supports it, but it needs to be
    // considered how should -oall work, and additional checks should be added.
    sel1info_ = options->addOption(SelectionOption("group1")
                                       .required().onlyStatic().storeVector(&sel1_)
                                       .description("First analysis/vector selection"));
    sel2info_ = options->addOption(SelectionOption("group2")
                                       .onlyStatic().storeVector(&sel2_)
                                       .description("Second analysis/vector selection"));
}
Beispiel #5
0
Options *
Angle::initOptions(TrajectoryAnalysisSettings *settings)
{
    static const char *const desc[] = {
        "g_angle computes different types of angles between vectors.",
        "It supports both vectors defined by two positions and normals of",
        "planes defined by three positions.",
        "The z axis or the local normal of a sphere can also be used as",
        "one of the vectors.",
        "There are also convenience options 'angle' and 'dihedral' for",
        "calculating bond angles and dihedrals defined by three/four",
        "positions.[PAR]",
        "The type of the angle is specified with [TT]-g1[tt] and [TT]-g2[tt].",
        "If [TT]-g1[tt] is [TT]angle[tt] or [TT]dihedral[tt], [TT]-g2[tt]",
        "should not be specified.",
        "In this case, one selection is required, and it should contain",
        "triplets or quartets of positions that define the angles to be",
        "calculated.",
        "If [TT]-g1[tt] is not [TT]angle[tt] or [TT]dihedral[tt], [TT]-g2[tt]",
        "should not be [TT]none[tt], and the two options define two vectors",
        "for the calculation. For vectors ([TT]vector[tt]), a selection with",
        "pairs of positions is required, and for planes ([TT]plane[tt]),",
        "triplets of positions are required.",
        "If both vectors are specified by positions, the number of vectors",
        "should be the same in both selections.",
        "[TT]-g2 sphnorm[tt] requires a reference selection that defines",
        "the center of the sphere.",
        "[TT]-g2 z[tt] does not require any selection.[PAR]",
        "With [TT]-split1[tt], the positions for [TT]-g1[tt] are specified",
        "using N separate selections with M positions each, instead of the",
        "default M*N positions in one selection.",
        "[TT]-split2[tt] does the same for [TT]-g2[tt].[PAR]",
        "There are two options for output:",
        "[TT]-o[tt] writes an xvgr file with the time and the average angle",
        "for each frame.",
        "With [TT]-all[tt], also the individual angles are written (only",
        "supported for static selections).",
        "[TT]-od[tt] can be used to dump all the individual angles,",
        "each on a separate line. This format is better suited for",
        "further processing, e.g., if angles from multiple runs are needed.",
        NULL
    };
    static const char *const cGroup1TypeEnum[] =
        { "angle", "dihedral", "vector", "plane", NULL };
    static const char *const cGroup2TypeEnum[] =
        { "none", "vector", "plane", "t0", "z", "sphnorm", NULL };

    _options.setDescription(desc);

    _options.addOption(FileNameOption("o").filetype(eftPlot).writeOnly()
                           .store(&_fnAngle).defaultValueIfSet("angle"));
    _options.addOption(FileNameOption("od").filetype(eftPlot).writeOnly()
                           .store(&_fnDump).defaultValueIfSet("angdump"));

    _options.addOption(StringOption("g1").enumValue(cGroup1TypeEnum)
        .defaultEnumIndex(0).store(&_g1type)
        .description("Type of analysis/first vector group"));
    _options.addOption(StringOption("g2").enumValue(cGroup2TypeEnum)
        .defaultEnumIndex(0).store(&_g2type)
        .description("Type of second vector group"));
    _options.addOption(BooleanOption("split1").store(&_bSplit1)
        .description("Each position of first group in separate selection"));
    _options.addOption(BooleanOption("split2").store(&_bSplit2)
        .description("Each position of second group in separate selection"));
    _options.addOption(BooleanOption("multi").store(&_bMulti)
        .description("Analyze multiple sets of angles/dihedrals"));
    _options.addOption(BooleanOption("all").store(&_bAll)
        .description("Print individual angles together with the average"));
    _options.addOption(BooleanOption("dumpd").store(&_bDumpDist)
        .description("Write also distances with -od"));

    _options.addOption(SelectionOption("group1").multiValue().required()
        .dynamicOnlyWhole().storeVector(&_sel1).getAdjuster(&_sel1Adj)
        .description("First analysis/vector selection"));
    _options.addOption(SelectionOption("group2").multiValue()
        .dynamicOnlyWhole().storeVector(&_sel2).getAdjuster(&_sel2Adj)
        .description("Second analysis/vector selection"));

    return &_options;
}