本文整理汇总了C++中FileName::SetFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::SetFileName方法的具体用法?C++ FileName::SetFileName怎么用?C++ FileName::SetFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::SetFileName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
//.........这里部分代码省略.........
mprinterr("Error: Must only specify 'first' or a reference structure, not both.\n");
return Action::ERR;
}
}
// Create data sets
std::string name = actionArgs.GetStringKey("name");
if (name.empty())
name = init.DSL().GenerateDefaultName("Contacts");
numnative_ = init.DSL().AddSet(DataSet::INTEGER, MetaData(name, "native"));
nonnative_ = init.DSL().AddSet(DataSet::INTEGER, MetaData(name, "nonnative"));
if (outfile != 0) {
outfile->AddDataSet(numnative_);
outfile->AddDataSet(nonnative_);
}
if (numnative_ == 0 || nonnative_ == 0) return Action::ERR;
if (actionArgs.hasKey("mindist")) {
mindist_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(name, "mindist"));
if (mindist_ == 0) return Action::ERR;
if (outfile != 0) outfile->AddDataSet(mindist_);
}
if (actionArgs.hasKey("maxdist")) {
maxdist_ = init.DSL().AddSet(DataSet::DOUBLE, MetaData(name, "maxdist"));
if (maxdist_ == 0) return Action::ERR;
if (outfile != 0) outfile->AddDataSet(maxdist_);
}
DataFile *natmapfile = 0, *nonmapfile = 0;
if (actionArgs.hasKey("map")) {
nativeMap_ = (DataSet_MatrixDbl*)init.DSL().AddSet(DataSet::MATRIX_DBL, MetaData(name, "nativemap"));
if (nativeMap_ == 0) return Action::ERR;
nonnatMap_ = (DataSet_MatrixDbl*)init.DSL().AddSet(DataSet::MATRIX_DBL, MetaData(name, "nonnatmap"));
if (nonnatMap_ == 0) return Action::ERR;
FileName mapFilename;
mapFilename.SetFileName( actionArgs.GetStringKey("mapout") );
if (!mapFilename.empty()) {
natmapfile = init.DFL().AddDataFile(mapFilename.PrependFileName("native."));
if (natmapfile != 0) natmapfile->AddDataSet(nativeMap_);
nonmapfile = init.DFL().AddDataFile(mapFilename.PrependFileName("nonnative."));
if (nonmapfile != 0) nonmapfile->AddDataSet(nonnatMap_);
}
}
// Get Masks
if (Mask1_.SetMaskString( actionArgs.GetMaskNext() )) return Action::ERR;
std::string mask2 = actionArgs.GetMaskNext();
if (!mask2.empty()) {
if (Mask2_.SetMaskString( mask2 )) return Action::ERR;
}
mprintf(" NATIVECONTACTS: Mask1='%s'", Mask1_.MaskString());
if (Mask2_.MaskStringSet())
mprintf(" Mask2='%s'", Mask2_.MaskString());
if (determineNativeContacts_) {
mprintf(", native contacts set up based on");
if (first_)
mprintf(" first frame.\n");
else
mprintf("'%s'.\n", REF.refName());
} else {
mprintf(", skipping native contacts set up.\n");
}
if (byResidue_) {
mprintf("\tContacts will be ignored for residues spaced < %i apart.\n", resoffset_);
if (nativeMap_ != 0)
mprintf("\tMap will be printed by residue.\n");
}
if (saveNonNative_)
mprintf("\tSaving non-native contacts as well (may use a lot of memory).\n");
示例2: Init
// Action_Spam::init()
Action::RetType Action_Spam::Init(ArgList& actionArgs, TopologyList* PFL, DataSetList* DSL, DataFileList* DFL, int debugIn)
{
// Always use imaged distances
InitImaging(true);
// This is needed everywhere in this function scope
FileName filename;
// See if we're doing pure water. If so, we don't need a peak file
purewater_ = actionArgs.hasKey("purewater");
if (purewater_) {
// We still need the cutoff
double cut = actionArgs.getKeyDouble("cut", 12.0);
cut2_ = cut * cut;
doublecut_ = 2 * cut;
onecut2_ = 1 / cut2_;
// See if we write to a data file
datafile_ = actionArgs.GetStringKey("out");
// Generate the data set name, and hold onto the master data set list
std::string ds_name = actionArgs.GetStringKey("name");
if (ds_name.empty())
ds_name = myDSL_.GenerateDefaultName("SPAM");
// We only have one data set averaging over every water. Add it here
myDSL_.AddSet(DataSet::DOUBLE, ds_name, NULL);
solvname_ = actionArgs.GetStringKey("solv");
if (solvname_.empty())
solvname_ = std::string("WAT");
}else {
// Get the file name with the peaks defined in it
filename.SetFileName( actionArgs.GetStringNext() );
if (filename.empty() || !File::Exists(filename)) {
mprinterr("Spam: Error: Peak file [%s] does not exist!\n", filename.full());
return Action::ERR;
}
// Get the remaining optional arguments
solvname_ = actionArgs.GetStringKey("solv");
if (solvname_.empty())
solvname_ = std::string("WAT");
reorder_ = actionArgs.hasKey("reorder");
bulk_ = actionArgs.getKeyDouble("bulk", 0.0);
double cut = actionArgs.getKeyDouble("cut", 12.0);
cut2_ = cut * cut;
doublecut_ = 2 * cut;
onecut2_ = 1 / cut2_;
std::string infoname = actionArgs.GetStringKey("info");
if (infoname.empty())
infoname = std::string("spam.info");
infofile_ = DFL->AddCpptrajFile(infoname, "SPAM info");
if (infofile_ == 0) return Action::ERR;
// The default maskstr is the Oxygen atom of the solvent
summaryfile_ = actionArgs.GetStringKey("summary");
// Divide site size by 2 to make it half the edge length (or radius)
site_size_ = actionArgs.getKeyDouble("site_size", 2.5) / 2.0;
sphere_ = actionArgs.hasKey("sphere");
// If it's a sphere, square the radius to compare with
if (sphere_)
site_size_ *= site_size_;
datafile_ = actionArgs.GetStringKey("out");
std::string ds_name = actionArgs.GetStringKey("name");
if (ds_name.empty())
ds_name = myDSL_.GenerateDefaultName("SPAM");
// Parse through the peaks file and extract the peaks
CpptrajFile peakfile;
if (peakfile.OpenRead(filename)) {
mprinterr("SPAM: Error: Could not open %s for reading!\n", filename.full());
return Action::ERR;
}
std::string line = peakfile.GetLine();
int npeaks = 0;
while (!line.empty()) {
if (sscanf(line.c_str(), "%d", &npeaks) != 1) {
line = peakfile.GetLine();
continue;
}
line = peakfile.GetLine();
break;
}
while (!line.empty()) {
double x, y, z, dens;
if (sscanf(line.c_str(), "C %lg %lg %lg %lg", &x, &y, &z, &dens) != 4) {
line = peakfile.GetLine();
continue;
}
line = peakfile.GetLine();
peaks_.push_back(Vec3(x, y, z));
}
peakfile.CloseFile();
// Check that our initial number of peaks matches our parsed peaks. Warn
// otherwise
if (npeaks != (int)peaks_.size())
mprinterr("SPAM: Warning: %s claims to have %d peaks, but really has %d!\n",
filename.full(), npeaks, peaks_.size());
// Now add all of the data sets
MetaData md(ds_name);
for (int i = 0; i < (int)peaks_.size(); i++) {
md.SetAspect( integerToString(i+1) ); // TODO: Should this be Idx?
//.........这里部分代码省略.........