本文整理汇总了C++中Peak1D类的典型用法代码示例。如果您正苦于以下问题:C++ Peak1D类的具体用法?C++ Peak1D怎么用?C++ Peak1D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Peak1D类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EmpiricalFormula
void CompNovoIdentificationBase::getCIDSpectrumLight_(PeakSpectrum & spec, const String & sequence, DoubleReal prefix, DoubleReal suffix)
{
static DoubleReal h2o_mass = EmpiricalFormula("H2O").getMonoWeight();
Peak1D p;
DoubleReal b_pos(0.0 + prefix);
DoubleReal y_pos(h2o_mass + suffix);
for (Size i = 0; i != sequence.size() - 1; ++i)
{
char aa(sequence[i]);
b_pos += aa_to_weight_[aa];
char aa2(sequence[sequence.size() - i - 1]);
y_pos += aa_to_weight_[aa2];
if (b_pos > min_mz_ && b_pos < max_mz_)
{
p.setPosition(b_pos + Constants::PROTON_MASS_U);
p.setIntensity(1.0f);
spec.push_back(p);
}
if (y_pos > min_mz_ && y_pos < max_mz_)
{
p.setPosition(y_pos + Constants::PROTON_MASS_U);
p.setIntensity(1.0f);
spec.push_back(p);
}
}
spec.sortByPosition();
return;
}
示例2: 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
示例3: 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);
}
}
示例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: 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);
}
}
示例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: START_SECTION
END_SECTION
START_SECTION((PositionType const& getPosition() const))
TEST_REAL_SIMILAR(Peak1D().getPosition()[0], 0.0)
END_SECTION
START_SECTION((CoordinateType getMZ() const))
TEST_REAL_SIMILAR(Peak1D().getMZ(), 0.0)
END_SECTION
START_SECTION((CoordinateType getPos() const))
TEST_REAL_SIMILAR(Peak1D().getPos(), 0.0)
END_SECTION
START_SECTION((void setIntensity(IntensityType intensity)))
Peak1D p;
p.setIntensity(17.8f);
TEST_REAL_SIMILAR(p.getIntensity(), 17.8)
END_SECTION
START_SECTION((void setPosition(PositionType const &position)))
Peak1D::PositionType pos;
pos[0] = 1.0;
Peak1D p;
p.setPosition(pos);
TEST_REAL_SIMILAR(p.getPosition()[0], 1.0)
END_SECTION
START_SECTION((PositionType& getPosition()))
Peak1D::PositionType pos;
pos[0] = 1.0;
示例9: previous_zero_left
//.........这里部分代码省略.........
}
}
previous_zero_right = (input[i + k].getIntensity() == 0);
right_boundary = i + k;
++k;
}
// skip if the minimal number of 3 points for fitting is not reached
if (peak_raw_data.size() < 3) continue;
CubicSpline2d peak_spline (peak_raw_data);
// calculate maximum by evaluating the spline's 1st derivative
// (bisection method)
double max_peak_mz = central_peak_mz;
double max_peak_int = central_peak_int;
double threshold = 1e-6;
OpenMS::Math::spline_bisection(peak_spline, left_neighbor_mz, right_neighbor_mz, max_peak_mz, max_peak_int, threshold);
//
// compute FWHM
//
if (report_FWHM_)
{
double fwhm_int = max_peak_int / 2.0;
threshold = 0.01 * fwhm_int;
double mz_mid, int_mid;
// left:
double mz_left = peak_raw_data.begin()->first;
double mz_center = max_peak_mz;
if (peak_spline.eval(mz_left) > fwhm_int)
{ // the spline ends before half max is reached -- take the leftmost point (probably an underestimation)
mz_mid = mz_left;
}
else
{
do
{
mz_mid = mz_left / 2 + mz_center / 2;
int_mid = peak_spline.eval(mz_mid);
if (int_mid < fwhm_int)
{
mz_left = mz_mid;
}
else
{
mz_center = mz_mid;
}
} while (fabs(int_mid - fwhm_int) > threshold);
}
const double fwhm_left_mz = mz_mid;
// right ...
double mz_right = peak_raw_data.rbegin()->first;
mz_center = max_peak_mz;
if (peak_spline.eval(mz_right) > fwhm_int)
{ // the spline ends before half max is reached -- take the rightmost point (probably an underestimation)
mz_mid = mz_right;
}
else
{
do
{
mz_mid = mz_right / 2 + mz_center / 2;
int_mid = peak_spline.eval(mz_mid);
if (int_mid < fwhm_int)
{
mz_right = mz_mid;
}
else
{
mz_center = mz_mid;
}
} while (fabs(int_mid - fwhm_int) > threshold);
}
const double fwhm_right_mz = mz_mid;
const double fwhm_absolute = fwhm_right_mz - fwhm_left_mz;
output.getFloatDataArrays()[0].push_back( report_FWHM_as_ppm_ ? fwhm_absolute / max_peak_mz * 1e6 : fwhm_absolute);
} // FWHM
// save picked peak into output spectrum
Peak1D peak;
PeakBoundary peak_boundary;
peak.setMZ(max_peak_mz);
peak.setIntensity(max_peak_int);
peak_boundary.mz_min = input[left_boundary].getMZ();
peak_boundary.mz_max = input[right_boundary].getMZ();
output.push_back(peak);
boundaries.push_back(peak_boundary);
// jump over profile data points that have been considered already
i = i + k - 1;
}
}
return;
}
示例10: main_
//.........这里部分代码省略.........
fixed_modifications_ok = false;
break;
}
}
}
}
//variable modifications
if (aaseq.isModified() && (!variable_modifications.empty()))
{
for (Size i = 0; i < aaseq.size(); ++i)
{
if (aaseq.isModified(i))
{
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";
示例11: getConvexhull
p1_6.setIntensity(4.8522452777f);
p1_6.setMZ(1000);
mt1.peaks.push_back(std::make_pair(678.6 , &p1_6));
Peak1D p1_7;
p1_7.setIntensity(5.80919229659f);
p1_7.setMZ(1000);
mt1.peaks.push_back(std::make_pair(678.9 , &p1_7));
Peak1D p1_8;
p1_8.setIntensity(6.68216169129f);
p1_8.setMZ(1000);
mt1.peaks.push_back(std::make_pair(679.2 , &p1_8));
Peak1D p1_9;
p1_9.setIntensity(7.38493077109f);
p1_9.setMZ(1000);
mt1.peaks.push_back(std::make_pair(679.5 , &p1_9));
Peak1D p1_10;
p1_10.setIntensity(7.84158938645f);
p1_10.setMZ(1000);
mt1.peaks.push_back(std::make_pair(679.8 , &p1_10));
START_SECTION(([FeatureFinderAlgorithmPickedHelperStructs::MassTrace] ConvexHull2D getConvexhull() const ))
{
ConvexHull2D ch = mt1.getConvexhull();
DPosition<2> point;
point[0] = 679.8;
point[1] = p1_10.getMZ();
TEST_EQUAL(ch.encloses(point),true);
point[1] = p1_10.getMZ() + 1.0;
示例12: sm
bool ShiftModel1D::finish()
{
if (!isValid())
{
return false;
}
if (!system_)
{
Log.info() << "No valid system found!" << std::endl;
return false;
}
// compute the shift model if necessary
if (compute_shifts_)
{
BALL::ShiftModel sm(parameters_.getFilename());
system_->apply(sm);
}
String element = "";
// Peter Bayer proposed as peak width
// for H 15Hz
// for N 10hz
// for C 5Hz
// peakwidth is meassured in ppm, since
// experiments were done in Hz, we convert the values
// according to the formular
//
// offset [Hz] = offset[ppm] * basic frequency
//
// for our prediction we assume a basic frequency of 700 MHz
float peakwidth = 0.0;
switch(type_)
{
case H:
case H_ON_BACKBONE:
element = "H";
//peakwidth = 0.02142; // Peter Bayers estimation
peakwidth = 0.0032; // this is the former BALL estimation
break;
case N:
case N_BACKBONE:
element = "N";
peakwidth = 0.01428;
break;
case C:
case C_BACKBONE:
element = "C";
peakwidth = 0.00714;
break;
}
int counter = 0;
if (element == "" )
return true;
for (BALL::ResidueIterator r_it = system_->beginResidue(); +r_it; ++r_it)
{
Atom* atom = NULL;
for (BALL::AtomIterator at_it = r_it->beginAtom(); +at_it; ++at_it)
{
if (hasType_(&(*at_it), type_))
{
counter++;
atom = &(*at_it);
// we have, get the shift
float shift = atom->getProperty(BALL::ShiftModule::PROPERTY__SHIFT).getFloat();
Peak1D peak;
float pos = shift;
peak.setPosition(pos);
peak.setWidth(peakwidth);
peak.setIntensity(peak.getIntensity()+1);
//setAtom();
peaks_.push_back(peak);
}
}
}
std::cout << "Number of considered atoms: "<< counter << std::endl;
return true;
}
示例13: main_
//.........这里部分代码省略.........
// 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?
if (fabs(it->getRT() - pit->rt) >= RT_tolerance)
{
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)
{
示例14: CHECK
CHECK(Peak1D::getAtom()/setAtom() const )
TEST_EQUAL(peak.getAtom(), 0)
peak.setAtom(&atom);
TEST_EQUAL(peak.getAtom(), &atom)
RESULT
CHECK(Peak1D::Peak1D(const Peak1D& peak))
Peak1D peak2(peak);
TEST_REAL_EQUAL(peak2.getPosition(), 111.1)
TEST_REAL_EQUAL(peak2.getWidth(), 222.2)
TEST_REAL_EQUAL(peak2.getIntensity(), 333.3)
TEST_EQUAL(peak2.getAtom(), &atom)
RESULT
CHECK(Peak1D::void operator = (const Peak1D& peak))
Peak1D peak2 = peak;
TEST_REAL_EQUAL(peak2.getPosition(), 111.1)
TEST_REAL_EQUAL(peak2.getWidth(), 222.2)
TEST_REAL_EQUAL(peak2.getIntensity(), 333.3)
TEST_EQUAL(peak2.getAtom(), &atom)
RESULT
CHECK(Peak1D::bool operator == (const Peak1D& peak) const )
Peak1D peak2 = peak;
Peak1D peak3 = peak;
TEST_EQUAL(peak2 == peak, true)
TEST_EQUAL(peak2 == peak3, true)
peak3.setWidth(0.0);
TEST_EQUAL(peak2 == peak, true)
TEST_EQUAL(peak2 == peak3, false)
peak3.setWidth(peak2.getWidth());