本文整理汇总了C++中AtomMask::MaskString方法的典型用法代码示例。如果您正苦于以下问题:C++ AtomMask::MaskString方法的具体用法?C++ AtomMask::MaskString怎么用?C++ AtomMask::MaskString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AtomMask
的用法示例。
在下文中一共展示了AtomMask::MaskString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MaskToMatResArray
// Action_Matrix::MaskToMatResArray()
Action_Matrix::MatResArray Action_Matrix::MaskToMatResArray(Topology const& currentParm,
AtomMask const& mask) const
{
MatResArray residues;
int currentResNum = -1;
matrix_res blank_res;
for (int idx = 0; idx != mask.Nselected(); idx++)
{
int atom1 = mask[idx];
int resNum = currentParm[atom1].ResNum();
if (resNum != currentResNum) {
residues.push_back( blank_res );
residues.back().resnum_ = resNum;
currentResNum = resNum;
}
residues.back().maskIdxs_.push_back( idx );
}
if (debug_ > 0) {
mprintf("DEBUG: BYRES: MASK '%s'\n", mask.MaskString());
for (MatResArray::const_iterator res = residues.begin(); res != residues.end(); ++res) {
mprintf("\tRes %i:", res->resnum_+1);
for (Iarray::const_iterator it = res->maskIdxs_.begin(); it != res->maskIdxs_.end(); ++it)
mprintf(" %i (%i)", mask[*it] + 1, *it);
mprintf("\n");
}
}
return residues;
}
示例2: Init
// Action_Center::Init()
Action::RetType Action_Center::Init(ArgList& actionArgs, ActionInit& init, int debugIn)
{
// Get keywords
useMass_ = actionArgs.hasKey("mass");
ReferenceFrame refFrm = init.DSL().GetReferenceFrame( actionArgs );
if (refFrm.error()) return Action::ERR;
// Determine center mode.
if (!refFrm.empty())
centerMode_ = REF;
else if (actionArgs.hasKey("origin"))
centerMode_ = ORIGIN;
else if (actionArgs.hasKey("point")) {
centerMode_ = POINT;
refCenter_[0] = actionArgs.getNextDouble(0.0);
refCenter_[1] = actionArgs.getNextDouble(0.0);
refCenter_[2] = actionArgs.getNextDouble(0.0);
} else
centerMode_ = BOXCTR;
// Get Masks
Mask_.SetMaskString( actionArgs.GetMaskNext() );
// Get reference mask if reference specified.
AtomMask refMask;
if (centerMode_ == REF) {
std::string rMaskExpr = actionArgs.GetMaskNext();
if (rMaskExpr.empty())
rMaskExpr = Mask_.MaskExpression();
refMask.SetMaskString( rMaskExpr );
if (refFrm.Parm().SetupIntegerMask( refMask, refFrm.Coord() ))
return Action::ERR;
// Get center of mask in reference
if (useMass_)
refCenter_ = refFrm.Coord().VCenterOfMass( refMask );
else
refCenter_ = refFrm.Coord().VGeometricCenter( refMask );
}
mprintf(" CENTER: Centering coordinates using");
if (useMass_)
mprintf(" center of mass");
else
mprintf(" geometric center");
mprintf(" of atoms in mask (%s) to\n", Mask_.MaskString());
switch (centerMode_) {
case ORIGIN: mprintf("\tcoordinate origin.\n"); break;
case BOXCTR: mprintf("\tbox center.\n"); break;
case REF:
mprintf("\tcenter of mask (%s) in reference '%s'.\n", refMask.MaskString(),
refFrm.refName());
break;
case POINT: mprintf("\tpoint (%g, %g, %g).\n",
refCenter_[0], refCenter_[1], refCenter_[2]);
break;
}
return Action::OK;
}
示例3: Init
// Action_Center::Init()
Action::RetType Action_Center::Init(ArgList& actionArgs, TopologyList* PFL, DataSetList* DSL, DataFileList* DFL, int debugIn)
{
// Get keywords
if (actionArgs.hasKey("origin"))
centerMode_ = ORIGIN;
else
centerMode_ = BOXCTR;
useMass_ = actionArgs.hasKey("mass");
ReferenceFrame refFrm = DSL->GetReferenceFrame( actionArgs );
if (refFrm.error()) return Action::ERR;
// Get Masks
Mask_.SetMaskString( actionArgs.GetMaskNext() );
// Get reference mask if reference specified.
AtomMask refMask;
if (!refFrm.empty()) {
std::string rMaskExpr = actionArgs.GetMaskNext();
if (rMaskExpr.empty())
rMaskExpr = Mask_.MaskExpression();
refMask.SetMaskString( rMaskExpr );
if (refFrm.Parm().SetupIntegerMask( refMask, refFrm.Coord() ))
return Action::ERR;
// Get center of mask in reference
if (useMass_)
refCenter_ = refFrm.Coord().VCenterOfMass( refMask );
else
refCenter_ = refFrm.Coord().VGeometricCenter( refMask );
centerMode_ = POINT;
}
mprintf(" CENTER: Centering coordinates using");
if (useMass_)
mprintf(" center of mass");
else
mprintf(" geometric center");
mprintf(" of atoms in mask (%s) to\n", Mask_.MaskString());
if (centerMode_ == POINT)
mprintf("\tcenter of mask (%s) in reference '%s'.\n", refMask.MaskString(),
refFrm.refName());
else if (centerMode_ == ORIGIN)
mprintf("\tcoordinate origin.\n");
else
mprintf("\tbox center.\n");
return Action::OK;
}
示例4: mprintf
/** Set up masks. */
int Cpptraj::MaskArray::SetupMasks(AtomMask const& maskIn, Topology const& topIn)
{
if (type_ == BY_MOLECULE && topIn.Nmol() < 1) {
mprintf("Warning: '%s' has no molecule information, cannot setup by molecule.\n",
topIn.c_str());
return 1;
}
masks_.clear();
if ( maskIn.None() ) {
mprintf("Warning: Nothing selected by mask '%s'\n", maskIn.MaskString());
return 0;
}
int last = -1;
int current = 0;
maxAtomsPerMask_ = 0;
sameNumAtomsPerMask_ = true;
for (AtomMask::const_iterator atm = maskIn.begin(); atm != maskIn.end(); ++atm)
{
switch (type_) {
case BY_ATOM : current = *atm; break;
case BY_RESIDUE : current = topIn[*atm].ResNum(); break;
case BY_MOLECULE : current = topIn[*atm].MolNum(); break;
}
if (current != last) {
if (!masks_.empty())
checkAtomsPerMask( masks_.back().Nselected() );
masks_.push_back( AtomMask() );
masks_.back().SetNatoms( topIn.Natom() );
}
masks_.back().AddSelectedAtom( *atm );
last = current;
}
if (!masks_.empty())
checkAtomsPerMask( masks_.back().Nselected() );
return 0;
}
示例5: MaskError
static inline Exec::RetType MaskError(AtomMask const& mask) {
mprinterr("Error: Mask '%s' selects %i atoms, expected 1.\n",
mask.MaskString(), mask.Nselected());
return CpptrajState::ERR;
}