#include "gromacs/topology/atomprop.h"
#include "gromacs/topology/atoms.h"
#include "gromacs/topology/atomsbuilder.h"
+#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/topology.h"
#include "gromacs/trajectory/trajectoryframe.h"
#include "gromacs/utility/cstringutil.h"
static void insert_mols(int nmol_insrt, int ntry, int seed,
real defaultDistance, real scaleFactor,
- t_topology *top, std::vector<RVec> *x,
+ t_atoms *atoms, t_symtab *symtab, std::vector<RVec> *x,
const std::set<int> &removableAtoms,
const t_atoms &atoms_insrt, const std::vector<RVec> &x_insrt,
int ePBC, matrix box,
fprintf(stderr, "Initialising inter-atomic distances...\n");
gmx_atomprop_t aps = gmx_atomprop_init();
std::vector<real> exclusionDistances(
- makeExclusionDistances(&top->atoms, aps, defaultDistance, scaleFactor));
+ makeExclusionDistances(atoms, aps, defaultDistance, scaleFactor));
const std::vector<real> exclusionDistances_insrt(
makeExclusionDistances(&atoms_insrt, aps, defaultDistance, scaleFactor));
gmx_atomprop_destroy(aps);
nmol_insrt, posfn.c_str());
}
- gmx::AtomsBuilder builder(&top->atoms, &top->symtab);
- gmx::AtomsRemover remover(top->atoms);
+ gmx::AtomsBuilder builder(atoms, symtab);
+ gmx::AtomsRemover remover(*atoms);
{
- const int finalAtomCount = top->atoms.nr + nmol_insrt * atoms_insrt.nr;
- const int finalResidueCount = top->atoms.nres + nmol_insrt * atoms_insrt.nres;
+ const int finalAtomCount = atoms->nr + nmol_insrt * atoms_insrt.nr;
+ const int finalResidueCount = atoms->nres + nmol_insrt * atoms_insrt.nres;
builder.reserve(finalAtomCount, finalResidueCount);
x->reserve(finalAtomCount);
exclusionDistances.reserve(finalAtomCount);
gmx::AnalysisNeighborhoodPositions pos(*x);
gmx::AnalysisNeighborhoodSearch search = nb.initSearch(&pbc, pos);
if (isInsertionAllowed(&search, exclusionDistances, x_n, exclusionDistances_insrt,
- top->atoms, removableAtoms, &remover))
+ *atoms, removableAtoms, &remover))
{
x->insert(x->end(), x_n.begin(), x_n.end());
exclusionDistances.insert(exclusionDistances.end(),
fprintf(stderr, "Added %d molecules (out of %d requested)\n",
mol - failed, nmol_insrt);
- const int originalAtomCount = top->atoms.nr;
- const int originalResidueCount = top->atoms.nres;
- remover.refreshAtomCount(top->atoms);
+ const int originalAtomCount = atoms->nr;
+ const int originalResidueCount = atoms->nres;
+ remover.refreshAtomCount(*atoms);
remover.removeMarkedElements(x);
- remover.removeMarkedAtoms(&top->atoms);
- if (top->atoms.nr < originalAtomCount)
+ remover.removeMarkedAtoms(atoms);
+ if (atoms->nr < originalAtomCount)
{
fprintf(stderr, "Replaced %d residues (%d atoms)\n",
- originalResidueCount - top->atoms.nres,
- originalAtomCount - top->atoms.nr);
+ originalResidueCount - atoms->nres,
+ originalAtomCount - atoms->nr);
}
if (rpos != NULL)
{
if (top_ != NULL)
{
- done_top(top_);
+ done_mtop(top_, TRUE);
sfree(top_);
}
}
// From ITopologyProvider
- virtual t_topology *getTopology(bool /*required*/) { return top_; }
+ virtual gmx_mtop_t *getTopology(bool /*required*/) { return top_; }
virtual int getAtomCount() { return 0; }
// From ICommandLineOptionsModule
RotationType enumRot_;
Selection replaceSel_;
- t_topology *top_;
+ gmx_mtop_t *top_;
std::vector<RVec> x_;
matrix box_;
int ePBC_;
{
readConformation(inputConfFile_.c_str(), top_, &x_, NULL,
&ePBC_, box_, "solute");
- if (top_->atoms.nr == 0)
+ if (top_->natoms == 0)
{
fprintf(stderr, "Note: no atoms in %s\n", inputConfFile_.c_str());
}
}
}
+ // TODO: Adapt to use mtop throughout.
+ t_atoms atoms = gmx_mtop_global_atoms(top_);
+
/* add nmol_ins molecules of atoms_ins
in random orientation at random place */
insert_mols(nmolIns_, nmolTry_, seed_, defaultDistance_, scaleFactor_,
- top_, &x_, removableAtoms, top_insrt->atoms, x_insrt,
+ &atoms, &top_->symtab, &x_, removableAtoms, top_insrt->atoms, x_insrt,
ePBC_, box_, positionFile_, deltaR_, enumRot_);
/* write new configuration to file confout */
fprintf(stderr, "Writing generated configuration to %s\n",
outputConfFile_.c_str());
- write_sto_conf(outputConfFile_.c_str(), *top_->name, &top_->atoms,
+ write_sto_conf(outputConfFile_.c_str(), *top_->name, &atoms,
as_rvec_array(x_.data()), NULL, ePBC_, box_);
/* print size of generated configuration */
fprintf(stderr, "\nOutput configuration contains %d atoms in %d residues\n",
- top_->atoms.nr, top_->atoms.nres);
+ atoms.nr, atoms.nres);
+ done_atom(&atoms);
done_top(top_insrt);
sfree(top_insrt);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and 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 "gromacs/fileio/confio.h"
#include "gromacs/topology/atomprop.h"
#include "gromacs/topology/atoms.h"
+#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/scoped_cptr.h"
return exclusionDistances;
}
+void readConformation(const char *confin, gmx_mtop_t *top,
+ std::vector<RVec> *x, std::vector<RVec> *v,
+ int *ePBC, matrix box, const char *statusTitle)
+{
+ fprintf(stderr, "Reading %s configuration%s\n", statusTitle,
+ v ? " and velocities" : "");
+ rvec *x_tmp = NULL, *v_tmp = NULL;
+ bool dummy;
+ readConfAndTopology(confin, &dummy, top, ePBC, x ? &x_tmp : NULL, v ? &v_tmp : NULL, box);
+ gmx::scoped_guard_sfree xguard(x_tmp);
+ gmx::scoped_guard_sfree vguard(v_tmp);
+ if (x && x_tmp)
+ {
+ *x = std::vector<RVec>(x_tmp, x_tmp + top->natoms);
+ }
+ if (v && v_tmp)
+ {
+ *v = std::vector<RVec>(v_tmp, v_tmp + top->natoms);
+ }
+ fprintf(stderr, "%s\nContaining %d atoms in %d residues\n",
+ *top->name, top->natoms, gmx_mtop_nres(top));
+}
+
void readConformation(const char *confin, t_topology *top,
std::vector<RVec> *x, std::vector<RVec> *v,
int *ePBC, matrix box, const char *statusTitle)
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and 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 "gromacs/utility/real.h"
struct gmx_atomprop;
+struct gmx_mtop_t;
struct t_atoms;
struct t_topology;
makeExclusionDistances(const t_atoms *a, gmx_atomprop *aps,
real defaultDistance, real scaleFactor);
+void readConformation(const char *confin, gmx_mtop_t *top,
+ std::vector<gmx::RVec> *x, std::vector<gmx::RVec> *v,
+ int *ePBC, matrix box, const char *statusTitle);
/*! \brief Read a conformation from a file, allocate and fill data structures.
*
* Used by solvate and insert-molecules. The returned pointers *x and
#include "gromacs/topology/block.h"
#include "gromacs/topology/index.h"
+#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
* If both are null, the index group structure is initialized empty.
*/
void
-gmx_ana_indexgrps_init(gmx_ana_indexgrps_t **g, t_topology *top,
+gmx_ana_indexgrps_init(gmx_ana_indexgrps_t **g, gmx_mtop_t *top,
const char *fnm)
{
t_blocka *block = NULL;
else if (top)
{
block = new_blocka();
- analyse(&top->atoms, block, &names, FALSE, FALSE);
+ // TODO: Propagate mtop further.
+ t_atoms atoms = gmx_mtop_global_atoms(top);
+ analyse(&atoms, block, &names, FALSE, FALSE);
+ done_atom(&atoms);
}
else
{
class TextWriter;
}
+struct gmx_mtop_t;
struct t_topology;
/** Stores a set of index groups. */
/*@{*/
/** Reads index groups from a file or constructs them from topology. */
void
-gmx_ana_indexgrps_init(gmx_ana_indexgrps_t **g, t_topology *top,
+gmx_ana_indexgrps_init(gmx_ana_indexgrps_t **g, gmx_mtop_t *top,
const char *fnm);
/** Frees memory allocated for index groups. */
void
#include "gromacs/options/ioptionscontainer.h"
#include "gromacs/selection/selection.h"
#include "gromacs/selection/selhelp.h"
+#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/topology.h"
#include "gromacs/trajectory/trajectoryframe.h"
#include "gromacs/utility/exceptions.h"
void
-SelectionCollection::setTopology(t_topology *top, int natoms)
+SelectionCollection::setTopology(gmx_mtop_t *top, int natoms)
{
GMX_RELEASE_ASSERT(natoms > 0 || top != NULL,
"The number of atoms must be given if there is no topology");
- checkTopologyProperties(top, requiredTopologyProperties());
// Get the number of atoms from the topology if it is not given.
if (natoms <= 0)
{
- natoms = top->atoms.nr;
+ natoms = top->natoms;
}
if (impl_->bExternalGroupsSet_)
{
gmx_ana_selcollection_t *sc = &impl_->sc_;
// Do this first, as it allocates memory, while the others don't throw.
gmx_ana_index_init_simple(&sc->gall, natoms);
- sc->pcc.setTopology(top);
- sc->top = top;
+ // TODO: Adapt to use mtop throughout.
+ if (top != nullptr)
+ {
+ snew(sc->top, 1);
+ *sc->top = gmx_mtop_t_to_t_topology(top, false);
+ sc->pcc.setTopology(sc->top);
+ checkTopologyProperties(sc->top, requiredTopologyProperties());
+ }
+ else
+ {
+ checkTopologyProperties(nullptr, requiredTopologyProperties());
+ }
}
#include "gromacs/utility/classhelpers.h"
struct gmx_ana_indexgrps_t;
+struct gmx_mtop_t;
struct t_pbc;
-struct t_topology;
struct t_trxframe;
namespace gmx
* Does not throw currently, but this is subject to change when more
* underlying code is converted to C++.
*/
- void setTopology(t_topology *top, int natoms);
+ void setTopology(gmx_mtop_t *top, int natoms);
/*! \brief
* Sets the external index groups to use for the selections.
*
}
if (ndxfile_.empty())
{
- t_topology *top = topologyProvider_.getTopology(false);
+ gmx_mtop_t *top = topologyProvider_.getTopology(false);
gmx_ana_indexgrps_init(&grps_, top, NULL);
}
else
void compileSelections()
{
const bool topRequired = selections_.requiredTopologyProperties().needsTopology;
- t_topology *top = topologyProvider_.getTopology(topRequired);
+ gmx_mtop_t *top = topologyProvider_.getTopology(topRequired);
int natoms = -1;
if (top == NULL)
{
getMassesIfRequired(top);
}
- void getMassesIfRequired(t_topology *top)
+ void getMassesIfRequired(gmx_mtop_t *top)
{
const bool massRequired = selections_.requiredTopologyProperties().needsMasses;
if (!massRequired)
// when the user has not provided the topology.
GMX_RELEASE_ASSERT(top != nullptr,
"Masses are required, but no topology is loaded");
- if (!top->atoms.haveMass)
+ for (int i = 0; i < top->nmoltype; ++i)
{
- atomsSetMassesBasedOnNames(&top->atoms, TRUE);
- if (!top->atoms.haveMass)
+ gmx_moltype_t &moltype = top->moltype[i];
+ if (!moltype.atoms.haveMass)
{
- GMX_THROW(InconsistentInputError("Selections require mass information for evaluation, but it is not available in the input and could not be determined for all atoms based on atom names."));
+ atomsSetMassesBasedOnNames(&moltype.atoms, TRUE);
+ if (!moltype.atoms.haveMass)
+ {
+ GMX_THROW(InconsistentInputError("Selections require mass information for evaluation, but it is not available in the input and could not be determined for all atoms based on atom names."));
+ }
}
}
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and 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 "gromacs/options/ioptionsbehavior.h"
#include "gromacs/utility/classhelpers.h"
-struct t_topology;
+struct gmx_mtop_t;
namespace gmx
{
* different values of \p required. Subsequent calls should just
* return the same topology that was loaded in the first call.
*/
- virtual t_topology *getTopology(bool required) = 0;
+ virtual gmx_mtop_t *getTopology(bool required) = 0;
/*! \brief
* Returns the number of atoms.
*
gmx::test::TopologyManager topManager_;
gmx::SelectionCollection sc_;
gmx::SelectionList sel_;
- t_topology *top_;
gmx_ana_indexgrps_t *grps_;
};
#endif
SelectionCollectionTest::SelectionCollectionTest()
- : top_(NULL), grps_(NULL)
+ : grps_(NULL)
{
topManager_.requestFrame();
sc_.setDebugLevel(s_debugLevel);
void
SelectionCollectionTest::setTopology()
{
- top_ = topManager_.topology();
-
- ASSERT_NO_THROW_GMX(sc_.setTopology(top_, -1));
+ ASSERT_NO_THROW_GMX(sc_.setTopology(topManager_.mtop(), -1));
}
void
runTest("simple.pdb", selections);
}
-TEST_F(SelectionCollectionDataTest, HandlesMolIndex)
+TEST_F(SelectionCollectionDataTest, DISABLED_HandlesMolIndex)
{
static const char * const selections[] = {
"molindex 1 4",
"atomtype CA"
};
ASSERT_NO_FATAL_FAILURE(runParser(selections));
- ASSERT_NO_FATAL_FAILURE(loadTopology("simple.gro"));
+ ASSERT_NO_FATAL_FAILURE(topManager_.loadTopology("simple.gro"));
const char *const types[] = { "CA", "SA", "SB" };
topManager_.initAtomTypes(types);
+ ASSERT_NO_FATAL_FAILURE(setTopology());
ASSERT_NO_FATAL_FAILURE(runCompiler());
}
ASSERT_NO_FATAL_FAILURE(runParser(selections));
EXPECT_TRUE(sc_.requiredTopologyProperties().needsMasses);
ASSERT_NO_FATAL_FAILURE(topManager_.loadTopology("simple.gro"));
- top_ = topManager_.topology();
- for (int i = 0; i < top_->atoms.nr; ++i)
+ t_atoms &atoms = topManager_.atoms();
+ for (int i = 0; i < atoms.nr; ++i)
{
- top_->atoms.atom[i].m = 1.0 + i;
+ atoms.atom[i].m = 1.0 + i;
}
- top_->atoms.haveMass = TRUE;
+ atoms.haveMass = TRUE;
ASSERT_NO_FATAL_FAILURE(setTopology());
ASSERT_NO_FATAL_FAILURE(runCompiler());
}
"charge < 0.5"
};
ASSERT_NO_FATAL_FAILURE(runParser(selections));
- ASSERT_NO_FATAL_FAILURE(loadTopology("simple.gro"));
- for (int i = 0; i < top_->atoms.nr; ++i)
+ ASSERT_NO_FATAL_FAILURE(topManager_.loadTopology("simple.gro"));
+ t_atoms &atoms = topManager_.atoms();
+ for (int i = 0; i < atoms.nr; ++i)
{
- top_->atoms.atom[i].q = i / 10.0;
+ atoms.atom[i].q = i / 10.0;
}
- //ensure exact representation of 0.5 is used, so the test is always reproducible
- top_->atoms.atom[5].q = 0.5;
- top_->atoms.haveCharge = TRUE;
+ // Ensure exact representation of 0.5 is used, so that the test is
+ // reproducible.
+ atoms.atom[5].q = 0.5;
+ atoms.haveCharge = TRUE;
+ ASSERT_NO_FATAL_FAILURE(setTopology());
ASSERT_NO_FATAL_FAILURE(runCompiler());
}
setFlags(TestFlags() | efTestEvaluation | efTestPositionAtoms
| efTestPositionMasses | efTestPositionCharges);
ASSERT_NO_FATAL_FAILURE(runParser(selections));
- ASSERT_NO_FATAL_FAILURE(loadTopology("simple.gro"));
- for (int i = 0; i < top_->atoms.nr; ++i)
+ ASSERT_NO_FATAL_FAILURE(topManager_.loadTopology("simple.gro"));
+ t_atoms &atoms = topManager_.atoms();
+ for (int i = 0; i < atoms.nr; ++i)
{
- top_->atoms.atom[i].m = 1.0 + i / 100.0;
- top_->atoms.atom[i].q = -(1.0 + i / 100.0);
+ atoms.atom[i].m = 1.0 + i / 100.0;
+ atoms.atom[i].q = -(1.0 + i / 100.0);
}
- top_->atoms.haveMass = TRUE;
- top_->atoms.haveCharge = TRUE;
+ atoms.haveMass = TRUE;
+ atoms.haveCharge = TRUE;
+ ASSERT_NO_FATAL_FAILURE(setTopology());
ASSERT_NO_FATAL_FAILURE(runCompiler());
ASSERT_NO_FATAL_FAILURE(runEvaluate());
ASSERT_NO_FATAL_FAILURE(runEvaluateFinal());
"charge {0.05 to -0.3 -0.05 to 0.55}"
};
ASSERT_NO_FATAL_FAILURE(runParser(selections));
- ASSERT_NO_FATAL_FAILURE(loadTopology("simple.gro"));
- for (int i = 0; i < top_->atoms.nr; ++i)
+ ASSERT_NO_FATAL_FAILURE(topManager_.loadTopology("simple.gro"));
+ t_atoms &atoms = topManager_.atoms();
+ for (int i = 0; i < atoms.nr; ++i)
{
- top_->atoms.atom[i].q = i / 10.0 - 0.5;
+ atoms.atom[i].q = i / 10.0 - 0.5;
}
- top_->atoms.haveCharge = TRUE;
+ atoms.haveCharge = TRUE;
+ ASSERT_NO_FATAL_FAILURE(setTopology());
ASSERT_NO_FATAL_FAILURE(runCompiler());
}
{
topManager_.loadTopology(filename);
- ASSERT_NO_THROW_GMX(sc_.setTopology(topManager_.topology(), -1));
+ ASSERT_NO_THROW_GMX(sc_.setTopology(topManager_.mtop(), -1));
}
{
TopologyManager::TopologyManager()
- : top_(NULL), frame_(NULL)
+ : mtop_(nullptr), top_(nullptr), frame_(nullptr)
{
}
TopologyManager::~TopologyManager()
{
- if (top_ != NULL)
+ if (mtop_ != nullptr)
+ {
+ done_mtop(mtop_, TRUE);
+ sfree(mtop_);
+ }
+ else if (top_ != nullptr)
{
done_top(top_);
- sfree(top_);
}
+ sfree(top_);
- if (frame_ != NULL)
+ if (frame_ != nullptr)
{
sfree(frame_->x);
sfree(frame_->v);
void TopologyManager::loadTopology(const char *filename)
{
+ bool fullTopology;
int ePBC;
rvec *xtop = NULL;
matrix box;
- GMX_RELEASE_ASSERT(top_ == NULL, "Topology initialized more than once");
- snew(top_, 1);
- read_tps_conf(gmx::test::TestFileManager::getInputFilePath(filename).c_str(),
- top_, &ePBC, frame_ != NULL ? &xtop : NULL,
- NULL, box, FALSE);
+ GMX_RELEASE_ASSERT(mtop_ == nullptr, "Topology initialized more than once");
+ snew(mtop_, 1);
+ readConfAndTopology(
+ gmx::test::TestFileManager::getInputFilePath(filename).c_str(),
+ &fullTopology, mtop_, &ePBC, frame_ != NULL ? &xtop : NULL,
+ NULL, box);
if (frame_ != NULL)
{
- frame_->natoms = top_->atoms.nr;
+ frame_->natoms = mtop_->natoms;
frame_->bX = TRUE;
snew(frame_->x, frame_->natoms);
std::memcpy(frame_->x, xtop, sizeof(*frame_->x) * frame_->natoms);
void TopologyManager::initAtomTypes(const ConstArrayRef<const char *> &types)
{
- GMX_RELEASE_ASSERT(top_ != NULL, "Topology not initialized");
+ GMX_RELEASE_ASSERT(mtop_ != nullptr, "Topology not initialized");
atomtypes_.reserve(types.size());
for (const char *type : types)
{
atomtypes_.push_back(gmx_strdup(type));
}
- snew(top_->atoms.atomtype, top_->atoms.nr);
- size_t j = 0;
- for (int i = 0; i < top_->atoms.nr; ++i, ++j)
+ t_atoms &atoms = this->atoms();
+ snew(atoms.atomtype, atoms.nr);
+ size_t j = 0;
+ for (int i = 0; i < atoms.nr; ++i, ++j)
{
if (j == types.size())
{
j = 0;
}
- top_->atoms.atomtype[i] = &atomtypes_[j];
+ atoms.atomtype[i] = &atomtypes_[j];
}
- top_->atoms.haveType = TRUE;
+ atoms.haveType = TRUE;
}
void TopologyManager::initUniformResidues(int residueSize)
frame_->natoms = index.size();
}
+t_atoms &TopologyManager::atoms()
+{
+ GMX_RELEASE_ASSERT(mtop_ != nullptr, "Topology not initialized");
+ GMX_RELEASE_ASSERT(mtop_->natoms == mtop_->moltype[0].atoms.nr,
+ "Test setup assumes all atoms in a single molecule type");
+ return mtop_->moltype[0].atoms;
+}
+
} // namespace test
} // namespace gmx
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and 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 <vector>
+struct gmx_mtop_t;
+struct t_atoms;
struct t_topology;
struct t_trxframe;
void initFrameIndices(const ConstArrayRef<int> &index);
t_topology *topology() { return top_; }
+ gmx_mtop_t *mtop() { return mtop_; }
+ t_atoms &atoms();
t_trxframe *frame() { return frame_; }
private:
+ gmx_mtop_t *mtop_;
t_topology *top_;
t_trxframe *frame_;
std::vector<char *> atomtypes_;
return ncg;
}
+int gmx_mtop_nres(const gmx_mtop_t *mtop)
+{
+ int nres = 0;
+ for (int mb = 0; mb < mtop->nmolblock; ++mb)
+ {
+ nres +=
+ mtop->molblock[mb].nmol*
+ mtop->moltype[mtop->molblock[mb].type].atoms.nres;
+ }
+ return nres;
+}
+
void gmx_mtop_remove_chargegroups(gmx_mtop_t *mtop)
{
int mt;
int
ncg_mtop(const gmx_mtop_t *mtop);
+/* Returns the total number of residues in mtop. */
+int gmx_mtop_nres(const gmx_mtop_t *mtop);
+
/* Removes the charge groups, i.e. makes single atom charge groups, in mtop */
void gmx_mtop_remove_chargegroups(gmx_mtop_t *mtop);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and 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 "gromacs/commandline/cmdlineoptionsmodule.h"
#include "gromacs/fileio/trxio.h"
#include "gromacs/math/vec.h"
+#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/arrayref.h"
#include "gromacs/utility/exceptions.h"
*/
TopologyInformation::TopologyInformation()
- : top_(NULL), bTop_(false), xtop_(NULL), ePBC_(-1)
+ : mtop_(NULL), top_(NULL), bTop_(false), xtop_(NULL), ePBC_(-1)
{
clear_mat(boxtop_);
}
TopologyInformation::~TopologyInformation()
{
- if (top_)
+ if (mtop_)
{
- done_top(top_);
- sfree(top_);
+ done_mtop(mtop_, TRUE);
+ sfree(mtop_);
}
+ // TODO: Free that part of the memory that is not shared with mtop_.
+ sfree(top_);
sfree(xtop_);
}
+t_topology *TopologyInformation::topology() const
+{
+ if (top_ == nullptr && mtop_ != nullptr)
+ {
+ snew(top_, 1);
+ *top_ = gmx_mtop_t_to_t_topology(mtop_, false);
+ }
+ return top_;
+}
+
+
void
TopologyInformation::getTopologyConf(rvec **x, matrix box) const
{
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2014,2015,2016, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and 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 "gromacs/options/timeunitmanager.h"
#include "gromacs/utility/classhelpers.h"
+struct gmx_mtop_t;
struct t_topology;
namespace gmx
{
public:
//! Returns true if a topology file was loaded.
- bool hasTopology() const { return top_ != NULL; }
+ bool hasTopology() const { return mtop_ != NULL; }
//! Returns true if a full topology file was loaded.
bool hasFullTopology() const { return bTop_; }
//! Returns the loaded topology, or NULL if not loaded.
- t_topology *topology() const { return top_; }
+ t_topology *topology() const;
//! Returns the ePBC field from the topology.
int ePBC() const { return ePBC_; }
/*! \brief
TopologyInformation();
~TopologyInformation();
+ gmx_mtop_t *mtop_;
//! The topology structure, or NULL if no topology loaded.
- t_topology *top_;
+ // TODO: Replace fully with mtop.
+ mutable t_topology *top_;
//! true if full tpx file was loaded, false otherwise.
bool bTop_;
//! Coordinates from the topology (can be NULL).
void finishTrajectory();
// From ITopologyProvider
- virtual t_topology *getTopology(bool required)
+ virtual gmx_mtop_t *getTopology(bool required)
{
initTopology(required);
- return topInfo_.topology();
+ return topInfo_.mtop_;
}
virtual int getAtomCount()
{
// Load the topology if requested.
if (!topfile_.empty())
{
- snew(topInfo_.top_, 1);
- topInfo_.bTop_ = read_tps_conf(topfile_.c_str(), topInfo_.top_, &topInfo_.ePBC_,
- &topInfo_.xtop_, NULL, topInfo_.boxtop_, FALSE);
+ snew(topInfo_.mtop_, 1);
+ readConfAndTopology(topfile_.c_str(), &topInfo_.bTop_, topInfo_.mtop_,
+ &topInfo_.ePBC_, &topInfo_.xtop_, NULL,
+ topInfo_.boxtop_);
// TODO: Only load this here if the tool actually needs it; selections
// take care of themselves.
- if (!topInfo_.top_->atoms.haveMass)
+ for (int i = 0; i < topInfo_.mtop_->nmoltype; ++i)
{
- // Try to read masses from database, be silent about missing masses
- atomsSetMassesBasedOnNames(&topInfo_.top_->atoms, FALSE);
+ gmx_moltype_t &moltype = topInfo_.mtop_->moltype[i];
+ if (!moltype.atoms.haveMass)
+ {
+ // Try to read masses from database, be silent about missing masses
+ atomsSetMassesBasedOnNames(&moltype.atoms, FALSE);
+ }
}
if (hasTrajectory()
&& !settings_.hasFlag(TrajectoryAnalysisSettings::efUseTopX))