本文整理汇总了C++中PeakMap类的典型用法代码示例。如果您正苦于以下问题:C++ PeakMap类的具体用法?C++ PeakMap怎么用?C++ PeakMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PeakMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filterPeakMap
void Normalizer::filterPeakMap(PeakMap & exp)
{
for (PeakMap::Iterator it = exp.begin(); it != exp.end(); ++it)
{
filterSpectrum(*it);
}
}
示例2: run
void MassTraceDetection::run(PeakMap::ConstAreaIterator& begin,
PeakMap::ConstAreaIterator& end,
std::vector<MassTrace>& found_masstraces)
{
PeakMap map;
MSSpectrum<Peak1D> current_spectrum;
if (begin == end)
{
return;
}
for (; begin != end; ++begin)
{
// AreaIterator points on novel spectrum?
if (begin.getRT() != current_spectrum.getRT())
{
// save new spectrum in map
if (current_spectrum.getRT() != -1)
{
map.addSpectrum(current_spectrum);
}
current_spectrum.clear(false);
current_spectrum.setRT(begin.getRT());
}
current_spectrum.push_back(*begin);
}
map.addSpectrum(current_spectrum);
run(map, found_masstraces);
}
示例3: filterPeakMap
void ParentPeakMower::filterPeakMap(PeakMap & exp)
{
for (PeakMap::Iterator it = exp.begin(); it != exp.end(); ++it)
{
filterSpectrum(*it);
}
}
示例4: getRetentionTimes_
// lists of peptide hits in "maps" will be sorted
bool MapAlignmentAlgorithmIdentification::getRetentionTimes_(
PeakMap& experiment, SeqToList& rt_data)
{
for (PeakMap::Iterator exp_it = experiment.begin();
exp_it != experiment.end(); ++exp_it)
{
getRetentionTimes_(exp_it->getPeptideIdentifications(), rt_data);
}
// duplicate annotations should not be possible -> no need to remove them
return false;
}
示例5: load
void MzMLFile::load(const String& filename, PeakMap& map)
{
map.reset();
//set DocumentIdentifier
map.setLoadedFileType(filename);
map.setLoadedFilePath(filename);
Internal::MzMLHandler handler(map, filename, getVersion(), *this);
handler.setOptions(options_);
safeParse_(filename, &handler);
}
示例6: filterPeakMap
void WindowMower::filterPeakMap(PeakMap & exp)
{
bool sliding = (String)param_.getValue("movetype") == "slide" ? true : false;
for (PeakMap::Iterator it = exp.begin(); it != exp.end(); ++it)
{
if (sliding)
{
filterPeakSpectrumForTopNInSlidingWindow(*it);
} else
{
filterPeakSpectrumForTopNInJumpingWindow(*it);
}
}
}
示例7: main_
ExitCodes main_(int, const char **)
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
String in_spectra = getStringOption_("in_spectra");
String in_identifications = getStringOption_("in_identifications");
String outfile = getStringOption_("model_output_file");
Int precursor_charge = getIntOption_("precursor_charge");
//-------------------------------------------------------------
// init SvmTheoreticalSpectrumGeneratorTrainer
//-------------------------------------------------------------
SvmTheoreticalSpectrumGeneratorTrainer trainer;
Param param = getParam_().copy("algorithm:", true);
String write_files = getFlag_("write_training_files") ? "true" : "false";
param.setValue("write_training_files", write_files);
trainer.setParameters(param);
//-------------------------------------------------------------
// loading input
//-------------------------------------------------------------
PeakMap map;
MzMLFile().load(in_spectra, map);
std::vector<PeptideIdentification> pep_ids;
std::vector<ProteinIdentification> prot_ids;
String tmp_str;
IdXMLFile().load(in_identifications, prot_ids, pep_ids, tmp_str);
IDMapper idmapper;
Param par;
par.setValue("rt_tolerance", 0.001);
par.setValue("mz_tolerance", 0.001);
idmapper.setParameters(par);
idmapper.annotate(map, pep_ids, prot_ids);
//generate vector of annotations
std::vector<AASequence> annotations;
PeakMap::iterator it;
for (it = map.begin(); it != map.end(); ++it)
{
annotations.push_back(it->getPeptideIdentifications()[0].getHits()[0].getSequence());
}
trainer.trainModel(map, annotations, outfile, precursor_charge);
return EXECUTION_OK;
}
示例8: main_
ExitCodes main_(int, const char **) override
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
//input/output files
String in(getStringOption_("in"));
String out(getStringOption_("out"));
//-------------------------------------------------------------
// loading input
//-------------------------------------------------------------
PeakMap exp;
MzMLFile f;
f.setLogType(log_type_);
f.load(in, exp);
//-------------------------------------------------------------
// if meta data arrays are present, remove them and warn
//-------------------------------------------------------------
if (exp.clearMetaDataArrays())
{
writeLog_("Warning: Spectrum meta data arrays cannot be sorted. They are deleted.");
}
//-------------------------------------------------------------
// filter
//-------------------------------------------------------------
Param filter_param = getParam_().copy("algorithm:", true);
writeDebug_("Used filter parameters", filter_param, 3);
BernNorm filter;
filter.setParameters(filter_param);
filter.filterPeakMap(exp);
//-------------------------------------------------------------
// writing output
//-------------------------------------------------------------
//annotate output with data processing info
addDataProcessing_(exp, getProcessingInfo_(DataProcessing::FILTERING));
f.store(out, exp);
return EXECUTION_OK;
}
示例9: cacheFile
CachedmzML cacheFile(std::string & tmp_filename, PeakMap& exp)
{
NEW_TMP_FILE(tmp_filename);
// Load experiment
MzMLFile().load(OPENMS_GET_TEST_DATA_PATH("MzMLFile_1.mzML"), exp);
TEST_EQUAL(exp.getNrSpectra() > 0, true)
TEST_EQUAL(exp.getNrChromatograms() > 0, true)
// Cache the experiment to a temporary file
CachedmzML cache;
cache.writeMemdump(exp, tmp_filename);
// Create the index from the given file
cache.createMemdumpIndex(tmp_filename);
return cache;
}
示例10: PeakMap
bool IDEvaluationBase::addSearchFile(const String& file_name)
{
MSSpectrum<> points;
if (!loadCurve(file_name, points)) return false;
data_.addSpectrum(points);
PeakMap* exp = new PeakMap();
exp->addSpectrum(points);
spec_1d_->canvas()->addLayer(SpectrumCanvas::ExperimentSharedPtrType(exp));
spec_1d_->canvas()->setLayerName(spec_1d_->canvas()->getLayerCount() - 1, points.getMetaValue("search_engine"));
// set intensity mode (after spectrum has been added!)
setIntensityMode((int) SpectrumCanvas::IM_SNAP);
return true;
}
示例11: writeXQuestXMLSpec
// version for label-free linkers
void XQuestResultXMLFile::writeXQuestXMLSpec(String out_file, String base_name, const std::vector< std::vector< OPXLDataStructs::CrossLinkSpectrumMatch > >& all_top_csms, const PeakMap& spectra)
{
// String spec_xml_filename = base_name + "_matched.spec.xml";
// XML Header
std::ofstream spec_xml_file;
std::cout << "Writing spec.xml to " << out_file << std::endl;
spec_xml_file.open(out_file.c_str(), std::ios::trunc); // ios::app = append to file, ios::trunc = overwrites file
// TODO write actual data
spec_xml_file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xquest_spectra compare_peaks_version=\"3.4\" date=\"Tue Nov 24 12:41:18 2015\" author=\"Thomas Walzthoeni,Oliver Rinner\" homepage=\"http://proteomics.ethz.ch\" resultdir=\"aleitner_M1012_004_matched\" deffile=\"xquest.def\" >" << std::endl;
// collect indices of spectra, that need to be written out
std::vector <Size> spectrum_indices;
for (Size i = 0; i < all_top_csms.size(); ++i)
{
if (!all_top_csms[i].empty())
{
if (all_top_csms[i][0].scan_index_light < spectra.size())
{
spectrum_indices.push_back(all_top_csms[i][0].scan_index_light);
}
}
}
// loop over list of indices and write out spectra
for (Size i = 0; i < spectrum_indices.size(); ++i)
{
String spectrum_light_name = base_name + ".light." + spectrum_indices[i];
String spectrum_heavy_name = base_name + ".heavy." + spectrum_indices[i];
String spectrum_name = spectrum_light_name + String("_") + spectrum_heavy_name;
// 4 Spectra resulting from a light/heavy spectra pair. Write for each spectrum, that is written to xquest.xml (should be all considered pairs, or better only those with at least one sensible Hit, meaning a score was computed)
spec_xml_file << "<spectrum filename=\"" << spectrum_light_name << ".dta" << "\" type=\"light\">" << std::endl;
spec_xml_file << getxQuestBase64EncodedSpectrum_(spectra[spectrum_indices[i]], String(""));
spec_xml_file << "</spectrum>" << std::endl;
spec_xml_file << "<spectrum filename=\"" << spectrum_heavy_name << ".dta" << "\" type=\"heavy\">" << std::endl;
spec_xml_file << getxQuestBase64EncodedSpectrum_(spectra[spectrum_indices[i]], String(""));
spec_xml_file << "</spectrum>" << std::endl;
String spectrum_common_name = spectrum_name + String("_common.txt");
spec_xml_file << "<spectrum filename=\"" << spectrum_common_name << "\" type=\"common\">" << std::endl;
spec_xml_file << getxQuestBase64EncodedSpectrum_(spectra[spectrum_indices[i]], spectrum_light_name + ".dta," + spectrum_heavy_name + ".dta");
spec_xml_file << "</spectrum>" << std::endl;
String spectrum_xlink_name = spectrum_name + String("_xlinker.txt");
spec_xml_file << "<spectrum filename=\"" << spectrum_xlink_name << "\" type=\"xlinker\">" << std::endl;
spec_xml_file << getxQuestBase64EncodedSpectrum_(spectra[spectrum_indices[i]], spectrum_light_name + ".dta," + spectrum_heavy_name + ".dta");
spec_xml_file << "</spectrum>" << std::endl;
}
spec_xml_file << "</xquest_spectra>" << std::endl;
spec_xml_file.close();
return;
}
示例12:
vector<vector<Size> > PScore::calculateRankMap(const PeakMap& peak_map, double mz_window)
{
vector<std::vector<Size> > rank_map; // note: ranks are zero based
rank_map.reserve(peak_map.size());
for (Size i = 0; i != peak_map.size(); ++i)
{
const PeakSpectrum& spec = peak_map[i];
vector<double> mz;
vector<double> intensities;
for (Size j = 0; j != spec.size(); ++j)
{
mz.push_back(spec[j].getMZ());
intensities.push_back(spec[j].getIntensity());
}
rank_map.push_back(calculateIntensityRankInMZWindow(mz, intensities, mz_window));
}
return rank_map;
}
示例13: 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]);
QApplication app(argc, const_cast<char **>(argv));
PeakMap exp;
exp.resize(1);
DTAFile().load(tutorial_data_path + "/data/Tutorial_Spectrum1D.dta", exp[0]);
LayerData::ExperimentSharedPtrType exp_sptr(new PeakMap(exp));
Spectrum1DWidget * widget = new Spectrum1DWidget(Param(), 0);
widget->canvas()->addLayer(exp_sptr);
widget->show();
return app.exec();
} //end of main
示例14: getPrecursors_
void getPrecursors_(const PeakMap & exp, vector<Precursor> & precursors, vector<double> & precursors_rt)
{
for (Size i = 0; i != exp.size(); ++i)
{
vector<Precursor> pcs = exp[i].getPrecursors();
if (pcs.empty())
{
continue;
}
vector<double> pcs_rt(pcs.size(), exp[i].getRT());
copy(pcs.begin(), pcs.end(), back_inserter(precursors));
copy(pcs_rt.begin(), pcs_rt.end(), back_inserter(precursors_rt));
}
}
示例15: getSwathFile
void getSwathFile(PeakMap& exp, int nr_swathes=32, bool ms1=true)
{
if (ms1)
{
MSSpectrum s;
s.setMSLevel(1);
Peak1D p; p.setMZ(100); p.setIntensity(200);
s.push_back(p);
exp.addSpectrum(s);
}
for (int i = 0; i< nr_swathes; i++)
{
MSSpectrum s;
s.setMSLevel(2);
std::vector<Precursor> prec(1);
prec[0].setIsolationWindowLowerOffset(12.5);
prec[0].setIsolationWindowUpperOffset(12.5);
prec[0].setMZ(400 + i*25 + 12.5);
s.setPrecursors(prec);
Peak1D p; p.setMZ(101 + i); p.setIntensity(201 + i);
s.push_back(p);
exp.addSpectrum(s);
}
}