本文整理汇总了C++中Param::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ Param::insert方法的具体用法?C++ Param::insert怎么用?C++ Param::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Param
的用法示例。
在下文中一共展示了Param::insert方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getParameters
Param MSSim::getParameters() const
{
Param tmp;
tmp.insert("", this->param_); // get non-labeling options
vector<String> products = Factory<BaseLabeler>::registeredProducts();
tmp.setValue("Labeling:type", "labelfree", "Select the labeling type you want for your experiment");
tmp.setValidStrings("Labeling:type", products);
for (vector<String>::iterator product_name = products.begin(); product_name != products.end(); ++product_name)
{
BaseLabeler* labeler = Factory<BaseLabeler>::create(*product_name);
if (labeler)
{
tmp.insert("Labeling:" + *product_name + ":", labeler->getDefaultParameters());
if (!tmp.copy("Labeling:" + *product_name).empty())
{
// if parameters of labeler are empty, the section will not exist and
// the command below would fail
tmp.setSectionDescription("Labeling:" + *product_name, labeler->getDescription());
}
delete(labeler);
}
else
{
throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "This labeler returned by the Factory is invalid!", product_name->c_str());
}
}
return tmp;
}
示例2: getSubsectionDefaults_
Param getSubsectionDefaults_(const String& /*section*/) const override
{
Param combined;
Param p_com;
p_com.setValue("noise_threshold_int", 10.0, "Intensity threshold below which peaks are regarded as noise.");
p_com.setValue("chrom_peak_snr", 3.0, "Minimum signal-to-noise a mass trace should have.");
p_com.setValue("chrom_fwhm", 5.0, "Expected chromatographic peak width (in seconds).");
combined.insert("common:", p_com);
Param p_mtd = MassTraceDetection().getDefaults();
p_mtd.remove("noise_threshold_int");
p_mtd.remove("chrom_peak_snr");
combined.insert("mtd:", p_mtd);
Param p_epd = ElutionPeakDetection().getDefaults();
p_epd.remove("noise_threshold_int");
p_epd.remove("chrom_peak_snr");
p_epd.remove("chrom_fwhm");
p_epd.setValue("enabled", "true", "Enables/disables the chromatographic peak detection of mass traces");
p_epd.setValidStrings("enabled", ListUtils::create<String>("true,false"));
combined.insert("epd:", p_epd);
return combined;
}
示例3: getSubsectionDefaults_
Param getSubsectionDefaults_(const String & /*section*/) const
{
Param tmp;
tmp.insert("Extraction:", ItraqChannelExtractor(ItraqQuantifier::FOURPLEX).getParameters()); // type is irrelevant - ini is the same
tmp.insert("Quantification:", ItraqQuantifier(ItraqQuantifier::FOURPLEX).getParameters()); // type is irrelevant - ini is the same
tmp.setValue("MetaInformation:Program", "OpenMS::ITRAQAnalyzer", "", StringList::create("advanced"));
return tmp;
}
示例4: getSubsectionDefaults_
Param getSubsectionDefaults_(const String & /*section*/) const
{
Param tmp;
tmp.insert("Extraction:", ItraqChannelExtractor(ItraqQuantifier::TMT_SIXPLEX).getParameters());
tmp.insert("Quantification:", ItraqQuantifier(ItraqQuantifier::TMT_SIXPLEX).getParameters());
tmp.setValue("MetaInformation:Program", "OpenMS::TMTAnalyzer", "", ListUtils::create<String>("advanced"));
return tmp;
}
示例5: getSubsectionDefaults_
Param getSubsectionDefaults_(const String& /*section*/) const
{
// there is only one subsection: 'algorithm' (s.a) .. and in it belongs the PeakPicker param
Param tmp;
tmp.insert("PeakPicker:", PeakPickerCWT().getDefaults());
return tmp;
}
示例6: getSubsectionDefaults_
Param getSubsectionDefaults_(const String & /*section*/) const
{
// there is only one subsection: 'algorithm' (s.a) .. and in it belongs the FeatureDecharger param
FeatureDeconvolution fdc;
Param tmp;
tmp.insert("FeatureDeconvolution:", fdc.getParameters());
return tmp;
}
示例7: getParameters
Param FeatureFinder::getParameters(const String& algorithm_name) const
{
Param tmp;
if (algorithm_name != "none")
{
FeatureFinderAlgorithm* a = Factory<FeatureFinderAlgorithm>::create(algorithm_name);
tmp.insert("", a->getDefaultParameters());
delete(a);
}
return tmp;
}
示例8: syncParams_
void MSSim::syncParams_(Param& p, bool to_outer)
{
vector<StringList> globals;
// here the globals params are listed that require to be in sync across several modules
// - first the global param name and following that the module names where this param occurs
// - Warning: the module params must have unchanged names and restrictions! (descriptions can differ though)
globals.push_back(ListUtils::create<String>("ionization_type,Ionization,RawSignal,RawTandemSignal"));
String global_prefix = "Global";
// remove or add local params
if (to_outer) // remove local params and merge to global
{
for (Size i = 0; i < globals.size(); ++i)
{
// set the global param:
OPENMS_PRECONDITION(globals[i].size() >= 2, "Param synchronisation aborting due to missing local parameters!");
p.insert(global_prefix + ":" + globals[i][0], p.copy(globals[i][1] + ":" + globals[i][0], true));
// remove local params
for (Size i_local = 1; i_local < globals[i].size(); ++i_local)
{
p.remove(globals[i][i_local] + ":" + globals[i][0]);
}
}
}
else // restore local params from global one
{
for (Size i = 0; i < globals.size(); ++i)
{
// get the global param:
OPENMS_PRECONDITION(globals[i].size() >= 2, "Param synchronisation aborting due to missing local parameters!");
Param p_global = p.copy(global_prefix + ":" + globals[i][0], true);
// insert into local params
for (Size i_local = 1; i_local < globals[i].size(); ++i_local)
{
p.insert(globals[i][i_local] + ":" + globals[i][0], p_global);
}
}
}
}
示例9: updateINI
void updateINI(const String& infile, const String& outfile)
{
Int this_instance = getIntOption_("instance");
INIUpdater updater;
String tmp_ini_file = File::getTempDirectory() + "/" + File::getUniqueName() + "_INIUpdater.ini";
tmp_files_.push_back(tmp_ini_file);
String path = File::getExecutablePath();
Param p;
ParamXMLFile paramFile;
paramFile.load(infile, p);
// get sections (usually there is only one - or the user has merged INI files manually)
StringList sections = updater.getToolNamesFromINI(p);
if (sections.empty())
{
writeLog_("Update for file " + infile + " failed because tool section does not exist. Check INI file for corruption!");
failed_.push_back(infile);
return;
}
// get version of first section
String version_old = "Unknown";
if (!p.exists(sections[0] + ":version"))
{
writeLog_("No OpenMS version information found in file " + infile + "! Cannot update!");
failed_.push_back(infile);
return;
}
else
{
version_old = p.getValue(sections[0] + ":version");
// TODO: return on newer version?!
}
// update sections
writeDebug_("Section names: " + ListUtils::concatenate(sections, ", "), 1);
bool update_success = true;
for (Size s = 0; s < sections.size(); ++s)
{
String sec_inst = sections[s] + ":" + String(this_instance) + ":";
// check for default instance
if (!p.exists(sec_inst + "debug"))
{
writeLog_("Update for file '" + infile + "' failed because the instance section '" + sec_inst + "' does not exist. Use -instance or check INI file for corruption!");
update_success = false;
break;
}
String new_tool;
String ttype;
// find mapping to new tool (might be the same name)
if (p.exists(sec_inst + "type")) ttype = p.getValue(sec_inst + "type");
if (!updater.getNewToolName(sections[s], ttype, new_tool))
{
String type_text = ((ttype == "") ? "" : " with type '" + ttype + "' ");
writeLog_("Update for file '" + infile + "' failed because the tool '" + sections[s] + "'" + type_text + "is unknown. TOPPAS file seems to be corrupted!");
update_success = false;
break;
}
// get defaults of new tool by calling it
QProcess pr;
QStringList arguments;
arguments << "-write_ini";
arguments << tmp_ini_file.toQString();
arguments << "-instance";
arguments << String(this_instance).toQString();
pr.start((path + "/" + new_tool).toQString(), arguments);
if (!pr.waitForFinished(-1))
{
writeLog_("Update for file '" + infile + "' failed because the tool '" + new_tool + "' returned with an error! Check if the tool works properly.");
update_success = false;
break;
}
// update defaults with old values
Param new_param;
paramFile.load(tmp_ini_file, new_param);
new_param = new_param.copy(new_tool, true);
Param old_param = p.copy(sections[s], true);
new_param.update(old_param);
// push back changes
p.remove(sections[s] + ":");
p.insert(new_tool, new_param);
}
if (!update_success)
{
failed_.push_back(infile);
return;
}
// STORE
if (outfile.empty()) // create a backup
{
QFileInfo fi(infile.toQString());
String backup_filename = String(fi.path()) + "/" + fi.completeBaseName() + "_v" + version_old + ".ini";
QFile::rename(infile.toQString(), backup_filename.toQString());
std::cout << "Backup of input file created: " << backup_filename << std::endl;
//.........这里部分代码省略.........
示例10: updateTOPPAS
void updateTOPPAS(const String& infile, const String& outfile)
{
Int this_instance = getIntOption_("instance");
INIUpdater updater;
String tmp_ini_file = File::getTempDirectory() + "/" + File::getUniqueName() + "_INIUpdater.ini";
tmp_files_.push_back(tmp_ini_file);
String path = File::getExecutablePath();
ParamXMLFile paramFile;
Param p;
paramFile.load(infile, p);
// get version of TOPPAS file
String version = "Unknown";
if (!p.exists("info:version"))
{
writeLog_("No OpenMS version information found in file " + infile + "! Assuming OpenMS 1.8 and below.");
version = "1.8.0";
}
else
{
version = p.getValue("info:version");
// TODO: return on newer version?!
}
Int vertices = p.getValue("info:num_vertices");
// update sections
writeDebug_("#Vertices: " + String(vertices), 1);
bool update_success = true;
for (Int v = 0; v < vertices; ++v)
{
String sec_inst = "vertices:" + String(v) + ":";
// check for default instance
if (!p.exists(sec_inst + "toppas_type"))
{
writeLog_("Update for file " + infile + " failed because the vertex #" + String(v) + " does not have a 'toppas_type' node. Check INI file for corruption!");
update_success = false;
break;
}
if (p.getValue(sec_inst + "toppas_type") != "tool") // not a tool (but input/output/merge node)
{
continue;
}
if (!p.exists(sec_inst + "tool_name"))
{
writeLog_("Update for file " + infile + " failed because the vertex #" + String(v) + " does not have a 'tool_name' node. Check INI file for corruption!");
update_success = false;
break;
}
String old_name = p.getValue(sec_inst + "tool_name");
String new_tool;
String ttype;
// find mapping to new tool (might be the same name)
if (p.exists(sec_inst + "tool_type")) ttype = p.getValue(sec_inst + "tool_type");
if (!updater.getNewToolName(old_name, ttype, new_tool))
{
String type_text = ((ttype == "") ? "" : " with type '" + ttype + "' ");
writeLog_("Update for file " + infile + " failed because the tool '" + old_name + "'" + type_text + "is unknown. TOPPAS file seems to be corrupted!");
update_success = false;
break;
}
// set new tool name
p.setValue(sec_inst + "tool_name", new_tool);
// delete TOPPAS type
if (new_tool != "GenericWrapper")
{
p.setValue(sec_inst + "tool_type", "");
}
// get defaults of new tool by calling it
QProcess pr;
QStringList arguments;
arguments << "-write_ini";
arguments << tmp_ini_file.toQString();
arguments << "-instance";
arguments << String(this_instance).toQString();
pr.start((path + "/" + new_tool).toQString(), arguments);
if (!pr.waitForFinished(-1))
{
writeLog_("Update for file " + infile + " failed because the tool '" + new_tool + "' returned with an error! Check if the tool works properly.");
update_success = false;
break;
}
// update defaults with old values
Param new_param;
paramFile.load(tmp_ini_file, new_param);
new_param = new_param.copy(new_tool + ":1", true);
Param old_param = p.copy(sec_inst + "parameters", true);
new_param.update(old_param);
// push back changes
p.remove(sec_inst + "parameters:");
p.insert(sec_inst + "parameters", new_param);
}
//.........这里部分代码省略.........