本文整理汇总了C++中PeakMap::sortSpectra方法的典型用法代码示例。如果您正苦于以下问题:C++ PeakMap::sortSpectra方法的具体用法?C++ PeakMap::sortSpectra怎么用?C++ PeakMap::sortSpectra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PeakMap
的用法示例。
在下文中一共展示了PeakMap::sortSpectra方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main_
ExitCodes main_(int, const char**)
{
//-------------------------------------------------------------
// parsing parameters
//-------------------------------------------------------------
String in(getStringOption_("in"));
String out(getStringOption_("out"));
String pair_in(getStringOption_("pair_in"));
String feature_out(getStringOption_("feature_out"));
double precursor_mass_tolerance(getDoubleOption_("precursor_mass_tolerance"));
double RT_tolerance(getDoubleOption_("RT_tolerance"));
double expansion_range(getDoubleOption_("expansion_range"));
Size max_isotope(getIntOption_("max_isotope"));
Int debug(getIntOption_("debug"));
//-------------------------------------------------------------
// reading input
//-------------------------------------------------------------
PeakMap exp;
MzMLFile().load(in, exp);
exp.sortSpectra();
exp.updateRanges();
// read pair file
ifstream is(pair_in.c_str());
String line;
vector<SILAC_pair> pairs;
while (getline(is, line))
{
line.trim();
if (line.empty() || line[0] == '#')
{
continue;
}
vector<String> split;
line.split(' ', split);
if (split.size() != 4)
{
cerr << "missformated line ('" << line << "') should be (space separated) 'm/z-light m/z-heavy charge rt'" << endl;
}
SILAC_pair p;
p.mz_light = split[0].toDouble();
p.mz_heavy = split[1].toDouble();
p.charge = split[2].toInt();
p.rt = split[3].toDouble();
pairs.push_back(p);
}
is.close();
//-------------------------------------------------------------
// calculations
//-------------------------------------------------------------
ConsensusMap results_map;
results_map.getFileDescriptions()[0].label = "light";
results_map.getFileDescriptions()[0].filename = in;
results_map.getFileDescriptions()[1].label = "heavy";
results_map.getFileDescriptions()[1].filename = in;
FeatureFinderAlgorithmIsotopeWavelet iso_ff;
Param ff_param(iso_ff.getParameters());
ff_param.setValue("max_charge", 3);
ff_param.setValue("intensity_threshold", -1.0);
iso_ff.setParameters(ff_param);
FeatureFinder ff;
ff.setLogType(ProgressLogger::NONE);
vector<SILACQuantitation> quantlets;
FeatureMap all_features;
for (PeakMap::ConstIterator it = exp.begin(); it != exp.end(); ++it)
{
if (it->size() == 0 || it->getMSLevel() != 1 || !it->getInstrumentSettings().getZoomScan())
{
continue;
}
PeakSpectrum new_spec = *it;
// get spacing from data
double min_spacing(numeric_limits<double>::max());
double last_mz(0);
for (PeakSpectrum::ConstIterator pit = new_spec.begin(); pit != new_spec.end(); ++pit)
{
if (pit->getMZ() - last_mz < min_spacing)
{
min_spacing = pit->getMZ() - last_mz;
}
last_mz = pit->getMZ();
}
writeDebug_("Min-spacing=" + String(min_spacing), 1);
// split the spectrum into two subspectra, by using different hypothesis of
// the SILAC pairs
Size idx = 0;
for (vector<SILAC_pair>::const_iterator pit = pairs.begin(); pit != pairs.end(); ++pit, ++idx)
{
// in RT window?
//.........这里部分代码省略.........
示例2: run
void FeatureFinder::run(const String& algorithm_name, PeakMap& input_map, FeatureMap& features, const Param& param, const FeatureMap& seeds)
{
// Nothing to do if there is no data
if ((algorithm_name != "mrm" && input_map.empty()) || (algorithm_name == "mrm" && input_map.getChromatograms().empty()))
{
features.clear(true);
return;
}
// check input
{
// We need updated ranges => check number of peaks
if (algorithm_name != "mrm" && input_map.getSize() == 0)
{
throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "FeatureFinder needs updated ranges on input map. Aborting.");
}
// We need MS1 data only => check levels
if (algorithm_name != "mrm" && (input_map.getMSLevels().size() != 1 || input_map.getMSLevels()[0] != 1))
{
throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "FeatureFinder can only operate on MS level 1 data. Please do not use MS/MS data. Aborting.");
}
//Check if the peaks are sorted according to m/z
if (!input_map.isSorted(true))
{
LOG_WARN << "Input map is not sorted by RT and m/z! This is done now, before applying the algorithm!" << std::endl;
input_map.sortSpectra(true);
input_map.sortChromatograms(true);
}
for (Size s = 0; s < input_map.size(); ++s)
{
if (input_map[s].empty())
continue;
if (input_map[s][0].getMZ() < 0)
{
throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "FeatureFinder can only operate on spectra that contain peaks with positive m/z values. Filter the data accordingly beforehand! Aborting.");
}
}
}
// initialize
if (algorithm_name != "mrm" && algorithm_name != "centroided")
{
// Resize peak flag vector
flags_.resize(input_map.size());
for (Size i = 0; i < input_map.size(); ++i)
{
flags_[i].assign(input_map[i].size(), UNUSED);
}
}
// do the work
if (algorithm_name != "none")
{
FeatureFinderAlgorithm* algorithm = Factory<FeatureFinderAlgorithm>::create(algorithm_name);
algorithm->setParameters(param);
algorithm->setData(input_map, features, *this);
algorithm->setSeeds(seeds);
algorithm->run();
delete(algorithm);
}
if (algorithm_name != "mrm") // mrm works on chromatograms; the next section is only for conventional data
{
//report RT apex spectrum index and native ID for each feature
for (Size i = 0; i < features.size(); ++i)
{
//index
Size spectrum_index = input_map.RTBegin(features[i].getRT()) - input_map.begin();
features[i].setMetaValue("spectrum_index", spectrum_index);
//native id
if (spectrum_index < input_map.size())
{
String native_id = input_map[spectrum_index].getNativeID();
features[i].setMetaValue("spectrum_native_id", native_id);
}
else
{
/// @todo that happens sometimes using IsotopeWaveletFeatureFinder (Rene, Marc, Andreas, Clemens)
std::cerr << "FeatureFinderAlgorithm_impl, line=" << __LINE__ << "; FixMe this cannot be, but happens" << std::endl;
}
}
}
}
示例3: main_
ExitCodes main_(int, const char**)
{
// parsing parameters
String in(getStringOption_("in"));
String feature_in(getStringOption_("feature_in"));
String out(getStringOption_("out"));
double precursor_mass_tolerance(getDoubleOption_("precursor_mass_tolerance"));
// reading input
FileHandler fh;
FileTypes::Type in_type = fh.getType(in);
PeakMap exp;
fh.loadExperiment(in, exp, in_type, log_type_, false, false);
exp.sortSpectra();
FeatureMap feature_map;
if (feature_in != "")
{
FeatureXMLFile().load(feature_in, feature_map);
}
// calculations
FeatureFinderAlgorithmIsotopeWavelet iso_ff;
Param ff_param(iso_ff.getParameters());
ff_param.setValue("max_charge", getIntOption_("max_charge"));
ff_param.setValue("intensity_threshold", getDoubleOption_("intensity_threshold"));
iso_ff.setParameters(ff_param);
FeatureFinder ff;
ff.setLogType(ProgressLogger::NONE);
PeakMap exp2 = exp;
exp2.clear(false);
for (PeakMap::ConstIterator it = exp.begin(); it != exp.end(); ++it)
{
if (it->size() != 0)
{
exp2.addSpectrum(*it);
}
}
exp = exp2;
exp.updateRanges();
// TODO check MS2 and MS1 counts
ProgressLogger progresslogger;
progresslogger.setLogType(log_type_);
progresslogger.startProgress(0, exp.size(), "Correcting precursor masses");
for (PeakMap::Iterator it = exp.begin(); it != exp.end(); ++it)
{
progresslogger.setProgress(exp.end() - it);
if (it->getMSLevel() != 2)
{
continue;
}
// find first MS1 scan of the MS/MS scan
PeakMap::Iterator ms1_it = it;
while (ms1_it != exp.begin() && ms1_it->getMSLevel() != 1)
{
--ms1_it;
}
if (ms1_it == exp.begin() && ms1_it->getMSLevel() != 1)
{
writeLog_("Did not find a MS1 scan to the MS/MS scan at RT=" + String(it->getRT()));
continue;
}
if (ms1_it->size() == 0)
{
writeDebug_("No peaks in scan at RT=" + String(ms1_it->getRT()) + String(", skipping"), 1);
continue;
}
PeakMap::Iterator ms2_it = ms1_it;
++ms2_it;
while (ms2_it != exp.end() && ms2_it->getMSLevel() == 2)
{
// first: error checks
if (ms2_it->getPrecursors().empty())
{
writeDebug_("Warning: found no precursors of spectrum RT=" + String(ms2_it->getRT()) + ", skipping it.", 1);
++ms2_it;
continue;
}
else if (ms2_it->getPrecursors().size() > 1)
{
writeLog_("Warning: found more than one precursor of spectrum RT=" + String(ms2_it->getRT()) + ", using first one.");
}
Precursor prec = *ms2_it->getPrecursors().begin();
double prec_pos = prec.getMZ();
PeakMap new_exp;
// now excise small region from the MS1 spec for the feature finder (isotope pattern must be covered...)
PeakSpectrum zoom_spec;
for (PeakSpectrum::ConstIterator pit = ms1_it->begin(); pit != ms1_it->end(); ++pit)
{
if (pit->getMZ() > prec_pos - 3 && pit->getMZ() < prec_pos + 3)
{
//.........这里部分代码省略.........
示例4: main_
ExitCodes main_(int, const char **)
{
//-------------------------------------------------------------
// parsing parameters
//-------------------------------------------------------------
String in(getStringOption_("in"));
String out(getStringOption_("out"));
Size num_spots_per_row(getIntOption_("num_spots_per_row"));
double RT_distance(getDoubleOption_("RT_distance"));
//-------------------------------------------------------------
// reading input
//-------------------------------------------------------------
PeakMap exp;
MzMLFile f;
f.setLogType(log_type_);
f.load(in, exp);
//-------------------------------------------------------------
// calculations
//-------------------------------------------------------------
ProgressLogger pl;
pl.setLogType(log_type_);
pl.startProgress(0, exp.size(), "Assigning pseudo RTs.");
Size num_ms1(0), num_ms1_base(0), row_counter(0);
bool row_to_reverse(false);
double actual_RT(0);
for (Size i = 0; i != exp.size(); ++i)
{
pl.setProgress(i);
if (row_to_reverse)
{
actual_RT = (double)(num_ms1_base + (num_spots_per_row - row_counter)) * RT_distance;
writeDebug_("RT=" + String(actual_RT) + " (modified, row_counter=" + String(row_counter) + ")", 1);
}
else
{
actual_RT = (double)num_ms1 * RT_distance;
writeDebug_("RT=" + String(actual_RT), 1);
}
exp[i].setRT(actual_RT);
if (exp[i].getMSLevel() == 1)
{
if (++row_counter >= num_spots_per_row)
{
row_counter = 0;
if (row_to_reverse)
{
row_to_reverse = false;
}
else
{
row_to_reverse = true;
}
}
++num_ms1;
if (!row_to_reverse)
{
num_ms1_base = num_ms1;
}
}
}
pl.endProgress();
// sort the spectra according to their new RT
exp.sortSpectra();
//-------------------------------------------------------------
// writing output
//-------------------------------------------------------------
f.store(out, exp);
return EXECUTION_OK;
}