// Action_Esander::Init() Action::RetType Action_Esander::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { # ifdef MPI trajComm_ = init.TrajComm(); # endif SANDER_.SetDebug( debugIn ); Init_ = init; // Get keywords outfile_ = init.DFL().AddDataFile( actionArgs.GetStringKey("out"), actionArgs ); save_forces_ = actionArgs.hasKey("saveforces"); ReferenceFrame REF = init.DSL().GetReferenceFrame( actionArgs ); if (REF.error()) return Action::ERR; if (!REF.empty()) { refFrame_ = REF.Coord(); currentParm_ = REF.ParmPtr(); } if (SANDER_.SetInput( actionArgs )) return Action::ERR; // DataSet name and array setname_ = actionArgs.GetStringNext(); if (setname_.empty()) setname_ = init.DSL().GenerateDefaultName("ENE"); Esets_.clear(); Esets_.resize( (int)Energy_Sander::N_ENERGYTYPES, 0 ); mprintf(" ESANDER: Calculating energy using Sander.\n"); mprintf("\tTemporary topology file name is '%s'\n", SANDER_.TopFilename().full()); if (save_forces_) mprintf("\tSaving force information to frame.\n"); mprintf("\tReference for initialization"); if (!REF.empty()) mprintf(" is '%s'\n", REF.refName()); else mprintf(" will be first frame.\n"); return Action::OK; }
// Action_Unwrap::Init() Action::RetType Action_Unwrap::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { // Get Keywords center_ = actionArgs.hasKey("center"); if (actionArgs.hasKey("bymol")) imageMode_ = Image::BYMOL; else if (actionArgs.hasKey("byres")) imageMode_ = Image::BYRES; else if (actionArgs.hasKey("byatom")) { imageMode_ = Image::BYATOM; // Unwrapping to center by atom makes no sense if (center_) center_ = false; } else imageMode_ = Image::BYATOM; // Get reference ReferenceFrame REF = init.DSL().GetReferenceFrame( actionArgs ); if (REF.error()) return Action::ERR; if (!REF.empty()) { RefFrame_ = REF.Coord(); // Get reference parm for frame RefParm_ = REF.ParmPtr(); } // Get mask string maskExpression_ = actionArgs.GetMaskNext(); mprintf(" UNWRAP: By %s", Image::ModeString(imageMode_)); if (!maskExpression_.empty()) mprintf(" using mask '%s'", maskExpression_.c_str()); else mprintf(" using all atoms"); if (imageMode_ != Image::BYATOM) { if (center_) mprintf(" based on center of mass."); else mprintf(" based on first atom position."); } mprintf("\n"); if ( !REF.empty()) mprintf("\tReference is %s", REF.refName()); else mprintf("\tReference is first frame."); mprintf("\n"); return Action::OK; }
/** Called once before traj processing. Set up reference info. */ Action::RetType Action_Rmsd::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { debug_ = debugIn; // Check for keywords fit_ = !actionArgs.hasKey("nofit"); if (fit_) rotate_ = !actionArgs.hasKey("norotate"); useMass_ = actionArgs.hasKey("mass"); DataFile* outfile = init.DFL().AddDataFile(actionArgs.GetStringKey("out"), actionArgs); bool saveMatrices = actionArgs.hasKey("savematrices"); // Reference keywords bool previous = actionArgs.hasKey("previous"); bool first = actionArgs.hasKey("first"); ReferenceFrame refFrm = init.DSL().GetReferenceFrame( actionArgs ); std::string reftrajname = actionArgs.GetStringKey("reftraj"); if (!reftrajname.empty()) RefParm_ = init.DSL().GetTopology( actionArgs ); // Per-res keywords perres_ = actionArgs.hasKey("perres"); if (perres_) { perresout_ = init.DFL().AddDataFile( actionArgs.GetStringKey("perresout") ); perresinvert_ = actionArgs.hasKey("perresinvert"); TgtRange_.SetRange( actionArgs.GetStringKey("range") ); RefRange_.SetRange( actionArgs.GetStringKey("refrange") ); perresmask_ = actionArgs.GetStringKey("perresmask"); if (perresmask_.empty()) perresmask_.assign(""); else { // If perresmask does not start with ampersand, insert one. if (perresmask_[0] != '&') perresmask_ = '&' + perresmask_; } perrescenter_ = actionArgs.hasKey("perrescenter"); perresavg_ = init.DFL().AddDataFile( actionArgs.GetStringKey("perresavg") ); } // Get the RMS mask string for target std::string tMaskExpr = actionArgs.GetMaskNext(); tgtMask_.SetMaskString(tMaskExpr); // Get the RMS mask string for reference std::string rMaskExpr = actionArgs.GetMaskNext(); if (rMaskExpr.empty()) rMaskExpr = tMaskExpr; // Initialize reference if (REF_.InitRef(previous, first, useMass_, fit_, reftrajname, refFrm, RefParm_, rMaskExpr, actionArgs, "rmsd")) return Action::ERR; // Set RefParm for perres if not empty if (perres_ && RefParm_ == 0 && !refFrm.empty()) RefParm_ = refFrm.ParmPtr(); // Set up the RMSD data set. MetaData md( actionArgs.GetStringNext(), MetaData::M_RMS ); rmsd_ = init.DSL().AddSet(DataSet::DOUBLE, md, "RMSD"); if (rmsd_==0) return Action::ERR; // Add dataset to data file list if (outfile != 0) outfile->AddDataSet( rmsd_ ); // Set up rotation matrix data set if specified if (saveMatrices) { md.SetAspect("RM"); if (!fit_) { mprinterr("Error: Must be fitting in order to save rotation matrices.\n"); return Action::ERR; } rmatrices_ = init.DSL().AddSet(DataSet::MAT3X3, md); if (rmatrices_ == 0) return Action::ERR; } mprintf(" RMSD: (%s), reference is %s", tgtMask_.MaskString(), REF_.RefModeString()); if (!fit_) mprintf(", no fitting"); else { mprintf(", with fitting"); if (!rotate_) mprintf(" (no rotation)"); } if (useMass_) mprintf(", mass-weighted"); mprintf(".\n"); if (rmatrices_ != 0) mprintf("\tRotation matrices will be saved to set '%s'\n", rmatrices_->legend()); // Per-residue RMSD info. if (perres_) { mprintf(" No-fit RMSD will also be calculated for "); if (TgtRange_.Empty()) mprintf("each solute residue"); else mprintf("residues %s",TgtRange_.RangeArg()); if (!RefRange_.Empty()) mprintf(" (reference residues %s)",RefRange_.RangeArg()); mprintf(" using mask [:X%s].\n",perresmask_.c_str()); if (perresout_ != 0) mprintf(" Per-residue output file is %s\n",perresout_->DataFilename().base()); if (perresavg_ != 0) mprintf(" Avg per-residue output file is %s\n",perresavg_->DataFilename().base()); if (perrescenter_) mprintf(" perrescenter: Each residue will be centered prior to RMS calc.\n"); if (perresinvert_) mprintf(" perresinvert: Frames will be written in rows instead of columns.\n"); } if (perres_) init.DSL().SetDataSetsPending(true); masterDSL_ = init.DslPtr(); return Action::OK; }