本文整理汇总了C++中Peak1D::setMZ方法的典型用法代码示例。如果您正苦于以下问题:C++ Peak1D::setMZ方法的具体用法?C++ Peak1D::setMZ怎么用?C++ Peak1D::setMZ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Peak1D
的用法示例。
在下文中一共展示了Peak1D::setMZ方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
// create a peak map containing 4 dummy spectra and peaks
MSExperiment exp;
// The following examples creates a MSExperiment containing four MSSpectrum instances.
for (Size i = 0; i < 4; ++i)
{
MSSpectrum spectrum;
spectrum.setRT(i);
spectrum.setMSLevel(1);
for (float mz = 500.0; mz <= 900; mz += 100.0)
{
Peak1D peak;
peak.setMZ(mz + i);
spectrum.push_back(peak);
}
exp.addSpectrum(spectrum);
}
// Iteration over the RT range (2,3) and the m/z range (603,802) and print the peak positions.
for (auto it = exp.areaBegin(2.0, 3.0, 603.0, 802.0); it != exp.areaEnd(); ++it)
{
cout << it.getRT() << " - " << it->getMZ() << endl;
}
// Iteration over all peaks in the experiment.
// Output: RT, m/z, and intensity
// Note that the retention time is stored in the spectrum (not in the peak object)
for (auto s_it = exp.begin(); s_it != exp.end(); ++s_it)
{
for (auto p_it = s_it->begin(); p_it != s_it->end(); ++p_it)
{
cout << s_it->getRT() << " - " << p_it->getMZ() << " " << p_it->getIntensity() << endl;
}
}
// We could store the spectra to a mzML file with:
// MzMLFile mzml;
// mzml.store(filename, exp);
// And load it with
// mzml.load(filename, exp);
// If we wanted to load only the MS2 spectra we could speed up reading by setting:
// mzml.getOptions().addMSLevel(2);
// before executing: mzml.load(filename, exp);
return 0;
} //end of main
示例2: convertToOpenMSSpectrum
void OpenSwathDataAccessHelper::convertToOpenMSSpectrum(const OpenSwath::SpectrumPtr sptr, OpenMS::MSSpectrum<> & spectrum)
{
// recreate a spectrum from the data arrays!
OpenSwath::BinaryDataArrayPtr mz_arr = sptr->getMZArray();
OpenSwath::BinaryDataArrayPtr int_arr = sptr->getIntensityArray();
spectrum.reserve(mz_arr->data.size());
for (Size i = 0; i < mz_arr->data.size(); i++)
{
Peak1D p;
p.setMZ(mz_arr->data[i]);
p.setIntensity(int_arr->data[i]);
spectrum.push_back(p);
}
}
示例3: 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);
}
}
示例4: main
Int main()
{
MSSpectrum<> spectrum;
Peak1D peak;
for (float mz = 1500.0; mz >= 500; mz -= 100.0)
{
peak.setMZ(mz);
spectrum.push_back(peak);
}
spectrum.sortByPosition();
MSSpectrum<>::Iterator it;
for (it = spectrum.MZBegin(800.0); it != spectrum.MZEnd(1000.0); ++it)
{
cout << it->getMZ() << endl;
}
return 0;
} //end of main
示例5: pick
void PeakPickerHiRes::pick(const MSChromatogram& input, MSChromatogram& output, std::vector<PeakBoundary>& boundaries) const
{
// copy meta data of the input chromatogram
output.clear(true);
output.ChromatogramSettings::operator=(input);
output.MetaInfoInterface::operator=(input);
output.setName(input.getName());
MSSpectrum input_spectrum;
MSSpectrum output_spectrum;
for (MSChromatogram::const_iterator it = input.begin(); it != input.end(); ++it)
{
Peak1D p;
p.setMZ(it->getRT());
p.setIntensity(it->getIntensity());
input_spectrum.push_back(p);
}
pick(input_spectrum, output_spectrum, boundaries, false); // no spacing checks!
for (MSSpectrum::const_iterator it = output_spectrum.begin(); it != output_spectrum.end(); ++it)
{
ChromatogramPeak p;
p.setRT(it->getMZ());
p.setIntensity(it->getIntensity());
output.push_back(p);
}
// copy float data arrays (for FWHM)
output.getFloatDataArrays().resize(output_spectrum.getFloatDataArrays().size());
for (Size i = 0; i < output_spectrum.getFloatDataArrays().size(); ++i)
{
output.getFloatDataArrays()[i].insert(output.getFloatDataArrays()[i].begin(), output_spectrum.getFloatDataArrays()[i].begin(), output_spectrum.getFloatDataArrays()[i].end());
output.getFloatDataArrays()[i].setName(output_spectrum.getFloatDataArrays()[i].getName());
}
}
示例6: main_
//.........这里部分代码省略.........
{
continue;
}
// now excise the two ranges for the pair, complete isotope distributions of both, light and heavy
PeakSpectrum light_spec, heavy_spec;
light_spec.setRT(it->getRT());
heavy_spec.setRT(it->getRT());
for (PeakSpectrum::ConstIterator sit = it->begin(); sit != it->end(); ++sit)
{
double mz(sit->getMZ());
if (mz - (pit->mz_light - precursor_mass_tolerance) > 0 &&
(pit->mz_light + (double)max_isotope * Constants::NEUTRON_MASS_U / (double)pit->charge + precursor_mass_tolerance) - mz > 0)
{
light_spec.push_back(*sit);
}
if (mz - (pit->mz_heavy - precursor_mass_tolerance) > 0 &&
(pit->mz_heavy + (double)max_isotope * Constants::NEUTRON_MASS_U / (double)pit->charge + precursor_mass_tolerance) - mz > 0)
{
heavy_spec.push_back(*sit);
}
}
// expand light spectrum
Peak1D p;
p.setIntensity(0);
if (light_spec.size() > 0)
{
double lower_border = light_spec.begin()->getMZ() - expansion_range;
for (double pos = light_spec.begin()->getMZ(); pos > lower_border; pos -= min_spacing)
{
p.setMZ(pos);
light_spec.insert(light_spec.begin(), p);
}
double upper_border = light_spec.begin()->getMZ() - expansion_range;
for (double pos = light_spec.rbegin()->getMZ(); pos < upper_border; pos += min_spacing)
{
p.setMZ(pos);
light_spec.push_back(p);
}
}
if (heavy_spec.size() > 0)
{
// expand heavy spectrum
double lower_border = heavy_spec.begin()->getMZ() - expansion_range;
for (double pos = heavy_spec.begin()->getMZ(); pos > lower_border; pos -= min_spacing)
{
p.setMZ(pos);
heavy_spec.insert(heavy_spec.begin(), p);
}
double upper_border = heavy_spec.begin()->getMZ() - expansion_range;
for (double pos = heavy_spec.rbegin()->getMZ(); pos < upper_border; pos += min_spacing)
{
p.setMZ(pos);
heavy_spec.push_back(p);
}
}
// create experiments for feature finding
PeakMap new_exp_light, new_exp_heavy;
new_exp_light.addSpectrum(light_spec);
示例7: main_
ExitCodes main_(int, const char**)
{
//-------------------------------------------------------------
// parameter handling
//-------------------------------------------------------------
StringList in = getStringList_("in");
String edta = getStringOption_("pos");
String out = getStringOption_("out");
String out_sep = getStringOption_("out_separator");
String out_TIC_debug = getStringOption_("auto_rt:out_debug_TIC");
StringList in_header = getStringList_("in_header");
// number of out_debug_TIC files and input files must be identical
/*if (out_TIC_debug.size() > 0 && in.size() != out_TIC_debug.size())
{
LOG_FATAL_ERROR << "Error: number of input file 'in' and auto_rt:out_debug_TIC files must be identical!" << std::endl;
return ILLEGAL_PARAMETERS;
}*/
// number of header files and input files must be identical
if (in_header.size() > 0 && in.size() != in_header.size())
{
LOG_FATAL_ERROR << "Error: number of input file 'in' and 'in_header' files must be identical!" << std::endl;
return ILLEGAL_PARAMETERS;
}
if (!getFlag_("auto_rt:enabled") && !out_TIC_debug.empty())
{
LOG_FATAL_ERROR << "Error: TIC output file requested, but auto_rt is not enabled! Either do not request the file or switch on 'auto_rt:enabled'." << std::endl;
return ILLEGAL_PARAMETERS;
}
double rttol = getDoubleOption_("rt_tol");
double mztol = getDoubleOption_("mz_tol");
Size rt_collect = getIntOption_("rt_collect");
//-------------------------------------------------------------
// loading input
//-------------------------------------------------------------
MzMLFile mzml_file;
mzml_file.setLogType(log_type_);
MSExperiment<Peak1D> exp, exp_pp;
EDTAFile ed;
ConsensusMap cm;
ed.load(edta, cm);
StringList tf_single_header0, tf_single_header1, tf_single_header2; // header content, for each column
std::vector<String> vec_single; // one line for each compound, multiple columns per experiment
vec_single.resize(cm.size());
for (Size fi = 0; fi < in.size(); ++fi)
{
// load raw data
mzml_file.load(in[fi], exp);
exp.sortSpectra(true);
if (exp.empty())
{
LOG_WARN << "The given file does not contain any conventional peak data, but might"
" contain chromatograms. This tool currently cannot handle them, sorry." << std::endl;
return INCOMPATIBLE_INPUT_DATA;
}
// try to detect RT peaks (only for the first input file -- all others should align!)
// cm.size() might change in here...
if (getFlag_("auto_rt:enabled") && fi == 0)
{
ConsensusMap cm_local = cm; // we might have different RT peaks for each map if 'auto_rt' is enabled
cm.clear(false); // reset global list (about to be filled)
// compute TIC
MSChromatogram<> tic = exp.getTIC();
MSSpectrum<> tics, tic_gf, tics_pp, tics_sn;
for (Size ic = 0; ic < tic.size(); ++ic)
{ // rewrite Chromatogram to MSSpectrum (GaussFilter requires it)
Peak1D peak;
peak.setMZ(tic[ic].getRT());
peak.setIntensity(tic[ic].getIntensity());
tics.push_back(peak);
}
// smooth (no PP_CWT here due to efficiency reasons -- large FWHM take longer!)
double fwhm = getDoubleOption_("auto_rt:FHWM");
GaussFilter gf;
Param p = gf.getParameters();
p.setValue("gaussian_width", fwhm * 2); // wider than FWHM, just to be sure we have a fully smoothed peak. Merging two peaks is unlikely
p.setValue("use_ppm_tolerance", "false");
gf.setParameters(p);
tic_gf = tics;
gf.filter(tic_gf);
// pick peaks
PeakPickerHiRes pp;
p = pp.getParameters();
p.setValue("signal_to_noise", getDoubleOption_("auto_rt:SNThreshold"));
pp.setParameters(p);
pp.pick(tic_gf, tics_pp);
if (tics_pp.size())
//.........这里部分代码省略.........
示例8: main_
//.........这里部分代码省略.........
const Residue& mod = aaseq.getResidue(i);
for (Size s = 0; s < variable_modifications.size(); ++s)
{
if (mod.getOneLetterCode() == mdb->getModification(variable_modifications[s]).getOrigin() && variable_modifications[s] != mod.getModification())
{
variable_modifications_ok = false;
break;
}
}
}
}
}
if (variable_modifications_ok && fixed_modifications_ok)
{
PeptideIdentification& translocate_pid = *i;
librar.getPeptideIdentifications().push_back(translocate_pid);
librar.setPrecursors(s->getPrecursors());
//library entry transformation
for (UInt l = 0; l < s->size(); ++l)
{
Peak1D peak;
if ((*s)[l].getIntensity() > remove_peaks_below_threshold)
{
const String& info = (*s)[l].getMetaValue("MSPPeakInfo");
if (info[0] == '?')
{
peak.setIntensity(sqrt(0.2 * (*s)[l].getIntensity()));
}
else
{
peak.setIntensity(sqrt((*s)[l].getIntensity()));
}
peak.setMZ((*s)[l].getMZ());
peak.setPosition((*s)[l].getPosition());
librar.push_back(peak);
}
}
if (found != MSLibrary.end())
{
found->second.push_back(librar);
}
else
{
vector<PeakSpectrum> tmp;
tmp.push_back(librar);
MSLibrary.insert(make_pair(MZ_multi, tmp));
}
}
}
}
time_t end_build_time = time(NULL);
cout << "Time needed for preprocessing data: " << (end_build_time - start_build_time) << "\n";
//compare function
PeakSpectrumCompareFunctor* comparor = Factory<PeakSpectrumCompareFunctor>::create(compare_function);
//-------------------------------------------------------------
// calculations
//-------------------------------------------------------------
double score;
StringList::iterator in, out_file;
for (in = in_spec.begin(), out_file = out.begin(); in < in_spec.end(); ++in, ++out_file)
{
time_t start_time = time(NULL);
spectra.load(*in, query);
//Will hold valuable hits
vector<PeptideIdentification> peptide_ids;