本文整理汇总了C++中DataFile::AddSet方法的典型用法代码示例。如果您正苦于以下问题:C++ DataFile::AddSet方法的具体用法?C++ DataFile::AddSet怎么用?C++ DataFile::AddSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFile
的用法示例。
在下文中一共展示了DataFile::AddSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
// Action_Dihedral::init()
Action::RetType Action_Dihedral::Init(ArgList& actionArgs, TopologyList* PFL, FrameList* FL,
DataSetList* DSL, DataFileList* DFL, int debugIn)
{
// Get keywords
DataFile* outfile = DFL->AddDataFile( actionArgs.GetStringKey("out"), actionArgs );
useMass_ = actionArgs.hasKey("mass");
DataSet::scalarType stype = DataSet::UNDEFINED;
range360_ = actionArgs.hasKey("range360");
std::string stypename = actionArgs.GetStringKey("type");
if ( stypename == "alpha" ) stype = DataSet::ALPHA;
else if ( stypename == "beta" ) stype = DataSet::BETA;
else if ( stypename == "gamma" ) stype = DataSet::GAMMA;
else if ( stypename == "delta" ) stype = DataSet::DELTA;
else if ( stypename == "epsilon" ) stype = DataSet::EPSILON;
else if ( stypename == "zeta" ) stype = DataSet::ZETA;
else if ( stypename == "chi" ) stype = DataSet::CHI;
else if ( stypename == "c2p" ) stype = DataSet::C2P;
else if ( stypename == "h1p" ) stype = DataSet::H1P;
else if ( stypename == "phi" ) stype = DataSet::PHI;
else if ( stypename == "psi" ) stype = DataSet::PSI;
else if ( stypename == "pchi" ) stype = DataSet::PCHI;
// Get Masks
std::string mask1 = actionArgs.GetMaskNext();
std::string mask2 = actionArgs.GetMaskNext();
std::string mask3 = actionArgs.GetMaskNext();
std::string mask4 = actionArgs.GetMaskNext();
if (mask1.empty() || mask2.empty() || mask3.empty() || mask4.empty()) {
mprinterr("Error: dihedral: Requires 4 masks\n");
return Action::ERR;
}
M1_.SetMaskString(mask1);
M2_.SetMaskString(mask2);
M3_.SetMaskString(mask3);
M4_.SetMaskString(mask4);
// Setup dataset
dih_ = DSL->AddSet(DataSet::DOUBLE, actionArgs.GetStringNext(),"Dih");
if (dih_==0) return Action::ERR;
dih_->SetScalar( DataSet::M_TORSION, stype );
// Add dataset to datafile list
if (outfile != 0) outfile->AddSet( dih_ );
mprintf(" DIHEDRAL: [%s]-[%s]-[%s]-[%s]\n", M1_.MaskString(),
M2_.MaskString(), M3_.MaskString(), M4_.MaskString());
if (useMass_)
mprintf(" Using center of mass of atoms in masks.\n");
if (range360_)
mprintf(" Output range is 0 to 360 degrees.\n");
else
mprintf(" Output range is -180 to 180 degrees.\n");
return Action::OK;
}
示例2: Init
// Action_Distance::init()
Action::RetType Action_Distance::Init(ArgList& actionArgs, TopologyList* PFL, FrameList* FL,
DataSetList* DSL, DataFileList* DFL, int debugIn)
{
// Get Keywords
InitImaging( !(actionArgs.hasKey("noimage")) );
useMass_ = !(actionArgs.hasKey("geom"));
DataFile* outfile = DFL->AddDataFile( actionArgs.GetStringKey("out"), actionArgs );
DataSet::scalarType stype = DataSet::UNDEFINED;
std::string stypename = actionArgs.GetStringKey("type");
if ( stypename == "hbond" ) stype = DataSet::HBOND;
else if (stypename == "noe" ) stype = DataSet::NOE; // TODO: Grab bound and boundh
// Get Masks
std::string mask1 = actionArgs.GetMaskNext();
std::string mask2 = actionArgs.GetMaskNext();
if (mask1.empty() || mask2.empty()) {
mprinterr("Error: distance: Requires 2 masks\n");
return Action::ERR;
}
Mask1_.SetMaskString(mask1);
Mask2_.SetMaskString(mask2);
// Dataset to store distances
dist_ = DSL->AddSet(DataSet::DOUBLE, actionArgs.GetStringNext(), "Dis");
if (dist_==0) return Action::ERR;
dist_->SetScalar( DataSet::M_DISTANCE, stype );
// Add dataset to data file
if (outfile != 0) outfile->AddSet( dist_ );
mprintf(" DISTANCE: %s to %s",Mask1_.MaskString(), Mask2_.MaskString());
if (!UseImage())
mprintf(", non-imaged");
if (useMass_)
mprintf(", center of mass");
else
mprintf(", geometric center");
mprintf(".\n");
return Action::OK;
}
示例3: Init
/** Called once before traj processing. Set up reference info. */
Action::RetType Action_Rmsd::Init(ArgList& actionArgs, TopologyList* PFL, FrameList* FL,
DataSetList* DSL, DataFileList* DFL, int debugIn)
{
// Check for keywords
GetRmsKeywords( actionArgs );
DataFile* outfile = DFL->AddDataFile(actionArgs.GetStringKey("out"), actionArgs);
// Reference keywords
bool previous = actionArgs.hasKey("previous");
bool first = actionArgs.hasKey("first");
ReferenceFrame REF = FL->GetFrameFromArgs( actionArgs );
std::string reftrajname = actionArgs.GetStringKey("reftraj");
RefParm_ = PFL->GetParm( actionArgs );
// Per-res keywords
perres_ = actionArgs.hasKey("perres");
if (perres_) {
perresout_ = DFL->AddDataFile( actionArgs.GetStringKey("perresout") );
perresinvert_ = actionArgs.hasKey("perresinvert");
ResRange_.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_ = DFL->AddDataFile( actionArgs.GetStringKey("perresavg") );
}
// Get the RMS mask string for target
std::string mask1 = GetRmsMasks(actionArgs);
// Initialize reference
if (InitRef(previous, first, UseMass(), Fit(), reftrajname, REF, RefParm_, mask1,
actionArgs, "rmsd"))
return Action::ERR;
// Set RefParm for perres if not empty
if (perres_ && RefParm_ == 0 && !REF.empty())
RefParm_ = REF.Parm();
// Set up the RMSD data set.
rmsd_ = DSL->AddSet(DataSet::DOUBLE, actionArgs.GetStringNext(),"RMSD");
if (rmsd_==0) return Action::ERR;
rmsd_->SetScalar( DataSet::M_RMS );
// Add dataset to data file list
if (outfile != 0) outfile->AddSet( rmsd_ );
mprintf(" RMSD: (%s), reference is %s",TgtMask().MaskString(),
RefModeString());
PrintRmsStatus();
// Per-residue RMSD info.
if (perres_) {
mprintf(" No-fit RMSD will also be calculated for ");
if (ResRange_.Empty())
mprintf("each solute residue");
else
mprintf("residues %s",ResRange_.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");
}
masterDSL_ = DSL;
return Action::OK;
}
示例4: Setup
Analysis::RetType Analysis_Lifetime::Setup(ArgList& analyzeArgs, DataSetList* datasetlist,
TopologyList* PFLin, DataFileList* DFLin, int debugIn)
{
// Get Keywords
DataFile* outfile = DFLin->AddDataFile(analyzeArgs.GetStringKey("out"), analyzeArgs);
if (outfile != 0) outfile->ProcessArgs("noemptyframes");
DataFile* maxfile = 0;
DataFile* avgfile = 0;
std::string setname = analyzeArgs.GetStringKey("name");
windowSize_ = analyzeArgs.getKeyInt("window", -1);
averageonly_ = analyzeArgs.hasKey("averageonly");
if (!averageonly_ && outfile != 0) {
maxfile = DFLin->AddDataFile("max." + outfile->DataFilename().Full(), analyzeArgs);
maxfile->ProcessArgs("noemptyframes");
avgfile = DFLin->AddDataFile("avg." + outfile->DataFilename().Full(), analyzeArgs);
avgfile->ProcessArgs("noemptyframes");
}
cumulative_ = analyzeArgs.hasKey("cumulative");
deltaAvg_ = analyzeArgs.hasKey("delta");
cut_ = analyzeArgs.getKeyDouble("cut", 0.5);
// Select datasets from remaining args
ArgList dsetArgs = analyzeArgs.RemainingArgs();
for (ArgList::const_iterator dsa = dsetArgs.begin(); dsa != dsetArgs.end(); ++dsa)
inputDsets_ += datasetlist->GetMultipleSets( *dsa );
if (inputDsets_.empty()) {
mprinterr("Error: lifetime: No data sets selected.\n");
return Analysis::ERR;
}
// Sort input datasets
inputDsets_.sort();
// Create output datasets
if ( windowSize_ != -1) {
if (setname.empty())
setname = datasetlist->GenerateDefaultName( "lifetime" );
int didx = 0;
for (DataSetList::const_iterator set = inputDsets_.begin(); set != inputDsets_.end(); ++set)
{
DataSet* outSet = datasetlist->AddSetIdx( DataSet::FLOAT, setname, didx );
if (outSet==0) {
mprinterr("Error: lifetime: Could not allocate output set for %s\n",
(*set)->Legend().c_str());
return Analysis::ERR;
}
outSet->SetLegend( (*set)->Legend() );
outputDsets_.push_back( outSet );
if (outfile != 0) outfile->AddSet( outSet );
if (!averageonly_) {
// MAX
// FIXME: CHeck for nullS
outSet = datasetlist->AddSetIdxAspect( DataSet::INT, setname, didx, "max" );
outSet->SetLegend( (*set)->Legend() );
maxDsets_.push_back( outSet );
if (maxfile != 0) maxfile->AddSet( outSet );
// AVG
outSet = datasetlist->AddSetIdxAspect( DataSet::FLOAT, setname, didx, "avg" );
outSet->SetLegend( (*set)->Legend() );
avgDsets_.push_back( outSet );
if (avgfile != 0) avgfile->AddSet( outSet );
}
++didx;
}
} else if (outfile != 0) {
mprinterr("Error: Output file name specified but no window size given ('window <N>')\n");
return Analysis::ERR;
}
if (!averageonly_)
mprintf(" LIFETIME: Calculating average lifetime using a cutoff of %f", cut_);
else
mprintf(" LIFETIME: Calculating only averages");
mprintf(" of data in %i sets\n", inputDsets_.size());
if (debugIn > 0)
inputDsets_.List();
if (windowSize_ != -1) {
mprintf("\tAverage of data over windows will be saved to sets named %s\n",
setname.c_str());
mprintf("\tWindow size for averaging: %i\n", windowSize_);
if (cumulative_)
mprintf("\tCumulative averages will be saved.\n");
if (deltaAvg_)
mprintf("\tChange of average from previous average will be saved.\n");
if (outfile != 0) {
mprintf("\tOutfile: %s", outfile->DataFilename().base());
if (!averageonly_)
mprintf(", %s, %s", maxfile->DataFilename().base(), avgfile->DataFilename().base());
mprintf("\n");
}
}
return Analysis::OK;
}