Exec::RetType Exec_Precision::Execute(CpptrajState& State, ArgList& argIn) { // Next string is DataSet(s)/DataFile that command pertains to. std::string name1 = argIn.GetStringNext(); if (name1.empty()) { mprinterr("Error: No filename/setname given.\n"); return CpptrajState::ERR; } // This will break if dataset name starts with a digit... int width = argIn.getNextInteger(12); if (width < 1) { mprintf("Error: Cannot set width < 1 (%i).\n", width); return CpptrajState::ERR; } int precision = argIn.getNextInteger(4); if (precision < 0) precision = 0; DataFile* df = State.DFL().GetDataFile(name1); if (df != 0) { mprintf("\tSetting precision for all sets in %s to %i.%i\n", df->DataFilename().base(), width, precision); df->SetDataFilePrecision(width, precision); } else { State.DSL().SetPrecisionOfDataSets( name1, width, precision ); } return CpptrajState::OK; }
// Action_Closest::Init() Action_Closest::RetType Action_Closest::Init(ArgList& actionArgs, int debugIn) { debug_ = debugIn; // Get Keywords closestWaters_ = actionArgs.getNextInteger(-1); if (closestWaters_ < 0) { mprinterr("Error: Invalid # solvent molecules to keep (%i).\n", closestWaters_); return Action_Closest::ERR; } if ( actionArgs.hasKey("oxygen") || actionArgs.hasKey("first") ) firstAtom_=true; useMaskCenter_ = actionArgs.hasKey("center"); image_.InitImaging( !(actionArgs.hasKey("noimage")) ); // Get Masks std::string mask1 = actionArgs.GetMaskNext(); if (mask1.empty()) { mprinterr("Error: No mask specified.\n"); return Action_Closest::ERR; } distanceMask_.SetMaskString(mask1); mprintf(" CLOSEST: Finding closest %i solvent molecules to atoms in mask %s\n", closestWaters_, distanceMask_.MaskString()); if (useMaskCenter_) mprintf("\tGeometric center of atoms in mask will be used.\n"); if (!image_.UseImage()) mprintf("\tImaging will be turned off.\n"); if (firstAtom_) mprintf("\tOnly first atom of solvent molecule used for distance calc.\n"); return Action_Closest::OK; }
/// \return 1 if problem with or not a Tinker Atom/Title line. static inline int SetNatomAndTitle(ArgList& lineIn, int& natom, std::string& title) { if (lineIn.Nargs() < 1) return 1; natom = lineIn.getNextInteger( -1 ); if (natom < 1) return 1; std::string nextWord = lineIn.GetStringNext(); //if (nextWord.empty()) return 1; while (!nextWord.empty()) { if (!title.empty()) title += ' '; title.append( nextWord ); nextWord = lineIn.GetStringNext(); } return 0; }