本文整理汇总了C++中Param::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Param::getValue方法的具体用法?C++ Param::getValue怎么用?C++ Param::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Param
的用法示例。
在下文中一共展示了Param::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registerOptionsAndFlags_
void registerOptionsAndFlags_()
{
registerInputFile_("in", "<file>", "", "featureXML or consensusXML file");
setValidFormats_("in", ListUtils::create<String>("featureXML,consensusXML"));
registerOutputFile_("out", "<file>", "", "mzTab file");
setValidFormats_("out", ListUtils::create<String>("csv"));
registerOutputFile_("out_annotation", "<file>", "", "A copy of the input file, annotated with matching hits from the database.", false);
setValidFormats_("out_annotation", ListUtils::create<String>("featureXML,consensusXML"));
// move some params from algorithm section to top level (to support input file functionality)
Param p = AccurateMassSearchEngine().getDefaults();
registerTOPPSubsection_("db", "Database files which contain the identifications");
registerInputFile_("db:mapping", "<file>", p.getValue("db:mapping"), p.getDescription("db:mapping"), true, false, ListUtils::create<String>("skipexists"));
setValidFormats_("db:mapping", ListUtils::create<String>("tsv"));
registerInputFile_("db:struct", "<file>", p.getValue("db:struct"), p.getDescription("db:struct"), true, false, ListUtils::create<String>("skipexists"));
setValidFormats_("db:struct", ListUtils::create<String>("tsv"));
registerInputFile_("positive_adducts_file", "<file>", p.getValue("positive_adducts_file"), p.getDescription("positive_adducts_file"), true, false, ListUtils::create<String>("skipexists"));
setValidFormats_("positive_adducts_file", ListUtils::create<String>("tsv"));
registerInputFile_("negative_adducts_file", "<file>", p.getValue("negative_adducts_file"), p.getDescription("negative_adducts_file"), true, false, ListUtils::create<String>("skipexists"));
setValidFormats_("negative_adducts_file", ListUtils::create<String>("tsv"));
// addEmptyLine_();
// addText_("Parameters for the accurate mass search can be given in the 'algorithm' part of INI file.");
registerSubsection_("algorithm", "Algorithm parameters section");
}
示例2: registerOptionsAndFlags_
void registerOptionsAndFlags_()
{
registerInputFile_("id", "<file>", "", "Protein/peptide identifications file");
setValidFormats_("id", ListUtils::create<String>("mzid,idXML"));
registerInputFile_("in", "<file>", "", "Feature map/consensus map file");
setValidFormats_("in", ListUtils::create<String>("featureXML,consensusXML,mzq"));
registerOutputFile_("out", "<file>", "", "Output file (the format depends on the input file format).");
setValidFormats_("out", ListUtils::create<String>("featureXML,consensusXML,mzq"));
addEmptyLine_();
IDMapper mapper;
Param p = mapper.getParameters();
registerDoubleOption_("rt_tolerance", "<value>", p.getValue("rt_tolerance"), "RT tolerance (in seconds) for the matching of peptide identifications and (consensus) features.\nTolerance is understood as 'plus or minus x', so the matching range increases by twice the given value.", false);
setMinFloat_("rt_tolerance", 0.0);
registerDoubleOption_("mz_tolerance", "<value>", p.getValue("mz_tolerance"), "m/z tolerance (in ppm or Da) for the matching of peptide identifications and (consensus) features.\nTolerance is understood as 'plus or minus x', so the matching range increases by twice the given value.", false);
setMinFloat_("mz_tolerance", 0.0);
registerStringOption_("mz_measure", "<choice>", p.getEntry("mz_measure").valid_strings[0], "Unit of 'mz_tolerance'.", false);
setValidStrings_("mz_measure", p.getEntry("mz_measure").valid_strings);
registerStringOption_("mz_reference", "<choice>", p.getEntry("mz_reference").valid_strings[0], "Source of m/z values for peptide identifications. If 'precursor', the precursor-m/z from the idXML is used. If 'peptide',\nmasses are computed from the sequences of peptide hits; in this case, an identification matches if any of its hits matches.\n('peptide' should be used together with 'feature:use_centroid_mz' to avoid false-positive matches.)", false);
setValidStrings_("mz_reference", p.getEntry("mz_reference").valid_strings);
registerFlag_("ignore_charge", "For feature/consensus maps: Assign an ID independently of whether its charge state matches that of the (consensus) feature.");
addEmptyLine_();
registerTOPPSubsection_("feature", "Additional options for featureXML input");
registerFlag_("feature:use_centroid_rt", "Use the RT coordinates of the feature centroids for matching, instead of the RT ranges of the features/mass traces.");
registerFlag_("feature:use_centroid_mz", "Use the m/z coordinates of the feature centroids for matching, instead of the m/z ranges of the features/mass traces.\n(If you choose 'peptide' as 'mz_reference', you should usually set this flag to avoid false-positive matches.)");
addEmptyLine_();
registerTOPPSubsection_("consensus", "Additional options for consensusXML input");
registerFlag_("consensus:use_subelements", "Match using RT and m/z of sub-features instead of consensus RT and m/z. A consensus feature matches if any of its sub-features matches.");
registerFlag_("consensus:annotate_ids_with_subelements", "Store the map index of the sub-feature in the peptide ID.", true);
}
示例3: IllegalArgument
TransformationModelLinear::TransformationModelLinear(
const TransformationModel::DataPoints & data, const Param & params)
{
params_ = params;
data_given_ = !data.empty();
if (!data_given_ && params.exists("slope") && (params.exists("intercept")))
{
// don't estimate parameters, use given values
slope_ = params.getValue("slope");
intercept_ = params.getValue("intercept");
}
else // estimate parameters from data
{
Param defaults;
getDefaultParameters(defaults);
params_.setDefaults(defaults);
symmetric_ = params_.getValue("symmetric_regression") == "true";
size_t size = data.size();
if (size == 0) // no data
{
throw Exception::IllegalArgument(__FILE__, __LINE__, __PRETTY_FUNCTION__,
"no data points for 'linear' model");
}
else if (size == 1) // degenerate case, but we can still do something
{
slope_ = 1.0;
intercept_ = data[0].second - data[0].first;
}
else // compute least-squares fit
{
vector<double> x(size), y(size);
for (size_t i = 0; i < size; ++i)
{
if (symmetric_)
{
x[i] = data[i].second + data[i].first;
y[i] = data[i].second - data[i].first;
}
else
{
x[i] = data[i].first;
y[i] = data[i].second;
}
}
double cov00, cov01, cov11, sumsq; // covariance values, sum of squares
double * x_start = &(x[0]), * y_start = &(y[0]);
gsl_fit_linear(x_start, 1, y_start, 1, size, &intercept_, &slope_,
&cov00, &cov01, &cov11, &sumsq);
if (symmetric_) // undo coordinate transformation:
{
slope_ = (1.0 + slope_) / (1.0 - slope_);
intercept_ = intercept_ * 1.41421356237309504880; // 1.41... = sqrt(2)
}
}
}
}
示例4: getTempDirectory
String File::getTempDirectory()
{
Param p = getSystemParameters();
if (p.exists("temp_dir") && String(p.getValue("temp_dir")).trim() != "")
{
return p.getValue("temp_dir");
}
return String(QDir::tempPath());
}
示例5: IllegalArgument
TransformationModelLinear::TransformationModelLinear(const TransformationModel::DataPoints& data, const Param& params) :
TransformationModel(data, params) // initializes model
{
data_given_ = !data.empty();
if (!data_given_ && params.exists("slope") && params.exists("intercept"))
{
// don't estimate parameters, use given values
slope_ = params.getValue("slope");
intercept_ = params.getValue("intercept");
}
else // estimate parameters from data
{
Param defaults;
getDefaultParameters(defaults);
params_.setDefaults(defaults);
symmetric_ = params_.getValue("symmetric_regression") == "true";
// weight the data (if weighting is specified)
TransformationModel::DataPoints data_weighted = data;
if ((params.exists("x_weight") && params.getValue("x_weight") != "") || (params.exists("y_weight") && params.getValue("y_weight") != ""))
{
weightData(data_weighted);
}
size_t size = data_weighted.size();
std::vector<Wm5::Vector2d> points;
if (size == 0) // no data
{
throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"no data points for 'linear' model");
}
else if (size == 1) // degenerate case, but we can still do something
{
slope_ = 1.0;
intercept_ = data_weighted[0].second - data_weighted[0].first;
}
else // compute least-squares fit
{
for (size_t i = 0; i < size; ++i)
{
points.push_back(Wm5::Vector2d(data_weighted[i].first, data_weighted[i].second));
}
if (!Wm5::HeightLineFit2<double>(static_cast<int>(size), &points.front(), slope_, intercept_))
{
throw Exception::UnableToFit(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "TransformationModelLinear", "Unable to fit linear transformation to data points.");
}
}
// update params
params_.setValue("slope", slope_);
params_.setValue("intercept", intercept_);
}
}
示例6: getUserDirectory
/// The current OpenMS user data path (for result files)
String File::getUserDirectory()
{
Param p = getSystemParameters();
String dir;
if (p.exists("home_dir") && String(p.getValue("home_dir")).trim() != "")
{
dir = p.getValue("home_dir");
}
else
{
dir = String(QDir::homePath());
}
dir.ensureLastChar('/');
return dir;
}
示例7: main
int main(int argc, const char** argv)
{
if (argc < 2) return 1;
// the path to the data should be given on the command line
String tutorial_data_path(argv[1]);
PeakMap exp_raw;
PeakMap exp_picked;
MzMLFile mzml_file;
mzml_file.load(tutorial_data_path + "/data/Tutorial_PeakPickerCWT.mzML", exp_raw);
PeakPickerCWT pp;
Param param;
param.setValue("peak_width", 0.1);
pp.setParameters(param);
pp.pickExperiment(exp_raw, exp_picked);
exp_picked.updateRanges();
cout << "\nMinimal fwhm of a mass spectrometric peak: " << (DoubleReal)param.getValue("peak_width")
<< "\n\nNumber of picked peaks " << exp_picked.getSize() << std::endl;
return 0;
} //end of main
示例8: process
virtual void process(ci::audio::Buffer * buffer) override {
int numFrames = buffer->getNumFrames();
int numChannels = buffer->getNumChannels();
float phaseInc = (freq->getValue() / getSampleRate()) * (float)M_PI * 2.0f;
auto data = buffer->getData();
for(int i = 0; i < numFrames; i++) {
phase = fmodf(phase + phaseInc, 2.0f * M_PI);
float pan = abs(sin(phase)) * mix->getValue();
for(int j = 0; j < numChannels; j++) {
int index = j * numFrames + i;
float initial = data[index];
data[index] *= pan;
data[index] += initial * (1.0f - mix->getValue());
}
}
}
示例9: preCheck
void ITRAQLabeler::preCheck(Param& param) const
{
// check for valid MS/MS method
if (!ListUtils::contains(ListUtils::create<String>("disabled,precursor"), param.getValue("RawTandemSignal:status")))
{
throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "iTRAQ Labeling does not work with the chosen MS/MS type");
}
}
示例10: getSystemParameters
Param File::getSystemParameters()
{
String filename = String(QDir::homePath()) + "/.OpenMS/OpenMS.ini";
Param p;
if (!File::readable(filename)) // create file
{
p = getSystemParameterDefaults_();
String dirname = String(QDir::homePath()) + "/.OpenMS";
QDir dir(dirname.toQString());
if (!dir.exists())
{
if (!File::writable(dirname))
{
LOG_WARN << "Warning: Cannot create folder '.OpenMS' in user home directory. Please check your environment!" << std::endl;
LOG_WARN << " Home directory determined is: " << QDir::homePath().toStdString() << "." << std::endl;
return p;
}
dir.mkpath(".");
}
if (!File::writable(filename))
{
LOG_WARN << "Warning: Cannot create '.OpenMS/OpenMS.ini' in user home directory. Please check your environment!" << std::endl;
LOG_WARN << " Home directory determined is: " << QDir::homePath().toStdString() << "." << std::endl;
return p;
}
ParamXMLFile paramFile;
paramFile.store(filename, p);
}
else
{
ParamXMLFile paramFile;
paramFile.load(filename, p);
// check version
if (!p.exists("version") || (p.getValue("version") != VersionInfo::getVersion()))
{
if (!p.exists("version"))
{
LOG_WARN << "Broken file '" << filename << "' discovered. The 'version' tag is missing." << std::endl;
}
else // old version
{
LOG_WARN << "File '" << filename << "' is deprecated." << std::endl;
}
LOG_WARN << "Updating missing/wrong entries in '" << filename << "' with defaults!" << std::endl;
Param p_new = getSystemParameterDefaults_();
p.setValue("version", VersionInfo::getVersion()); // update old version, such that p_new:version does not get overwritten during update()
p_new.update(p);
paramFile.store(filename, p_new);
}
}
return p;
}
示例11: 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);
}
//.........这里部分代码省略.........
示例12: float
p2.setValue("test:b:b1", 47.1);
p2.setSectionDescription("test:b","bdesc\"<>\nnewline");
p2.setValue("test2:a:a1", 47.1);
p2.setValue("test2:b:b1", 47.1,"",ListUtils::create<String>("advanced"));
p2.setSectionDescription("test2:a","adesc");
//exception
Param p300;
TEST_EXCEPTION(Exception::UnableToCreateFile, paramFile.store("/does/not/exist/FileDoesNotExist.xml",p300))
String filename;
NEW_TMP_FILE(filename);
paramFile.store(filename,p2);
Param p3;
paramFile.load(filename,p3);
TEST_REAL_SIMILAR(float(p2.getValue("test:float")), float(p3.getValue("test:float")))
TEST_EQUAL(p2.getValue("test:string"), p3.getValue("test:string"))
TEST_EQUAL(p2.getValue("test:int"), p3.getValue("test:int"))
TEST_REAL_SIMILAR(float(p2.getValue("test2:float")), float(p3.getValue("test2:float")))
TEST_EQUAL(p2.getValue("test2:string"), p3.getValue("test2:string"))
TEST_EQUAL(p2.getValue("test2:int"), p3.getValue("test2:int"))
TEST_STRING_EQUAL(p2.getDescription("test:float"), p3.getDescription("test:float"))
TEST_STRING_EQUAL(p2.getDescription("test:string"), p3.getDescription("test:string"))
TEST_STRING_EQUAL(p2.getDescription("test:int"), p3.getDescription("test:int"))
TEST_EQUAL(p3.getSectionDescription("test"),"sectiondesc")
TEST_EQUAL(p3.getDescription("test:a:a1"),"a1desc\"<>\nnewline")
TEST_EQUAL(p3.getSectionDescription("test:b"),"bdesc\"<>\nnewline")
TEST_EQUAL(p3.getSectionDescription("test2:a"),"adesc")
TEST_EQUAL(p3.hasTag("test2:b:b1","advanced"),true)
TEST_EQUAL(p3.hasTag("test2:a:a1","advanced"),false)
示例13: setenv
String dirname = File::getTempDirectory() + "/" + File::getUniqueName() + "/";
TEST_EQUAL(d.mkpath(dirname.toQString()), TRUE);
#ifdef OPENMS_WINDOWSPLATFORM
_putenv_s("OPENMS_HOME_PATH", dirname.c_str());
#else
setenv("OPENMS_HOME_PATH", dirname.c_str(), 0);
#endif
TEST_EQUAL(File::getUserDirectory(), dirname)
// Note: this does not guarantee any more that the user directory or an
// OpenMS.ini file exists at the new location.
END_SECTION
START_SECTION(static Param getSystemParameters())
Param p = File::getSystemParameters();
TEST_EQUAL(p.size()>0, true)
TEST_EQUAL(p.getValue("version"), VersionInfo::getVersion())
END_SECTION
START_SECTION(static String findDatabase(const String &db_name))
TEST_EXCEPTION(Exception::FileNotFound, File::findDatabase("filedoesnotexists"))
String db = File::findDatabase("./CV/unimod.obo");
//TEST_EQUAL(db,"wtf")
TEST_EQUAL(db.hasSubstring("share/OpenMS"), true)
END_SECTION
START_SECTION(static String findExecutable(const OpenMS::String& toolName))
{
TEST_EXCEPTION(Exception::FileNotFound, File::findExecutable("executable_does_not_exist"))
TEST_EQUAL(File::path(File::findExecutable("File_test")) + "/", File::getExecutablePath())
示例14:
feat3.setPosition(pos3);
feat3.setIntensity(100.0f);
feat4.setPosition(pos4);
feat4.setIntensity(100.0f);
input[1].push_back(ConsensusFeature(feat3));
input[1].push_back(ConsensusFeature(feat4));
TransformationDescription transformation;
PoseClusteringShiftSuperimposer pcat;
Param params;
#if 0 // switch this on for debugging
params.setValue("dump_buckets","tmp_PoseClusteringShiftSuperimposer_buckets");
params.setValue("dump_pairs","tmp_PoseClusteringShiftSuperimposer_pairs");
pcat.setParameters(params);
#endif
pcat.run(input[0], input[1], transformation);
TEST_STRING_EQUAL(transformation.getModelType(), "linear")
params = transformation.getModelParameters();
TEST_EQUAL(params.size(), 2)
TEST_REAL_SIMILAR(params.getValue("slope"), 1.0)
TEST_REAL_SIMILAR(params.getValue("intercept"), -20.4)
END_SECTION
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST
示例15: main_
ExitCodes main_(int, const char**) override
{
//-------------------------------------------------------------
// parsing parameters
//-------------------------------------------------------------
String in = getStringOption_("in");
String out = getStringOption_("out");
PeptideIndexing indexer;
Param param = getParam_().copy("", true);
Param param_pi = indexer.getParameters();
param_pi.update(param, false, Log_debug); // suppress param. update message
indexer.setParameters(param_pi);
indexer.setLogType(this->log_type_);
String db_name = getStringOption_("fasta");
if (!File::readable(db_name))
{
String full_db_name;
try
{
full_db_name = File::findDatabase(db_name);
}
catch (...)
{
printUsage_();
return ILLEGAL_PARAMETERS;
}
db_name = full_db_name;
}
//-------------------------------------------------------------
// reading input
//-------------------------------------------------------------
// we stream the Fasta file
std::vector<ProteinIdentification> prot_ids;
std::vector<PeptideIdentification> pep_ids;
IdXMLFile idxmlfile;
idxmlfile.setLogType(this->log_type_);
idxmlfile.load(in, prot_ids, pep_ids);
//-------------------------------------------------------------
// calculations
//-------------------------------------------------------------
FASTAContainer<TFI_File> proteins(db_name);
PeptideIndexing::ExitCodes indexer_exit = indexer.run(proteins, prot_ids, pep_ids);
//-------------------------------------------------------------
// calculate protein coverage
//-------------------------------------------------------------
if (param.getValue("write_protein_sequence").toBool())
{
for (Size i = 0; i < prot_ids.size(); ++i)
{
prot_ids[i].computeCoverage(pep_ids);
}
}
//-------------------------------------------------------------
// writing output
//-------------------------------------------------------------
idxmlfile.store(out, prot_ids, pep_ids);
if (indexer_exit == PeptideIndexing::DATABASE_EMPTY)
{
return INPUT_FILE_EMPTY;
}
else if (indexer_exit == PeptideIndexing::UNEXPECTED_RESULT)
{
return UNEXPECTED_RESULT;
}
else if ((indexer_exit != PeptideIndexing::EXECUTION_OK) &&
(indexer_exit != PeptideIndexing::PEPTIDE_IDS_EMPTY))
{
return UNKNOWN_ERROR;
}
return EXECUTION_OK;
}