本文整理汇总了C++中PeakMap::getSpectra方法的典型用法代码示例。如果您正苦于以下问题:C++ PeakMap::getSpectra方法的具体用法?C++ PeakMap::getSpectra怎么用?C++ PeakMap::getSpectra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PeakMap
的用法示例。
在下文中一共展示了PeakMap::getSpectra方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main_
ExitCodes main_(int, const char**)
{
// instance specific location of settings in INI file (e.g. 'TOPP_Skeleton:1:')
String ini_location;
// path to the log file
String logfile(getStringOption_("log"));
String xtandem_executable(getStringOption_("xtandem_executable"));
String inputfile_name;
String outputfile_name;
//-------------------------------------------------------------
// parsing parameters
//-------------------------------------------------------------
inputfile_name = getStringOption_("in");
writeDebug_(String("Input file: ") + inputfile_name, 1);
if (inputfile_name == "")
{
writeLog_("No input file specified. Aborting!");
printUsage_();
return ILLEGAL_PARAMETERS;
}
outputfile_name = getStringOption_("out");
writeDebug_(String("Output file: ") + outputfile_name, 1);
if (outputfile_name == "")
{
writeLog_("No output file specified. Aborting!");
printUsage_();
return ILLEGAL_PARAMETERS;
}
// write input xml file
String temp_directory = QDir::toNativeSeparators((File::getTempDirectory() + "/" + File::getUniqueName() + "/").toQString()); // body for the tmp files
{
QDir d;
d.mkpath(temp_directory.toQString());
}
String input_filename(temp_directory + "_tandem_input_file.xml");
String tandem_input_filename(temp_directory + "_tandem_input_file.mzData");
String tandem_output_filename(temp_directory + "_tandem_output_file.xml");
String tandem_taxonomy_filename(temp_directory + "_tandem_taxonomy_file.xml");
//-------------------------------------------------------------
// Validate user parameters
//-------------------------------------------------------------
if (getIntOption_("min_precursor_charge") > getIntOption_("max_precursor_charge"))
{
LOG_ERROR << "Given charge range is invalid: max_precursor_charge needs to be >= min_precursor_charge." << std::endl;
return ILLEGAL_PARAMETERS;
}
//-------------------------------------------------------------
// reading input
//-------------------------------------------------------------
String db_name(getStringOption_("database"));
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;
}
PeakMap exp;
MzMLFile mzml_file;
mzml_file.getOptions().addMSLevel(2); // only load msLevel 2
mzml_file.setLogType(log_type_);
mzml_file.load(inputfile_name, exp);
if (exp.getSpectra().empty())
{
throw OpenMS::Exception::FileEmpty(__FILE__, __LINE__, __FUNCTION__, "Error: No MS2 spectra in input file.");
}
// determine type of spectral data (profile or centroided)
SpectrumSettings::SpectrumType spectrum_type = exp[0].getType();
if (spectrum_type == SpectrumSettings::RAWDATA)
{
if (!getFlag_("force"))
{
throw OpenMS::Exception::IllegalArgument(__FILE__, __LINE__, __FUNCTION__, "Error: Profile data provided but centroided MS2 spectra expected. To enforce processing of the data set the -force flag.");
}
}
// we need to replace the native id with a simple numbering schema, to be able to
// map the IDs back to the spectra (RT, and MZ information)
Size native_id(0);
for (PeakMap::Iterator it = exp.begin(); it != exp.end(); ++it)
//.........这里部分代码省略.........
示例2: main_
ExitCodes main_(int, const char**)
{
//input file names
String in = getStringOption_("in");
String out = getStringOption_("out");
String out_mzq = getStringOption_("out_mzq");
//prevent loading of fragment spectra
PeakFileOptions options;
options.setMSLevels(vector<Int>(1, 1));
//reading input data
MzMLFile f;
f.getOptions() = options;
f.setLogType(log_type_);
PeakMap exp;
f.load(in, exp);
exp.updateRanges();
if (exp.getSpectra().empty())
{
throw OpenMS::Exception::FileEmpty(__FILE__, __LINE__, __FUNCTION__, "Error: No MS1 spectra in input file.");
}
// determine type of spectral data (profile or centroided)
SpectrumSettings::SpectrumType spectrum_type = exp[0].getType();
if (spectrum_type == SpectrumSettings::RAWDATA)
{
if (!getFlag_("force"))
{
throw OpenMS::Exception::IllegalArgument(__FILE__, __LINE__, __FUNCTION__, "Error: Profile data provided but centroided spectra expected. To enforce processing of the data set the -force flag.");
}
}
//load seeds
FeatureMap seeds;
if (getStringOption_("seeds") != "")
{
FeatureXMLFile().load(getStringOption_("seeds"), seeds);
}
//setup of FeatureFinder
FeatureFinder ff;
ff.setLogType(log_type_);
// A map for the resulting features
FeatureMap features;
// get parameters specific for the feature finder
Param feafi_param = getParam_().copy("algorithm:", true);
writeDebug_("Parameters passed to FeatureFinder", feafi_param, 3);
// Apply the feature finder
ff.run(FeatureFinderAlgorithmPicked::getProductName(), exp, features, feafi_param, seeds);
features.applyMemberFunction(&UniqueIdInterface::setUniqueId);
// DEBUG
if (debug_level_ > 10)
{
FeatureMap::Iterator it;
for (it = features.begin(); it != features.end(); ++it)
{
if (!it->isMetaEmpty())
{
vector<String> keys;
it->getKeys(keys);
LOG_INFO << "Feature " << it->getUniqueId() << endl;
for (Size i = 0; i < keys.size(); i++)
{
LOG_INFO << " " << keys[i] << " = " << it->getMetaValue(keys[i]) << endl;
}
}
}
}
//-------------------------------------------------------------
// writing files
//-------------------------------------------------------------
//annotate output with data processing info
addDataProcessing_(features, getProcessingInfo_(DataProcessing::QUANTITATION));
// write features to user specified output file
FeatureXMLFile map_file;
// Remove detailed convex hull information and subordinate features
// (unless requested otherwise) to reduce file size of feature files
// unless debugging is turned on.
if (debug_level_ < 5)
{
FeatureMap::Iterator it;
for (it = features.begin(); it != features.end(); ++it)
{
it->getConvexHull().expandToBoundingBox();
for (Size i = 0; i < it->getConvexHulls().size(); ++i)
{
it->getConvexHulls()[i].expandToBoundingBox();
}
//.........这里部分代码省略.........
示例3: main_
ExitCodes main_(int, const char**) override
{
//-------------------------------------------------------------
// parsing parameters
//-------------------------------------------------------------
// do this early, to see if comet is installed
String comet_executable = getStringOption_("comet_executable");
String tmp_param = File::getTemporaryFile();
writeLog_("Comet is writing the default parameter file...");
runExternalProcess_(comet_executable.toQString(), QStringList() << "-p" << tmp_param.c_str());
String inputfile_name = getStringOption_("in");
String out = getStringOption_("out");
//-------------------------------------------------------------
// reading input
//-------------------------------------------------------------
String db_name(getStringOption_("database"));
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;
}
//tmp_dir
String tmp_dir = makeAutoRemoveTempDirectory_();
String tmp_pepxml = tmp_dir + "result.pep.xml";
String tmp_pin = tmp_dir + "result.pin";
String default_params = getStringOption_("default_params_file");
String tmp_file;
//default params given or to be written
if (default_params.empty())
{
tmp_file = tmp_dir + "param.txt";
ofstream os(tmp_file.c_str());
createParamFile_(os);
os.close();
}
else
{
tmp_file = default_params;
}
PeakMap exp;
MzMLFile mzml_file;
mzml_file.getOptions().setMSLevels({2}); // only load msLevel 2
mzml_file.setLogType(log_type_);
mzml_file.load(inputfile_name, exp);
if (exp.getSpectra().empty())
{
throw OpenMS::Exception::FileEmpty(__FILE__, __LINE__, __FUNCTION__, "Error: No MS2 spectra in input file.");
}
// determine type of spectral data (profile or centroided)
SpectrumSettings::SpectrumType spectrum_type = exp[0].getType();
if (spectrum_type == SpectrumSettings::PROFILE)
{
if (!getFlag_("force"))
{
throw OpenMS::Exception::IllegalArgument(__FILE__, __LINE__, __FUNCTION__, "Error: Profile data provided but centroided MS2 spectra expected. To enforce processing of the data set the -force flag.");
}
}
//-------------------------------------------------------------
// calculations
//-------------------------------------------------------------
String paramP = "-P" + tmp_file;
String paramN = "-N" + File::removeExtension(File::removeExtension(tmp_pepxml));
QStringList arguments;
arguments << paramP.toQString() << paramN.toQString() << inputfile_name.toQString();
//-------------------------------------------------------------
// run comet
//-------------------------------------------------------------
// Comet execution with the executable and the arguments StringList
TOPPBase::ExitCodes exit_code = runExternalProcess_(comet_executable.toQString(), arguments);
if (exit_code != EXECUTION_OK)
{
return exit_code;
}
//-------------------------------------------------------------
// writing IdXML output
//-------------------------------------------------------------
// read the pep.xml put of Comet and write it to idXML
//.........这里部分代码省略.........
示例4: main_
//.........这里部分代码省略.........
parameters << "-cfg" << cfg_file;
// path to input file must be the last parameter
parameters << inputfile_name;
//-------------------------------------------------------------
// calculations
//-------------------------------------------------------------
QStringList qparam;
writeDebug_("MyriMatch arguments:", 1);
writeDebug_(String("\"") + ListUtils::concatenate(parameters, "\" \"") + "\"", 1);
for (Size i = 0; i < parameters.size(); ++i)
{
qparam << parameters[i].toQString();
}
QProcess process;
// Bad style, because it breaks relative paths?
process.setWorkingDirectory(tmp_dir.toQString());
process.start(myrimatch_executable.toQString(), qparam, QIODevice::ReadOnly);
bool success = process.waitForFinished(-1);
String myri_msg(QString(process.readAllStandardOutput()));
String myri_err(QString(process.readAllStandardError()));
writeDebug_(myri_msg, 1);
writeDebug_(myri_err, 0);
if (!success || process.exitStatus() != 0 || process.exitCode() != 0)
{
writeLog_("Error: MyriMatch problem! (Details can be seen in the logfile: \"" + logfile + "\")");
writeLog_("Note: This message can also be triggered if you run out of space in your tmp directory");
return EXTERNAL_PROGRAM_ERROR;
}
//-------------------------------------------------------------
// reading MyriMatch output
//-------------------------------------------------------------
writeDebug_("Reading output of MyriMatch", 5);
String exp_name = File::basename(inputfile_name);
String pep_file = tmp_dir + File::removeExtension(exp_name) + ".pepXML";
vector<ProteinIdentification> protein_identifications;
vector<PeptideIdentification> peptide_identifications;
PeakMap exp;
if (File::exists(pep_file))
{
MzMLFile fh;
fh.load(inputfile_name, exp);
SpectrumMetaDataLookup lookup;
lookup.readSpectra(exp.getSpectra());
PepXMLFile().load(pep_file, protein_identifications,
peptide_identifications, exp_name, lookup);
}
else
{
writeLog_("Error: MyriMatch problem! No pepXML output file (expected as '" + pep_file + "') was generated by MyriMatch.");
writeLog_("Note: This message can be triggered if no MS2 spectra were found or no identifications were made.");
writeLog_(" Myrimatch expects MS2 spectra in mzML files to contain the MSn tag. MSSpectrum with MS level 2 is not sufficient. You can use FileConverter to create such an mzML file by converting from mzML --> mzXML --> mzML.");
return EXTERNAL_PROGRAM_ERROR;
}
if (debug_level_ == 0)
{
QFile(pep_file.toQString()).remove();
QFile(cfg_file.toQString()).remove();
}
else
{
writeDebug_(String("Not removing '") + pep_file + "' for debugging purposes. Please delete manually!", 1);
writeDebug_(String("Not removing '") + cfg_file + "' for debugging purposes. Please delete manually!", 1);
}
//-------------------------------------------------------------
// writing results
//-------------------------------------------------------------
ProteinIdentification::SearchParameters search_parameters;
search_parameters.db = getStringOption_("database");
ProteinIdentification::PeakMassType mass_type = getFlag_("precursor_mass_tolerance_avg") == true ? ProteinIdentification::AVERAGE : ProteinIdentification::MONOISOTOPIC;
search_parameters.mass_type = mass_type;
search_parameters.fixed_modifications = getStringList_("fixed_modifications");
search_parameters.variable_modifications = getStringList_("variable_modifications");
search_parameters.missed_cleavages = getIntOption_("MaxMissedCleavages");
search_parameters.fragment_mass_tolerance = getDoubleOption_("fragment_mass_tolerance");
search_parameters.precursor_mass_tolerance = getDoubleOption_("precursor_mass_tolerance");
search_parameters.precursor_mass_tolerance_ppm = getStringOption_("precursor_mass_tolerance_unit") == "ppm" ? true : false;
search_parameters.fragment_mass_tolerance_ppm = getStringOption_("fragment_mass_tolerance_unit") == "ppm" ? true : false;
protein_identifications[0].setSearchParameters(search_parameters);
protein_identifications[0].setSearchEngineVersion(myrimatch_version);
protein_identifications[0].setSearchEngine("MyriMatch");
if (!protein_identifications.empty())
{
StringList ms_runs;
exp.getPrimaryMSRunPath(ms_runs);
protein_identifications[0].setPrimaryMSRunPath(ms_runs);
}
IdXMLFile().store(outputfile_name, protein_identifications, peptide_identifications);
return EXECUTION_OK;
}
示例5: main_
ExitCodes main_(int argc, const char** argv)
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
//input/output files
String in(getStringOption_("in")), out(getStringOption_("out"));
FileHandler fh;
FileTypes::Type in_type = fh.getType(in);
//-------------------------------------------------------------
// loading input
//-------------------------------------------------------------
PeakMap exp;
// keep only MS2 spectra
fh.getOptions().addMSLevel(2);
fh.loadExperiment(in, exp, in_type, log_type_);
writeDebug_(String("Spectra loaded: ") + exp.size(), 2);
if (exp.getSpectra().empty())
{
throw OpenMS::Exception::FileEmpty(__FILE__, __LINE__, __FUNCTION__, "Error: No MS2 spectra in input file.");
}
// determine type of spectral data (profile or centroided)
SpectrumSettings::SpectrumType spectrum_type = exp[0].getType();
if (spectrum_type == SpectrumSettings::RAWDATA)
{
if (!getFlag_("force"))
{
throw OpenMS::Exception::IllegalArgument(__FILE__, __LINE__, __FUNCTION__, "Error: Profile data provided but centroided MS2 spectra expected. To enforce processing of the data set the -force flag.");
}
}
//-------------------------------------------------------------
// calculations
//-------------------------------------------------------------
Param mascot_param = getParam_().copy("Mascot_parameters:", true);
MascotGenericFile mgf_file;
Param p;
// TODO: switch this to mzML (much smaller)
p.setValue("internal:format", "Mascot generic", "Sets the format type of the peak list, this should not be changed unless you write the header only.", ListUtils::create<String>("advanced"));
p.setValue("internal:HTTP_format", "true", "Write header with MIME boundaries instead of simple key-value pairs. For HTTP submission only.", ListUtils::create<String>("advanced"));
p.setValue("internal:content", "all", "Use parameter header + the peak lists with BEGIN IONS... or only one of them.", ListUtils::create<String>("advanced"));
mgf_file.setParameters(mascot_param);
// get the spectra into string stream
writeDebug_("Writing MGF file to stream", 1);
stringstream ss;
mgf_file.store(ss, in, exp, true); // write in compact format
// Usage of a QCoreApplication is overkill here (and ugly too), but we just use the
// QEventLoop to process the signals and slots and grab the results afterwards from
// the MascotRemotQuery instance
char** argv2 = const_cast<char**>(argv);
QCoreApplication event_loop(argc, argv2);
MascotRemoteQuery* mascot_query = new MascotRemoteQuery(&event_loop);
Param mascot_query_param = getParam_().copy("Mascot_server:", true);
writeDebug_("Setting parameters for Mascot query", 1);
mascot_query->setParameters(mascot_query_param);
writeDebug_("Setting spectra for Mascot query", 1);
mascot_query->setQuerySpectra(ss.str());
// remove unnecessary spectra
ss.clear();
QObject::connect(mascot_query, SIGNAL(done()), &event_loop, SLOT(quit()));
QTimer::singleShot(1000, mascot_query, SLOT(run()));
writeDebug_("Fire off Mascot query", 1);
event_loop.exec();
writeDebug_("Mascot query finished", 1);
if (mascot_query->hasError())
{
writeLog_("An error occurred during the query: " + mascot_query->getErrorMessage());
delete mascot_query;
return EXTERNAL_PROGRAM_ERROR;
}
// write Mascot response to file
String mascot_tmp_file_name(File::getTempDirectory() + "/" + File::getUniqueName() + "_Mascot_response");
QFile mascot_tmp_file(mascot_tmp_file_name.c_str());
mascot_tmp_file.open(QIODevice::WriteOnly);
mascot_tmp_file.write(mascot_query->getMascotXMLResponse());
mascot_tmp_file.close();
// clean up
delete mascot_query;
vector<PeptideIdentification> pep_ids;
ProteinIdentification prot_id;
// set up mapping between scan numbers and retention times:
MascotXMLFile::RTMapping rt_mapping;
MascotXMLFile::generateRTMapping(exp.begin(), exp.end(), rt_mapping);
//.........这里部分代码省略.........