Angle::Angle()
: TrajectoryAnalysisModule(name, shortDescription),
- sel1info_(NULL), sel2info_(NULL), natoms1_(0), natoms2_(0)
+ sel1info_(NULL), sel2info_(NULL), binWidth_(1.0), natoms1_(0), natoms2_(0)
{
averageModule_.reset(new AnalysisDataFrameAverageModule());
angles_.addModule(averageModule_);
+ histogramModule_.reset(new AnalysisDataSimpleHistogramModule());
+ angles_.addModule(histogramModule_);
registerAnalysisDataset(&angles_, "angle");
registerBasicDataset(averageModule_.get(), "average");
+ registerBasicDataset(&histogramModule_->averager(), "histogram");
}
"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:",
+ "There are three 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."
+ "[TT]-oall[tt] writes all the individual angles.",
+ "[TT]-oh[tt] writes a histogram of the angles. The bin width can be",
+ "set with [TT]-binw[tt]."
/* 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,",
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(FileNameOption("oh").filetype(eftPlot).outputFile()
+ .store(&fnHistogram_).defaultBasename("anghist")
+ .description("Histogram of the angles"));
options->addOption(StringOption("g1").enumValue(cGroup1TypeEnum)
.defaultEnumIndex(0).store(&g1type_)
options->addOption(StringOption("g2").enumValue(cGroup2TypeEnum)
.defaultEnumIndex(0).store(&g2type_)
.description("Type of second vector group"));
+ options->addOption(DoubleOption("binw").store(&binWidth_)
+ .description("Binwidth for -oh in degrees"));
// TODO: Allow multiple angles to be computed in one invocation.
// Most of the code already supports it, but requires a solution for
checkSelections(sel1_, sel2_);
angles_.setColumnCount(sel1_[0].posCount() / natoms1_);
+ double histogramMin = (g1type_ == "dihedral" ? -180.0 : 0);
+ histogramModule_->init(histogramFromRange(histogramMin, 180.0)
+ .binWidth(binWidth_).includeAll());
if (g2type_ == "t0")
{
// TODO: Add legends? (there can be a massive amount of columns)
angles_.addModule(plotm);
}
+
+ if (!fnHistogram_.empty())
+ {
+ AnalysisDataPlotModulePointer plotm(
+ new AnalysisDataPlotModule(settings.plotSettings()));
+ plotm->setFileName(fnHistogram_);
+ plotm->setTitle("Angle histogram");
+ plotm->setXLabel("Angle (degrees)");
+ plotm->setYLabel("Probability");
+ // TODO: Add legends
+ histogramModule_->averager().addModule(plotm);
+ }
}
void
Angle::finishAnalysis(int /*nframes*/)
{
+ AbstractAverageHistogram &averageHistogram = histogramModule_->averager();
+ averageHistogram.normalizeProbability();
+ averageHistogram.done();
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2011,2012, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013, by the GROMACS development team, led by
* David van der Spoel, Berk Hess, Erik Lindahl, and including many
* others, as listed in the AUTHORS file in the top-level source
* directory and at http://www.gromacs.org.
#include "../analysismodule.h"
#include "gromacs/analysisdata/analysisdata.h"
#include "gromacs/analysisdata/modules/average.h"
+#include "gromacs/analysisdata/modules/histogram.h"
#include "gromacs/selection/selection.h"
namespace gmx
void checkSelections(const SelectionList &sel1,
const SelectionList &sel2) const;
- SelectionList sel1_;
- SelectionList sel2_;
- SelectionOptionInfo *sel1info_;
- SelectionOptionInfo *sel2info_;
- std::string fnAverage_;
- std::string fnAll_;
-
- std::string g1type_;
- std::string g2type_;
-
- AnalysisData angles_;
- AnalysisDataFrameAverageModulePointer averageModule_;
- int natoms1_;
- int natoms2_;
+ SelectionList sel1_;
+ SelectionList sel2_;
+ SelectionOptionInfo *sel1info_;
+ SelectionOptionInfo *sel2info_;
+ std::string fnAverage_;
+ std::string fnAll_;
+ std::string fnHistogram_;
+
+ std::string g1type_;
+ std::string g2type_;
+ double binWidth_;
+
+ AnalysisData angles_;
+ AnalysisDataFrameAverageModulePointer averageModule_;
+ AnalysisDataSimpleHistogramModulePointer histogramModule_;
+ int natoms1_;
+ int natoms2_;
// TODO: It is not possible to put rvec into a container.
- std::vector<rvec *> vt0_;
+ std::vector<rvec *> vt0_;
// Copy and assign disallowed by base.
};
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013, by the GROMACS development team, led by
* David van der Spoel, Berk Hess, Erik Lindahl, and including many
* others, as listed in the AUTHORS file in the top-level source
* directory and at http://www.gromacs.org.
{
const char *const cmdline[] = {
"angle",
- "-g1", "angle", "-group1", "resname RA1 RA2 and name A1 A2 A3"
+ "-g1", "angle", "-group1", "resname RA1 RA2 and name A1 A2 A3",
+ "-binw", "60"
};
setTopology("angle.gro");
runTest(CommandLine::create(cmdline));
{
const char *const cmdline[] = {
"angle",
- "-g1", "dihedral", "-group1", "resname RD1 RD2 RD3 and name A1 A2 A3 A4"
+ "-g1", "dihedral", "-group1", "resname RD1 RD2 RD3 and name A1 A2 A3 A4",
+ "-binw", "120"
};
setTopology("angle.gro");
runTest(CommandLine::create(cmdline));
const char *const cmdline[] = {
"angle",
"-g1", "vector", "-group1", "resname RV1 RV2 and name A1 A2",
- "-g2", "vector", "-group2", "resname RV3 RV4 and name A1 A2"
+ "-g2", "vector", "-group2", "resname RV3 RV4 and name A1 A2",
+ "-binw", "60"
};
setTopology("angle.gro");
runTest(CommandLine::create(cmdline));
const char *const cmdline[] = {
"angle",
"-g1", "vector", "-group1", "resname RV1 RV2 and name A1 A2",
- "-g2", "plane", "-group2", "resname RP1 RP2 and name A1 A2 A3"
+ "-g2", "plane", "-group2", "resname RP1 RP2 and name A1 A2 A3",
+ "-binw", "60"
};
setTopology("angle.gro");
runTest(CommandLine::create(cmdline));
const char *const cmdline[] = {
"angle",
"-g1", "plane", "-group1", "resname RP1 RP2 and name A1 A2 A3",
- "-g2", "z"
+ "-g2", "z",
+ "-binw", "60"
};
setTopology("angle.gro");
runTest(CommandLine::create(cmdline));
const char *const cmdline[] = {
"angle",
"-g1", "vector", "-group1", "resname RV1 RV2 and name A1 A2",
- "-g2", "sphnorm", "-group2", "cog of resname RS"
+ "-g2", "sphnorm", "-group2", "cog of resname RS",
+ "-binw", "60"
};
setTopology("angle.gro");
runTest(CommandLine::create(cmdline));
const char *const cmdline[] = {
"angle",
"-g1", "vector", "-group1", "resname RV1 RV2 RV3 RV4 and name A1 A2",
- "-g2", "t0"
+ "-g2", "t0",
+ "-binw", "60"
};
setTopology("angle.gro");
setTrajectory("angle.gro");
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
<ReferenceData>
- <String Name="CommandLine">angle -g1 dihedral -group1 'resname RD1 RD2 RD3 and name A1 A2 A3 A4'</String>
+ <String Name="CommandLine">angle -g1 dihedral -group1 'resname RD1 RD2 RD3 and name A1 A2 A3 A4' -binw 120</String>
<OutputData Name="Data">
<AnalysisData Name="angle">
<DataFrame Name="Frame0">
</Sequence>
</DataFrame>
</AnalysisData>
+ <AnalysisData Name="histogram">
+ <DataFrame Name="Frame0">
+ <Real Name="X">-120.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.002778</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame1">
+ <Real Name="X">0.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.002778</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame2">
+ <Real Name="X">120.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.002778</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ </AnalysisData>
</OutputData>
</ReferenceData>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
<ReferenceData>
- <String Name="CommandLine">angle -g1 plane -group1 'resname RP1 RP2 and name A1 A2 A3' -g2 z</String>
+ <String Name="CommandLine">angle -g1 plane -group1 'resname RP1 RP2 and name A1 A2 A3' -g2 z -binw 60</String>
<OutputData Name="Data">
<AnalysisData Name="angle">
<DataFrame Name="Frame0">
</Sequence>
</DataFrame>
</AnalysisData>
+ <AnalysisData Name="histogram">
+ <DataFrame Name="Frame0">
+ <Real Name="X">30.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.008333</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame1">
+ <Real Name="X">90.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame2">
+ <Real Name="X">150.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.008333</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ </AnalysisData>
</OutputData>
</ReferenceData>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
<ReferenceData>
- <String Name="CommandLine">angle -g1 angle -group1 'resname RA1 RA2 and name A1 A2 A3'</String>
+ <String Name="CommandLine">angle -g1 angle -group1 'resname RA1 RA2 and name A1 A2 A3' -binw 60</String>
<OutputData Name="Data">
<AnalysisData Name="angle">
<DataFrame Name="Frame0">
</Sequence>
</DataFrame>
</AnalysisData>
+ <AnalysisData Name="histogram">
+ <DataFrame Name="Frame0">
+ <Real Name="X">30.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.008333</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame1">
+ <Real Name="X">90.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame2">
+ <Real Name="X">150.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.008333</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ </AnalysisData>
</OutputData>
</ReferenceData>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
<ReferenceData>
- <String Name="CommandLine">angle -g1 vector -group1 'resname RV1 RV2 and name A1 A2' -g2 vector -group2 'resname RV3 RV4 and name A1 A2'</String>
+ <String Name="CommandLine">angle -g1 vector -group1 'resname RV1 RV2 and name A1 A2' -g2 vector -group2 'resname RV3 RV4 and name A1 A2' -binw 60</String>
<OutputData Name="Data">
<AnalysisData Name="angle">
<DataFrame Name="Frame0">
</Sequence>
</DataFrame>
</AnalysisData>
+ <AnalysisData Name="histogram">
+ <DataFrame Name="Frame0">
+ <Real Name="X">30.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.008333</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame1">
+ <Real Name="X">90.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.008333</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame2">
+ <Real Name="X">150.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ </AnalysisData>
</OutputData>
</ReferenceData>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
<ReferenceData>
- <String Name="CommandLine">angle -g1 vector -group1 'resname RV1 RV2 and name A1 A2' -g2 plane -group2 'resname RP1 RP2 and name A1 A2 A3'</String>
+ <String Name="CommandLine">angle -g1 vector -group1 'resname RV1 RV2 and name A1 A2' -g2 plane -group2 'resname RP1 RP2 and name A1 A2 A3' -binw 60</String>
<OutputData Name="Data">
<AnalysisData Name="angle">
<DataFrame Name="Frame0">
</Sequence>
</DataFrame>
</AnalysisData>
+ <AnalysisData Name="histogram">
+ <DataFrame Name="Frame0">
+ <Real Name="X">30.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.008333</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame1">
+ <Real Name="X">90.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.008333</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame2">
+ <Real Name="X">150.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ </AnalysisData>
</OutputData>
</ReferenceData>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
<ReferenceData>
- <String Name="CommandLine">angle -g1 vector -group1 'resname RV1 RV2 and name A1 A2' -g2 sphnorm -group2 'cog of resname RS'</String>
+ <String Name="CommandLine">angle -g1 vector -group1 'resname RV1 RV2 and name A1 A2' -g2 sphnorm -group2 'cog of resname RS' -binw 60</String>
<OutputData Name="Data">
<AnalysisData Name="angle">
<DataFrame Name="Frame0">
</Sequence>
</DataFrame>
</AnalysisData>
+ <AnalysisData Name="histogram">
+ <DataFrame Name="Frame0">
+ <Real Name="X">30.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.008333</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame1">
+ <Real Name="X">90.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.008333</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame2">
+ <Real Name="X">150.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.000000</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ </AnalysisData>
</OutputData>
</ReferenceData>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
<ReferenceData>
- <String Name="CommandLine">angle -g1 vector -group1 'resname RV1 RV2 RV3 RV4 and name A1 A2' -g2 t0</String>
+ <String Name="CommandLine">angle -g1 vector -group1 'resname RV1 RV2 RV3 RV4 and name A1 A2' -g2 t0 -binw 60</String>
<OutputData Name="Data">
<AnalysisData Name="angle">
<DataFrame Name="Frame0">
</Sequence>
</DataFrame>
</AnalysisData>
+ <AnalysisData Name="histogram">
+ <DataFrame Name="Frame0">
+ <Real Name="X">30.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.012500</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.004167</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame1">
+ <Real Name="X">90.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.002083</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.002083</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ <DataFrame Name="Frame2">
+ <Real Name="X">150.000000</Real>
+ <Sequence Name="Y">
+ <Int Name="Length">2</Int>
+ <DataValue>
+ <Real Name="Value">0.002083</Real>
+ </DataValue>
+ <DataValue>
+ <Real Name="Value">0.002083</Real>
+ </DataValue>
+ </Sequence>
+ </DataFrame>
+ </AnalysisData>
</OutputData>
</ReferenceData>