diff --git a/doc/cpptraj.lyx b/doc/cpptraj.lyx
index 9c2d7b97f2..13446a031e 100644
--- a/doc/cpptraj.lyx
+++ b/doc/cpptraj.lyx
@@ -4926,11 +4926,27 @@ Read
\end_layout
\begin_layout LyX-Code
-[ read1d [index
] [onlycols ] ]
+[prec {flt|dbl}]
\end_layout
\begin_layout LyX-Code
-[read2d] [vector] [mat3x3]
+{[read1d [index ] [onlycols ] [floatcols ]
+\end_layout
+
+\begin_layout LyX-Code
+ [intcols ] [stringcols ]] |
+\end_layout
+
+\begin_layout LyX-Code
+ [read2d [{square2d|nosquare2d}]] |
+\end_layout
+
+\begin_layout LyX-Code
+ [vector] |
+\end_layout
+
+\begin_layout LyX-Code
+ [mat3x3] |
\begin_inset Separator latexpar
\end_inset
@@ -4938,20 +4954,24 @@ Read
\end_layout
\begin_layout LyX-Code
-[ read3d [dims ,,] [origin ,,]
+ [read3d [dims ,,] [origin ,,]
\end_layout
\begin_layout LyX-Code
- [delta ,,dz>] [prec {dbl|flt}] [bin {center|corner} ]
+ [delta ,,dz>] [prec {dbl|flt}] [bin {center|corner} ]
+\end_layout
+
+\begin_layout LyX-Code
+}
\end_layout
\begin_deeper
\begin_layout Description
-index
+prec
\begin_inset space ~
\end_inset
- Use column (starting from 1) as index column (1D data only).
+{flt|dbl} Read 2d/3d data as single (flt) or double (dbl, default) precision.
\end_layout
\begin_layout Description
@@ -5001,9 +5021,20 @@ stringcols
\end_deeper
\begin_layout Description
-read2d Read data as 2D square matrix.
+read2d Read data as 2D matrix.
+\end_layout
+
+\begin_deeper
+\begin_layout Description
+square2d Read data as square matrix (default).
\end_layout
+\begin_layout Description
+nosquare2d Read data as XYZ matrix (i.e.
+ each line contains ' ').
+\end_layout
+
+\end_deeper
\begin_layout Description
vector Read data as vector.
If indices are present they will be skipped.
@@ -5107,7 +5138,7 @@ Write
\end_layout
\begin_layout LyX-Code
-[invert] [xydy] []
+[{invert|noinvert}] [{xydy|noxydy}] []
\begin_inset Separator latexpar
\end_inset
@@ -5122,10 +5153,18 @@ invert Normally, data is written out with X-values pertaining to frames
This command flips that behavior so that X-values pertain to data sets.
\end_layout
+\begin_layout Description
+noinvert Do not flip X-Y axes (default).
+\end_layout
+
\begin_layout Description
xydy Combine consecutive pairs of sets into XYDY sets.
\end_layout
+\begin_layout Description
+noxydy Do not combine consecutuve pairs of sets into XYDY sets (default).
+\end_layout
+
\begin_layout Description
]
+[{nolabels|labels}] [{usemap|pm3d|nopm3d}] [title ]
\end_layout
\begin_layout LyX-Code
@@ -5190,6 +5229,10 @@ Write
nolabels Do not print axis labels.
\end_layout
+\begin_layout Description
+labels Print axis labels.
+\end_layout
+
\begin_layout Description
usemap pm3d output with 1 extra empty row/col (may improve look).
\end_layout
@@ -7093,7 +7136,7 @@ The following general commands are available:
\begin_layout Standard
\align center
\begin_inset Tabular
-
+
@@ -7346,6 +7389,26 @@ Quit cpptraj.
|
\begin_inset Text
+\begin_layout Plain Layout
+flatten
+\end_layout
+
+\end_inset
+ |
+
+\begin_inset Text
+
+\begin_layout Plain Layout
+Distribute elements of 2d matrix across 1d array.
+\end_layout
+
+\end_inset
+ |
+
+
+
+\begin_inset Text
+
\begin_layout Plain Layout
go | run
\end_layout
@@ -9747,6 +9810,171 @@ exit | quit
Exit normally.
\end_layout
+\begin_layout Subsection
+flatten
+\end_layout
+
+\begin_layout LyX-Code
+flatten name [mode {sum|avg}]
+\end_layout
+
+\begin_deeper
+\begin_layout Description
+name
+\begin_inset space ~
+\end_inset
+
+ Name of
+\begin_inset Quotes eld
+\end_inset
+
+flattened
+\begin_inset Quotes erd
+\end_inset
+
+ 1D output set(s).
+\end_layout
+
+\begin_layout Description
+mode
+\begin_inset space ~
+\end_inset
+
+{sum|avg} If sum, matrix elements will be summed.
+ If avg, matrix elements will be averaged.
+\end_layout
+
+\begin_layout Description
+ Specify matrices to
+\begin_inset Quotes eld
+\end_inset
+
+flatten
+\begin_inset Quotes erd
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Standard
+DataSets Created
+\end_layout
+
+\begin_layout Description
+ Flattened 1D set if only one input matrix.
+\end_layout
+
+\begin_layout Description
+: Flattened 1D sets when more than one input matrix; index starts
+ from 1.
+\end_layout
+
+\end_deeper
+\begin_layout Standard
+Flatten 1 or more matrices into 1D array(s) by summing or averaging elements.
+ For example, given a matrix with values like this:
+\end_layout
+
+\begin_layout LyX-Code
+X Y Value
+\end_layout
+
+\begin_layout LyX-Code
+1 3 5.0
+\end_layout
+
+\begin_layout LyX-Code
+1 4 4.0
+\end_layout
+
+\begin_layout LyX-Code
+2 3 2.0
+\end_layout
+
+\begin_layout Standard
+The
+\begin_inset Quotes eld
+\end_inset
+
+flattened
+\begin_inset Quotes erd
+\end_inset
+
+ 1D array with mode SUM would be determined as follows:
+\end_layout
+
+\begin_layout LyX-Code
+Element 1 = (5.0/2) + (4.0/2) = 4.5
+\end_layout
+
+\begin_layout LyX-Code
+Element 2 = (2.0/2) = 1.0
+\end_layout
+
+\begin_layout LyX-Code
+Element 3 = (5.0/2) + (2.0/2) = 3.5
+\end_layout
+
+\begin_layout LyX-Code
+Element 4 = (4.0/2) = 2.0
+\end_layout
+
+\begin_layout Standard
+And the final 1D array would look like so:
+\end_layout
+
+\begin_layout LyX-Code
+Index Value
+\end_layout
+
+\begin_layout LyX-Code
+1 4.5
+\end_layout
+
+\begin_layout LyX-Code
+2 1.0
+\end_layout
+
+\begin_layout LyX-Code
+3 3.5
+\end_layout
+
+\begin_layout LyX-Code
+4 2.0
+\end_layout
+
\begin_layout Subsection
go | run
\end_layout
diff --git a/src/Command.cpp b/src/Command.cpp
index c5308bac79..83dcd13e34 100644
--- a/src/Command.cpp
+++ b/src/Command.cpp
@@ -20,6 +20,7 @@
#include "Exec_DataFile.h"
#include "Exec_DataFilter.h"
#include "Exec_DataSetCmd.h"
+#include "Exec_Flatten.h"
#include "Exec_GenerateAmberRst.h"
#include "Exec_Help.h"
#include "Exec_ParallelAnalysis.h"
@@ -216,6 +217,7 @@ void Command::Init() {
Command::AddCmd( new Exec_DataFilter(), Cmd::EXE, 1, "datafilter" );
Command::AddCmd( new Exec_DataSetCmd(), Cmd::EXE, 1, "dataset" );
Command::AddCmd( new Exec_EnsFileExt(), Cmd::EXE, 1, "ensextension" );
+ Command::AddCmd( new Exec_Flatten(), Cmd::EXE, 1, "flatten" );
Command::AddCmd( new Exec_GenerateAmberRst(),Cmd::EXE, 1, "rst" );
Command::AddCmd( new Exec_Help(), Cmd::EXE, 1, "help" );
Command::AddCmd( new Exec_ListAll(), Cmd::EXE, 1, "list" );
diff --git a/src/DataIO_Gnuplot.cpp b/src/DataIO_Gnuplot.cpp
index e906ae19d9..c19ff199dc 100644
--- a/src/DataIO_Gnuplot.cpp
+++ b/src/DataIO_Gnuplot.cpp
@@ -217,6 +217,7 @@ DataIO_Gnuplot::LabelArray DataIO_Gnuplot::LabelArg( std::string const& labelarg
void DataIO_Gnuplot::WriteHelp() {
mprintf("\tnolabels : Do not print axis labels.\n"
+ "\tlabels : Print axis labels.\n"
"\tusemap : pm3d output with 1 extra empty row/col (may improve look).\n"
"\tpm3d : Normal pm3d map output.\n"
"\tnopm3d : Turn off pm3d\n"
@@ -239,6 +240,7 @@ void DataIO_Gnuplot::WriteHelp() {
// DataIO_Gnuplot::processWriteArgs()
int DataIO_Gnuplot::processWriteArgs(ArgList &argIn) {
+ if (argIn.hasKey("labels")) printLabels_ = true;
if (argIn.hasKey("nolabels")) printLabels_ = false;
if (argIn.hasKey("usemap")) pm3d_ = MAP;
if (argIn.hasKey("pm3d")) pm3d_ = ON;
diff --git a/src/DataIO_Grace.cpp b/src/DataIO_Grace.cpp
index 2ecbdb3eec..4159aec088 100644
--- a/src/DataIO_Grace.cpp
+++ b/src/DataIO_Grace.cpp
@@ -120,14 +120,18 @@ int DataIO_Grace::ReadData(FileName const& fname,
// -----------------------------------------------------------------------------
void DataIO_Grace::WriteHelp() {
mprintf("\tinvert : Flip X/Y axes.\n"
+ "\tnoinvert : Do not flip X/Y axes.\n"
"\txydy : Make consecutive sets into XYDY sets.\n"
+ "\tnoxydy : Do not make consecutive sets into XYDY sets.\n"
"\t : If a string dataset is specified, assume it has data point labels.\n");
}
// DataIO_Grace::processWriteArgs()
int DataIO_Grace::processWriteArgs(ArgList &argIn) {
if (argIn.hasKey("invert")) isInverted_ = true;
+ if (argIn.hasKey("noinvert")) isInverted_ = false;
if (argIn.hasKey("xydy")) isXYDY_ = true;
+ if (argIn.hasKey("noxydy")) isXYDY_ = false;
if (isInverted_ && isXYDY_) {
mprinterr("Error: 'invert' not compatible with 'xydy'\n");
return 1;
diff --git a/src/DataIO_Std.cpp b/src/DataIO_Std.cpp
index 5236045c37..64a4d19ac9 100644
--- a/src/DataIO_Std.cpp
+++ b/src/DataIO_Std.cpp
@@ -3,6 +3,7 @@
#include // strchr
#include // isdigit, isalpha
#include // std::max
+#include // For reading in potentially sparse matrix
#include // modf TODO put function in StringRoutines?
#include "DataIO_Std.h"
#include "CpptrajStdio.h"
@@ -16,6 +17,8 @@
#include "DataSet_Vector.h" // For reading TODO remove dependency?
#include "DataSet_Mat3x3.h" // For reading TODO remove dependency?
#include "DataSet_2D.h"
+#include "DataSet_MatrixFlt.h"
+#include "DataSet_MatrixDbl.h"
#include "DataSet_3D.h"
#include "DataSet_Cmatrix_MEM.h"
@@ -29,7 +32,7 @@ DataIO_Std::DataIO_Std() :
isInverted_(false),
hasXcolumn_(true),
writeHeader_(true),
- square2d_(false),
+ square2d_(true),
sparse_(false),
originSpecified_(false),
deltaSpecified_(false),
@@ -47,26 +50,6 @@ static void PrintColumnError(int idx) {
mprinterr("Error: Number of columns in file changes at line %i.\n", idx);
}
-void DataIO_Std::ReadHelp() {
- mprintf("\tread1d: Read data as 1D data sets (default).\n"
- "\t\tindex : (1D) Use column # (starting from 1) as index (X) column.\n"
- "\t\tonlycols : Only read columns in range.\n"
- "\t\tfloatcols : Force specified columns to be read as single-precision floats.\n"
- "\t\tintcols : Force specified columns to be read as integers.\n"
- "\t\tstringcols : Force specified columns to be read as strings.\n"
- "\tread2d: Read data as 2D square matrix.\n"
- "\tread3d: Read data as 3D grid. If no dimension data in file must also\n"
- "\t specify 'dims'; can also specify 'origin' and 'delta'.\n"
- "\t\tdims ,, : Grid dimensions.\n"
- "\t\torigin ,, : Grid origins (0,0,0).\n"
- "\t\tdelta ,, : Grid spacing (1,1,1).\n"
- "\t\tprec {dbl|flt*} : Grid precision; double or float (default float).\n"
- "\t\tbin {center|corner*} : Coords specify bin centers or corners (default corners).\n"
- "\tvector: Read data as vector: VX VY VZ [OX OY OZ]\n"
- "\tmat3x3: Read data as 3x3 matrices: M(1,1) M(1,2) ... M(3,2) M(3,3)\n");
-
-}
-
const char* DataIO_Std::SEPARATORS = " ,\t"; // whitespace, comma, or tab-delimited
// DataIO_Std::Get3Double()
@@ -87,6 +70,31 @@ int DataIO_Std::Get3Double(std::string const& key, Vec3& vec, bool& specified)
return 0;
}
+/** Data read options. */
+void DataIO_Std::ReadHelp() {
+ mprintf("\tprec {flt|dbl} : Read 2d/3d data as single (flt) or double (dbl, default) precision.\n"
+ "\tread1d : Read data as 1D data sets (default).\n"
+ "\t\tindex : (1D) Use column # (starting from 1) as index (X) column.\n"
+ "\t\tonlycols : Only read columns in range.\n"
+ "\t\tfloatcols : Force specified columns to be read as single-precision floats.\n"
+ "\t\tintcols : Force specified columns to be read as integers.\n"
+ "\t\tstringcols : Force specified columns to be read as strings.\n"
+ "\tread2d : Read data as 2D matrix.\n"
+ "\t\tsquare2d : Read data as square matrix (default).\n"
+ "\t\tnosquare2d : Read data as XYZ matrix (i.e. each line contains ' ').\n"
+ "\tread3d : Read data as 3D grid. If no dimension data in file must also\n"
+ "\t specify 'dims'; can also specify 'origin' and 'delta'.\n"
+ "\t\tdims ,, : Grid dimensions.\n"
+ "\t\torigin ,, : Grid origins (0,0,0).\n"
+ "\t\tdelta ,, : Grid spacing (1,1,1).\n"
+ "\t\tprec {dbl|flt*} : Grid precision; double or float (default float).\n"
+ "\t\tbin {center|corner*} : Coords specify bin centers or corners (default corners).\n"
+ "\tvector : Read data as vector: VX VY VZ [OX OY OZ]\n"
+ "\tmat3x3 : Read data as 3x3 matrices: M(1,1) M(1,2) ... M(3,2) M(3,3)\n");
+
+}
+
+
// DataIO_Std::processReadArgs()
int DataIO_Std::processReadArgs(ArgList& argIn) {
mode_ = READ1D;
@@ -135,6 +143,24 @@ int DataIO_Std::processReadArgs(ArgList& argIn) {
// Column user args start from 1
strCols_.ShiftBy(-1);
}
+ // Precision
+ // TODO precision for 1d too
+ if (mode_ == READ2D || mode_ == READ3D) {
+ std::string precKey = argIn.GetStringKey("prec");
+ if (!precKey.empty()) {
+ if (precKey == "flt") prec_ = FLOAT;
+ else if (precKey == "dbl") prec_ = DOUBLE;
+ else {
+ mprinterr("Error: Expected only 'flt' or 'dbl' for keyword 'prec'\n");
+ return 1;
+ }
+ }
+ }
+ // Options for 2d
+ if (mode_ == READ2D) {
+ if (argIn.hasKey("square2d")) square2d_ = true;
+ if (argIn.hasKey("nosquare2d")) square2d_ = false;
+ }
// Options for 3d
if (mode_ == READ3D) {
if (Get3Double(argIn.GetStringKey("origin"), origin_, originSpecified_)) return 1;
@@ -151,16 +177,7 @@ int DataIO_Std::processReadArgs(ArgList& argIn) {
dims_[1] = oArg.getNextInteger(dims_[1]);
dims_[2] = oArg.getNextInteger(dims_[2]);
}
- // TODO precision for 1d and 2d too
- std::string precKey = argIn.GetStringKey("prec");
- if (!precKey.empty()) {
- if (precKey == "flt") prec_ = FLOAT;
- else if (precKey == "dbl") prec_ = DOUBLE;
- else {
- mprinterr("Error: Expected only 'flt' or 'dbl' for keyword 'prec'\n");
- return 1;
- }
- }
+
std::string binKey = argIn.GetStringKey("bin");
if (!binKey.empty()) {
if (binKey == "center") binCorners_ = false;
@@ -188,7 +205,12 @@ int DataIO_Std::ReadData(FileName const& fname,
if (err == IS_ASCII_CMATRIX)
err = ReadCmatrix(fname, dsl, dsname);
break;
- case READ2D: err = Read_2D(fname.Full(), dsl, dsname); break;
+ case READ2D:
+ if (square2d_)
+ err = Read_2D(fname.Full(), dsl, dsname);
+ else
+ err = Read_2D_XYZ(fname, dsl, dsname);
+ break;
case READ3D: err = Read_3D(fname.Full(), dsl, dsname); break;
case READVEC: err = Read_Vector(fname.Full(), dsl, dsname); break;
case READMAT3X3: err = Read_Mat3x3(fname.Full(), dsl, dsname); break;
@@ -526,6 +548,138 @@ int DataIO_Std::Read_2D(std::string const& fname,
return 0;
}
+// DataIO_Std::Read_2D_XYZ()
+/* Read matrix of format */
+int DataIO_Std::Read_2D_XYZ(FileName const& fname,
+ DataSetList& datasetlist, std::string const& dsname)
+{
+ // Buffer file
+ BufferedLine buffer;
+ if (buffer.OpenFileRead( fname )) return 1;
+ mprintf("\tData will be read as a 2D XYZ matrix.\n");
+ // Skip comments
+ const char* linebuffer = buffer.Line();
+ while (linebuffer != 0 && linebuffer[0] == '#')
+ linebuffer = buffer.Line();
+ // To allow for sparse matrix, read in indices and values first. Then
+ // put into a matrix.
+ int maxcol = -1;
+ int maxrow = -1;
+ typedef std::pair Ipair;
+ typedef std::map MatrixMap;
+ MatrixMap matrixMap;
+
+ int err = 0;
+ bool hasDiagonal = false;
+ while (linebuffer != 0) {
+ // Skip comments
+ if (linebuffer[0] != '#') {
+ int ntokens = buffer.TokenizeLine( SEPARATORS );
+ if (ntokens < 3) {
+ mprintf("Warning: In 2D file, less than 3 columns at line %i, skipping.\n", buffer.LineNumber());
+ } else {
+ int ix = -1;
+ int iy = -1;
+ double dval = 0;
+ // X
+ std::string Str( buffer.NextToken() );
+ if (validInteger( Str ))
+ ix = convertToInteger( Str );
+ else if (validDouble( Str )) {
+ mprintf("Warning: Line %i X value %s is not an integer.\n", buffer.LineNumber(), Str.c_str());
+ ix = (int)convertToDouble( Str );
+ } else {
+ mprinterr("Error: Line %i X value %s does not appear to be a valid number.\n", buffer.LineNumber(), Str.c_str());
+ err = 1;
+ break;
+ }
+ maxcol = std::max(ix, maxcol);
+ // Y
+ Str = std::string( buffer.NextToken() );
+ if (validInteger( Str ))
+ iy = convertToInteger( Str );
+ else if (validDouble( Str )) {
+ mprintf("Warning: Line %i Y value %s is not an integer.\n", buffer.LineNumber(), Str.c_str());
+ iy = (int)convertToDouble( Str );
+ } else {
+ mprinterr("Error: Line %i Y value %s does not appear to be a valid number.\n", buffer.LineNumber(), Str.c_str());
+ err = 1;
+ break;
+ }
+ maxrow = std::max(iy, maxrow);
+ // Check diagonal
+ if (ix == iy) hasDiagonal = true;
+ // Value
+ Str = std::string( buffer.NextToken() );
+ if (validDouble( Str )) {
+ dval = convertToDouble( Str );
+ //mprintf("DBG: %i %i %s\n", ix, iy, Str.c_str());
+ } else {
+ mprinterr("Error: Line %i Z value does not appear to be a valid number.\n", buffer.LineNumber(), Str.c_str());
+ err = 1;
+ break;
+ }
+ // Add to map
+ Ipair idx(ix, iy);
+ MatrixMap::iterator it = matrixMap.lower_bound( idx );
+ if (it == matrixMap.end() || it->first != idx) {
+ matrixMap.insert(it, std::pair(idx, dval));
+ } else {
+ mprinterr("Error: Line %i duplicate matrix indices found: %i %i\n", buffer.LineNumber(), ix, iy);
+ }
+ } // END if ntokens < 3
+ } // END if linebuffer[0] != #
+ linebuffer = buffer.Line();
+ } // END loop over file
+ if (err != 0) {
+ mprinterr("Error: Could not read matrix from %s\n", fname.full());
+ return 1;
+ }
+ mprintf("\tRead in %zu values for matrix.\n", matrixMap.size());
+ mprintf("\tMax col = %i, max row = %i\n", maxcol, maxrow);
+ if (maxcol < 1 || maxrow < 1) {
+ mprinterr("Error: One or more dimensions is empty.\n");
+ return 1;
+ }
+ if (hasDiagonal)
+ mprintf("\tMatrix has diagonal elements.\n");
+
+ // Allocate set
+ DataSet::DataType dtype;
+ if (prec_ == FLOAT) {
+ mprintf("\tMatrix is single precision.\n");
+ dtype = DataSet::MATRIX_FLT;
+ } else {
+ mprintf("\tMatrix is double precision.\n");
+ dtype = DataSet::MATRIX_DBL;
+ }
+ DataSet* ds = datasetlist.AddSet(dtype, dsname, "Mat");
+ if (ds == 0) {
+ mprinterr("Error: Could not allocate dataset for 2D xyz matrix.\n");
+ return 1;
+ }
+ // TODO check symmetric, upper triangle, etc
+ DataSet_2D& mat = static_cast( *ds );
+ if (mat.Allocate2D(maxcol, maxrow)) {
+ mprinterr("Error: Could not allocate memory for 2D xyz matrix.\n");
+ return 1;
+ }
+ if (dtype == DataSet::MATRIX_FLT) {
+ DataSet_MatrixFlt& fmat = static_cast( *ds );
+ for (MatrixMap::const_iterator it = matrixMap.begin(); it != matrixMap.end(); ++it)
+ fmat.SetElement( it->first.first-1, it->first.second-1, it->second );
+ } else if (dtype == DataSet::MATRIX_DBL) {
+ DataSet_MatrixDbl& dmat = static_cast( *ds );
+ for (MatrixMap::const_iterator it = matrixMap.begin(); it != matrixMap.end(); ++it)
+ dmat.SetElement( it->first.first-1, it->first.second-1, it->second );
+ } else {
+ mprinterr("Internal Error: Unhandled matrix type during 2D xyz matrix read.\n");
+ return 1;
+ }
+
+ return 0;
+}
+
// DataIO_Std::Read_3D()
int DataIO_Std::Read_3D(std::string const& fname,
DataSetList& datasetlist, std::string const& dsname)
@@ -851,6 +1005,7 @@ void DataIO_Std::WriteHelp() {
mprintf("\theader : Print header line.\n"
"\tnoheader : Do not print header line.\n"
"\tinvert : Flip X/Y axes (1D).\n"
+ "\tnoinvert : Do not flip X/Y axes(1D).\n"
"\tgroupby : (1D) group data sets by .\n"
"\t\tname : Group by name.\n"
"\t\taspect : Group by aspect.\n"
@@ -868,8 +1023,6 @@ void DataIO_Std::WriteHelp() {
// DataIO_Std::processWriteArgs()
int DataIO_Std::processWriteArgs(ArgList &argIn) {
- if (!isInverted_ && argIn.hasKey("invert"))
- isInverted_ = true;
std::string grouparg = argIn.GetStringKey("groupby");
if (!grouparg.empty()) {
if (group_ != BY_NAME && grouparg == "name")
@@ -886,22 +1039,18 @@ int DataIO_Std::processWriteArgs(ArgList &argIn) {
mprintf("Warning: Unrecognized arg for 'groupby' (%s), ignoring.\n", grouparg.c_str());
}
}
- if (hasXcolumn_ && argIn.hasKey("noxcol"))
- hasXcolumn_ = false;
- if (!hasXcolumn_ && argIn.hasKey("xcol"))
- hasXcolumn_ = true;
- if (writeHeader_ && argIn.hasKey("noheader"))
- writeHeader_ = false;
- if (!writeHeader_ && argIn.hasKey("header"))
- writeHeader_ = true;
- if (!square2d_ && argIn.hasKey("square2d"))
- square2d_ = true;
- else if (square2d_ && argIn.hasKey("nosquare2d"))
- square2d_ = false;
- if (!sparse_ && argIn.hasKey("sparse"))
- sparse_ = true;
- else if (sparse_ && argIn.hasKey("nosparse"))
- sparse_ = false;
+
+ if (argIn.hasKey("invert")) isInverted_ = true;
+ if (argIn.hasKey("noinvert")) isInverted_ = false;
+ if (argIn.hasKey("xcol")) hasXcolumn_ = true;
+ if (argIn.hasKey("noxcol")) hasXcolumn_ = false;
+ if (argIn.hasKey("header")) writeHeader_ = true;
+ if (argIn.hasKey("noheader")) writeHeader_ = false;
+ if (argIn.hasKey("square2d")) square2d_ = true;
+ if (argIn.hasKey("nosquare2d")) square2d_ = false;
+ if (argIn.hasKey("sparse")) sparse_ = true;
+ if (argIn.hasKey("nosparse")) sparse_ = false;
+
if (sparse_)
cut_ = argIn.getKeyDouble("cut", cut_);
return 0;
diff --git a/src/DataIO_Std.h b/src/DataIO_Std.h
index 9a655fb4ee..087be23cca 100644
--- a/src/DataIO_Std.h
+++ b/src/DataIO_Std.h
@@ -25,6 +25,7 @@ class DataIO_Std : public DataIO {
int Read_1D(std::string const&,DataSetList&,std::string const&);
int ReadCmatrix(FileName const&, DataSetList&, std::string const&);
int Read_2D(std::string const&,DataSetList&,std::string const&);
+ int Read_2D_XYZ(FileName const&,DataSetList&,std::string const&);
int Read_3D(std::string const&,DataSetList&,std::string const&);
int Read_Vector(std::string const&,DataSetList&,std::string const&);
int Read_Mat3x3(std::string const&,DataSetList&,std::string const&);
diff --git a/src/Exec_Flatten.cpp b/src/Exec_Flatten.cpp
new file mode 100644
index 0000000000..b682d58de2
--- /dev/null
+++ b/src/Exec_Flatten.cpp
@@ -0,0 +1,145 @@
+#include "Exec_Flatten.h"
+#include "CpptrajStdio.h"
+#include "DataSet_2D.h"
+#include "DataSet_1D.h"
+#include "OnlineVarT.h"
+#include // std::max
+
+// Exec_Flatten::Help()
+void Exec_Flatten::Help() const
+{
+ mprintf("\tname [mode {sum|avg}] \n"
+ " Flatten 1 or more matrices into 1D array(s) by summing or\n"
+ " averaging elements.\n"
+ );
+}
+
+// Exec_Flatten::Execute()
+Exec::RetType Exec_Flatten::Execute(CpptrajState& State, ArgList& argIn)
+{
+ std::vector inpSets;
+ std::vector outSets;
+
+ std::string dsname = argIn.GetStringKey("name");
+ if (dsname.empty()) {
+ mprinterr("Error: Must specify output set name with 'name'\n");
+ return CpptrajState::ERR;
+ }
+ mprintf("\tOutput set name: %s\n", dsname.c_str());
+
+ const char* modeStr[] = {"sum", "avg"};
+ enum ModeType { SUM = 0, AVG };
+ ModeType mode;
+ std::string modeArg = argIn.GetStringKey("mode");
+ if (!modeArg.empty()) {
+ if (modeArg == "sum")
+ mode = SUM;
+ else if (modeArg == "avg")
+ mode = AVG;
+ else {
+ mprinterr("Error: Unrecognized keyword for 'mode': %s\n", modeArg.c_str());
+ return CpptrajState::ERR;
+ }
+ } else
+ mode = SUM;
+ mprintf("\tFlatten mode: %s\n", modeStr[mode]);
+
+ // Get input sets
+ std::string setarg = argIn.GetStringNext();
+ while (!setarg.empty()) {
+ DataSetList dsl = State.DSL().GetMultipleSets( setarg );
+ for (DataSetList::const_iterator ds = dsl.begin(); ds != dsl.end(); ++ds)
+ {
+ if ( (*ds)->Group() != DataSet::MATRIX_2D ) {
+ mprintf("Warning: Set '%s' is not a matrix, skipping.\n", (*ds)->legend());
+ } else {
+ inpSets.push_back( (DataSet_2D*)(*ds) );
+ }
+ }
+ setarg = argIn.GetStringNext();
+ }
+ mprintf("\t%zu matrices to flatten.\n", inpSets.size());
+ if (inpSets.empty()) return CpptrajState::OK;
+
+ // Set up output sets.
+ if (inpSets.size() == 1) {
+ DataSet* ds = State.DSL().AddSet( DataSet::DOUBLE, dsname );
+ if (ds == 0) return CpptrajState::ERR;
+ outSets.push_back( (DataSet_1D*)ds );
+ } else {
+ int idx = 1;
+ for (std::vector::const_iterator it = inpSets.begin(); it != inpSets.end(); ++it)
+ {
+ MetaData md(dsname, idx);
+ DataSet* ds = State.DSL().AddSet( DataSet::DOUBLE, md );
+ if (ds == 0) return CpptrajState::ERR;
+ outSets.push_back( (DataSet_1D*)ds );
+ idx++;
+ }
+ }
+
+ // Flatten
+ std::vector sumArray;
+ std::vector< Stats > avgArray;
+
+ for (unsigned int idx = 0; idx != inpSets.size(); idx++) {
+ DataSet_2D const& Mat = static_cast( *(inpSets[idx]) );
+ DataSet_1D& Out = static_cast( *(outSets[idx]) );
+ // Determine max size for Out and allocate
+ unsigned int maxSize = std::max(Mat.Ncols(), Mat.Nrows());
+ mprintf("\tMatrix: %s, %zu columns, %zu rows. Output: %u elements\n", Mat.legend(), Mat.Ncols(), Mat.Nrows(), maxSize);
+ Out.Allocate( DataSet::SizeArray(1, maxSize) );
+ // Allocate temp array
+ if (mode == SUM) {
+ sumArray.clear();
+ sumArray.resize( maxSize, 0.0 );
+ } else {
+ avgArray.clear();
+ avgArray.resize( maxSize, Stats() );
+ }
+ // Loop over array.
+ for (unsigned int row = 0; row != Mat.Nrows(); row++) {
+ for (unsigned int col = 0; col != Mat.Ncols(); col++) {
+ double dval = Mat.GetElement(col, row);
+ //mprintf("DBG: %8u %8u %12.4f\n", col, row, dval);
+ // Diagonal element gets full interaction
+ if (row == col) {
+ //if (col == 0) mprintf("DBG: Diag Elt 0 %12.4f\n", dval);
+ if (mode == SUM)
+ sumArray[row] += dval;
+ else
+ avgArray[row].accumulate( dval );
+ } else {
+ // Off-diagonal element: divide element between row and col
+ double halfVal = dval / 2.0;
+ //mprintf("DBG0: %8u %12.4f\n", col, halfVal);
+ //mprintf("DBG1: %8u %12.4f\n", row, halfVal);
+ //if (col == 0 || row == 0) mprintf("DBG: Elt 0 %12.4f\n", halfVal);
+ // Operation
+ if (mode == SUM) {
+ sumArray[row] += halfVal;
+ sumArray[col] += halfVal;
+ } else {
+ avgArray[row].accumulate( halfVal );
+ avgArray[col].accumulate( halfVal );
+ }
+ }
+ } // END loop over columns
+ } // END loop over rows
+ // Fill in final values TODO make Resize a DataSet_1D function
+ if (mode == SUM) {
+ int jdx = 0;
+ for (std::vector::const_iterator it = sumArray.begin(); it != sumArray.end(); ++it) {
+ double val = *it;
+ Out.Add(jdx++, &val);
+ }
+ } else {
+ int jdx = 0;
+ for (std::vector< Stats >::const_iterator it = avgArray.begin(); it != avgArray.end(); ++it) {
+ double val = it->mean();
+ Out.Add(jdx++, &val );
+ }
+ }
+ } // END loop over input sets
+ return CpptrajState::OK;
+}
diff --git a/src/Exec_Flatten.h b/src/Exec_Flatten.h
new file mode 100644
index 0000000000..46ee55c8a3
--- /dev/null
+++ b/src/Exec_Flatten.h
@@ -0,0 +1,12 @@
+#ifndef INC_EXEC_FLATTEN_H
+#define INC_EXEC_FLATTEN_H
+#include "Exec.h"
+/// Flatten a 2D matrix to a 1D data set
+class Exec_Flatten : public Exec {
+ public:
+ Exec_Flatten() : Exec(GENERAL) {}
+ void Help() const;
+ DispatchObject* Alloc() const { return (DispatchObject*)new Exec_Flatten(); }
+ RetType Execute(CpptrajState&, ArgList&);
+};
+#endif
diff --git a/src/Version.h b/src/Version.h
index 5c2382acc9..fcf9b83978 100644
--- a/src/Version.h
+++ b/src/Version.h
@@ -12,7 +12,7 @@
* Whenever a number that precedes is incremented, all subsequent
* numbers should be reset to 0.
*/
-#define CPPTRAJ_INTERNAL_VERSION "V5.0.3"
+#define CPPTRAJ_INTERNAL_VERSION "V5.0.4"
/// PYTRAJ relies on this
#define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION
#endif
diff --git a/src/cpptrajdepend b/src/cpptrajdepend
index 2fb7096f93..3bfd4c6b62 100644
--- a/src/cpptrajdepend
+++ b/src/cpptrajdepend
@@ -159,7 +159,7 @@ Cluster_ReadInfo.o : Cluster_ReadInfo.cpp ArgList.h ArrayIterator.h AssociatedDa
Cmd.o : Cmd.cpp Cmd.h DispatchObject.h
CmdInput.o : CmdInput.cpp CmdInput.h StringRoutines.h
CmdList.o : CmdList.cpp Cmd.h CmdList.h DispatchObject.h
-Command.o : Command.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h ActionTopWriter.h Action_Align.h Action_Angle.h Action_AreaPerMol.h Action_AtomMap.h Action_AtomicCorr.h Action_AtomicFluct.h Action_AutoImage.h Action_Average.h Action_Bounds.h Action_Box.h Action_Center.h Action_Channel.h Action_CheckChirality.h Action_CheckStructure.h Action_Closest.h Action_ClusterDihedral.h Action_Contacts.h Action_CreateCrd.h Action_CreateReservoir.h Action_DNAionTracker.h Action_DSSP.h Action_Density.h Action_Diffusion.h Action_Dihedral.h Action_DihedralRMS.h Action_Dipole.h Action_DistRmsd.h Action_Distance.h Action_Energy.h Action_Esander.h Action_FilterByData.h Action_FixAtomOrder.h Action_FixImagedBonds.h Action_GIST.h Action_Grid.h Action_GridFreeEnergy.h Action_HydrogenBond.h Action_Image.h Action_InfraredSpectrum.h Action_Jcoupling.h Action_LESsplit.h Action_LIE.h Action_LipidOrder.h Action_MakeStructure.h Action_Mask.h Action_Matrix.h Action_MinImage.h Action_Molsurf.h Action_MultiDihedral.h Action_MultiVector.h Action_NAstruct.h Action_NMRrst.h Action_NativeContacts.h Action_OrderParameter.h Action_Outtraj.h Action_PairDist.h Action_Pairwise.h Action_Principal.h Action_Projection.h Action_Pucker.h Action_Radgyr.h Action_Radial.h Action_RandomizeIons.h Action_Remap.h Action_ReplicateCell.h Action_Rmsd.h Action_Rotate.h Action_RunningAvg.h Action_STFC_Diffusion.h Action_Scale.h Action_SetVelocity.h Action_Spam.h Action_Strip.h Action_Surf.h Action_SymmetricRmsd.h Action_Temperature.h Action_Time.h Action_Translate.h Action_Unstrip.h Action_Unwrap.h Action_Vector.h Action_VelocityAutoCorr.h Action_Volmap.h Action_Volume.h Action_Watershell.h Action_XtalSymm.h Analysis.h AnalysisList.h AnalysisState.h Analysis_AmdBias.h Analysis_AutoCorr.h Analysis_Average.h Analysis_Clustering.h Analysis_ConstantPHStats.h Analysis_Corr.h Analysis_CrankShaft.h Analysis_CrdFluct.h Analysis_CrossCorr.h Analysis_CurveFit.h Analysis_Divergence.h Analysis_EvalPlateau.h Analysis_FFT.h Analysis_HausdorffDistance.h Analysis_Hist.h Analysis_IRED.h Analysis_Integrate.h Analysis_KDE.h Analysis_Lifetime.h Analysis_LowestCurve.h Analysis_Matrix.h Analysis_MeltCurve.h Analysis_Modes.h Analysis_MultiHist.h Analysis_Multicurve.h Analysis_Overlap.h Analysis_PhiPsi.h Analysis_Regression.h Analysis_RemLog.h Analysis_Rms2d.h Analysis_RmsAvgCorr.h Analysis_Rotdif.h Analysis_RunningAvg.h Analysis_Slope.h Analysis_Spline.h Analysis_State.h Analysis_Statistics.h Analysis_TI.h Analysis_Timecorr.h Analysis_VectorMath.h Analysis_Wavelet.h ArgList.h Array1D.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h AxisType.h BaseIOtype.h Box.h BoxArgs.h BufferedLine.h CharMask.h ClusterDist.h ClusterList.h ClusterMap.h ClusterNode.h ClusterSieve.h Cmd.h CmdInput.h CmdList.h Command.h CompactFrameArray.h ComplexArray.h Constants.h Constraints.h ControlBlock.h ControlBlock_For.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Cmatrix.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_GridFlt.h DataSet_Mat3x3.h DataSet_MatrixDbl.h DataSet_MatrixFlt.h DataSet_Mesh.h DataSet_Modes.h DataSet_RemLog.h DataSet_Vector.h DataSet_double.h DataSet_float.h DataSet_integer.h DataSet_integer_mem.h DataSet_pH.h DataSet_string.h Deprecated.h DihedralSearch.h Dimension.h DispatchObject.h Energy.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h ExclusionArray.h Exec.h Exec_AddMissingRes.h Exec_Analyze.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_Emin.h Exec_GenerateAmberRst.h Exec_Graft.h Exec_Help.h Exec_LoadCrd.h Exec_LoadTraj.h Exec_ParallelAnalysis.h Exec_ParmBox.h Exec_ParmSolvent.h Exec_ParmStrip.h Exec_ParmWrite.h Exec_PermuteDihedrals.h Exec_Precision.h Exec_PrepareForLeap.h Exec_PrintData.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_SequenceAlign.h Exec_Set.h Exec_Show.h Exec_SortEnsembleData.h Exec_SplitCoords.h Exec_System.h Exec_Top.h Exec_Traj.h Exec_UpdateParameters.h Exec_ViewRst.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h Grid.h GridAction.h GridBin.h HistBin.h Hungarian.h ImageOption.h ImageTypes.h InputTrajCommon.h MapAtom.h MaskArray.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h NetcdfFile.h OnlineVarT.h OutputTrajCommon.h PDBfile.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PubFFT.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h Spline.h SplineFxnTable.h StructureCheck.h SymbolExporting.h SymmetricRmsdCalc.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h cuda_kernels/GistCudaSetup.cuh molsurf.h
+Command.o : Command.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h ActionTopWriter.h Action_Align.h Action_Angle.h Action_AreaPerMol.h Action_AtomMap.h Action_AtomicCorr.h Action_AtomicFluct.h Action_AutoImage.h Action_Average.h Action_Bounds.h Action_Box.h Action_Center.h Action_Channel.h Action_CheckChirality.h Action_CheckStructure.h Action_Closest.h Action_ClusterDihedral.h Action_Contacts.h Action_CreateCrd.h Action_CreateReservoir.h Action_DNAionTracker.h Action_DSSP.h Action_Density.h Action_Diffusion.h Action_Dihedral.h Action_DihedralRMS.h Action_Dipole.h Action_DistRmsd.h Action_Distance.h Action_Energy.h Action_Esander.h Action_FilterByData.h Action_FixAtomOrder.h Action_FixImagedBonds.h Action_GIST.h Action_Grid.h Action_GridFreeEnergy.h Action_HydrogenBond.h Action_Image.h Action_InfraredSpectrum.h Action_Jcoupling.h Action_LESsplit.h Action_LIE.h Action_LipidOrder.h Action_MakeStructure.h Action_Mask.h Action_Matrix.h Action_MinImage.h Action_Molsurf.h Action_MultiDihedral.h Action_MultiVector.h Action_NAstruct.h Action_NMRrst.h Action_NativeContacts.h Action_OrderParameter.h Action_Outtraj.h Action_PairDist.h Action_Pairwise.h Action_Principal.h Action_Projection.h Action_Pucker.h Action_Radgyr.h Action_Radial.h Action_RandomizeIons.h Action_Remap.h Action_ReplicateCell.h Action_Rmsd.h Action_Rotate.h Action_RunningAvg.h Action_STFC_Diffusion.h Action_Scale.h Action_SetVelocity.h Action_Spam.h Action_Strip.h Action_Surf.h Action_SymmetricRmsd.h Action_Temperature.h Action_Time.h Action_Translate.h Action_Unstrip.h Action_Unwrap.h Action_Vector.h Action_VelocityAutoCorr.h Action_Volmap.h Action_Volume.h Action_Watershell.h Action_XtalSymm.h Analysis.h AnalysisList.h AnalysisState.h Analysis_AmdBias.h Analysis_AutoCorr.h Analysis_Average.h Analysis_Clustering.h Analysis_ConstantPHStats.h Analysis_Corr.h Analysis_CrankShaft.h Analysis_CrdFluct.h Analysis_CrossCorr.h Analysis_CurveFit.h Analysis_Divergence.h Analysis_EvalPlateau.h Analysis_FFT.h Analysis_HausdorffDistance.h Analysis_Hist.h Analysis_IRED.h Analysis_Integrate.h Analysis_KDE.h Analysis_Lifetime.h Analysis_LowestCurve.h Analysis_Matrix.h Analysis_MeltCurve.h Analysis_Modes.h Analysis_MultiHist.h Analysis_Multicurve.h Analysis_Overlap.h Analysis_PhiPsi.h Analysis_Regression.h Analysis_RemLog.h Analysis_Rms2d.h Analysis_RmsAvgCorr.h Analysis_Rotdif.h Analysis_RunningAvg.h Analysis_Slope.h Analysis_Spline.h Analysis_State.h Analysis_Statistics.h Analysis_TI.h Analysis_Timecorr.h Analysis_VectorMath.h Analysis_Wavelet.h ArgList.h Array1D.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h AxisType.h BaseIOtype.h Box.h BoxArgs.h BufferedLine.h CharMask.h ClusterDist.h ClusterList.h ClusterMap.h ClusterNode.h ClusterSieve.h Cmd.h CmdInput.h CmdList.h Command.h CompactFrameArray.h ComplexArray.h Constants.h Constraints.h ControlBlock.h ControlBlock_For.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Cmatrix.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_GridFlt.h DataSet_Mat3x3.h DataSet_MatrixDbl.h DataSet_MatrixFlt.h DataSet_Mesh.h DataSet_Modes.h DataSet_RemLog.h DataSet_Vector.h DataSet_double.h DataSet_float.h DataSet_integer.h DataSet_integer_mem.h DataSet_pH.h DataSet_string.h Deprecated.h DihedralSearch.h Dimension.h DispatchObject.h Energy.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h ExclusionArray.h Exec.h Exec_AddMissingRes.h Exec_Analyze.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_Emin.h Exec_Flatten.h Exec_GenerateAmberRst.h Exec_Graft.h Exec_Help.h Exec_LoadCrd.h Exec_LoadTraj.h Exec_ParallelAnalysis.h Exec_ParmBox.h Exec_ParmSolvent.h Exec_ParmStrip.h Exec_ParmWrite.h Exec_PermuteDihedrals.h Exec_Precision.h Exec_PrepareForLeap.h Exec_PrintData.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_SequenceAlign.h Exec_Set.h Exec_Show.h Exec_SortEnsembleData.h Exec_SplitCoords.h Exec_System.h Exec_Top.h Exec_Traj.h Exec_UpdateParameters.h Exec_ViewRst.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h Grid.h GridAction.h GridBin.h HistBin.h Hungarian.h ImageOption.h ImageTypes.h InputTrajCommon.h MapAtom.h MaskArray.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h NetcdfFile.h OnlineVarT.h OutputTrajCommon.h PDBfile.h PairList.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PubFFT.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h Spline.h SplineFxnTable.h StructureCheck.h SymbolExporting.h SymmetricRmsdCalc.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h cuda_kernels/GistCudaSetup.cuh molsurf.h
CompactFrameArray.o : CompactFrameArray.cpp Box.h CompactFrameArray.h CoordinateInfo.h CpptrajStdio.h Matrix_3x3.h Parallel.h ReplicaDimArray.h Vec3.h
ComplexArray.o : ComplexArray.cpp ArrayIterator.h ComplexArray.h
Constraints.o : Constraints.cpp ArgList.h Atom.h AtomMask.h AtomType.h Box.h CharMask.h Constants.h Constraints.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h Topology.h TypeNameHolder.h Unit.h Vec3.h
@@ -190,7 +190,7 @@ DataIO_NC_Cmatrix.o : DataIO_NC_Cmatrix.cpp ArgList.h ArrayIterator.h Associated
DataIO_OpenDx.o : DataIO_OpenDx.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_OpenDx.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridDbl.h DataSet_GridFlt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ProgressBar.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h
DataIO_Peaks.o : DataIO_Peaks.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_Peaks.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Vector_Scalar.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h
DataIO_RemLog.o : DataIO_RemLog.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_RemLog.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_RemLog.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ProgressBar.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h
-DataIO_Std.o : DataIO_Std.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h ClusterDist.h ClusterSieve.h ComplexArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_Std.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Cmatrix.h DataSet_Cmatrix_MEM.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Mat3x3.h DataSet_Vector.h DataSet_double.h DataSet_float.h DataSet_integer.h DataSet_string.h Dimension.h FileIO.h FileName.h Frame.h GridBin.h Hungarian.h MapAtom.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h SymmetricRmsdCalc.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h
+DataIO_Std.o : DataIO_Std.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h ClusterDist.h ClusterSieve.h ComplexArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_Std.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Cmatrix.h DataSet_Cmatrix_MEM.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Mat3x3.h DataSet_MatrixDbl.h DataSet_MatrixFlt.h DataSet_Vector.h DataSet_double.h DataSet_float.h DataSet_integer.h DataSet_string.h Dimension.h FileIO.h FileName.h Frame.h GridBin.h Hungarian.h MapAtom.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h StringRoutines.h SymbolExporting.h SymmetricRmsdCalc.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h
DataIO_VecTraj.o : DataIO_VecTraj.cpp ActionFrameCounter.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ComplexArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_VecTraj.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_Vector.h Dimension.h FileIO.h FileName.h FileTypes.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OutputTrajCommon.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajectoryFile.h Trajout_Single.h TypeNameHolder.h Unit.h Vec3.h
DataIO_XVG.o : DataIO_XVG.cpp ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_XVG.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_double.h Dimension.h FileIO.h FileName.h Frame.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h
DataIO_Xplor.o : DataIO_Xplor.cpp ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h BufferedLine.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajStdio.h DataIO.h DataIO_Xplor.h DataSet.h DataSetList.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_GridFlt.h Dimension.h FileIO.h FileName.h Frame.h Grid.h GridBin.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ProgressBar.h Range.h ReferenceFrame.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TypeNameHolder.h Unit.h Vec3.h
@@ -262,6 +262,7 @@ Exec_DataFile.o : Exec_DataFile.cpp Action.h ActionList.h ActionState.h Analysis
Exec_DataFilter.o : Exec_DataFilter.cpp Action.h ActionList.h ActionState.h Action_FilterByData.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h Array1D.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_double.h DataSet_integer.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_DataFilter.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ProgressBar.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h
Exec_DataSetCmd.o : Exec_DataSetCmd.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h ArrayIterator.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h ComplexArray.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h DataSet_MatrixDbl.h DataSet_Mesh.h DataSet_Vector.h DataSet_string.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_DataSetCmd.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h Spline.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h
Exec_Emin.o : Exec_Emin.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h CharMask.h Constants.h Constraints.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnergyArray.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Emin.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MdOpts.h MetaData.h Minimize_SteepestDescent.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h PotentialFunction.h PotentialTerm.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h
+Exec_Flatten.o : Exec_Flatten.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flatten.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h
Exec_GenerateAmberRst.o : Exec_GenerateAmberRst.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_GenerateAmberRst.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h ImageOption.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h
Exec_Graft.o : Exec_Graft.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Graft.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h
Exec_Help.o : Exec_Help.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h AtomType.h BaseIOtype.h Box.h Cmd.h CmdList.h Command.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Help.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h Molecule.h NameType.h Parallel.h ParameterHolders.h ParameterSet.h ParameterTypes.h ParmFile.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h TypeNameHolder.h Unit.h Vec3.h
diff --git a/src/cpptrajfiles b/src/cpptrajfiles
index 999ce5a507..2047c673e3 100644
--- a/src/cpptrajfiles
+++ b/src/cpptrajfiles
@@ -262,6 +262,7 @@ COMMON_SOURCES= \
Exec_DataFilter.cpp \
Exec_DataSetCmd.cpp \
Exec_Emin.cpp \
+ Exec_Flatten.cpp \
Exec_GenerateAmberRst.cpp \
Exec_Graft.cpp \
Exec_Help.cpp \
diff --git a/test/Makefile b/test/Makefile
index 29a80bfcb6..be14162b5c 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -474,6 +474,9 @@ test.evalplateau:
test.graft:
@-cd Test_Graft && ./RunTest.sh $(OPT)
+test.flatten:
+ @-cd Test_Flatten && ./RunTest.sh $(OPT)
+
# Every test target should go here.
COMPLETETESTS=test.general \
test.strip \
@@ -625,7 +628,8 @@ COMPLETETESTS=test.general \
test.diagmatrix \
test.emin \
test.evalplateau \
- test.graft
+ test.graft \
+ test.flatten
test.all:
$(MAKE) test.complete summary
diff --git a/test/Test_Flatten/RunTest.sh b/test/Test_Flatten/RunTest.sh
new file mode 100755
index 0000000000..db6c381ad1
--- /dev/null
+++ b/test/Test_Flatten/RunTest.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+. ../MasterTest.sh
+
+CleanFiles cpptraj.in flatten.dat
+
+INPUT='-i cpptraj.in'
+
+cat > cpptraj.in < vector.in < vector.in < vector.in < |