void pr_int(t_conv *conv) { int signoffset; char fillchar; pre_int(conv); if (conv->precision_on || conv->minus) conv->zero = 0; fillchar = conv->zero && !conv->minus ? '0' : ' '; signoffset = fillchar == '0' && (conv->str[0] == '-' || \ conv->plus || conv->space) ? 1 : 0; while (conv->precision_on && (int)ft_strlen(conv->str) < \ conv->precision + (conv->str[0] == '-')) conv->str = insert_at(conv->str, '0', (conv->str[0] == '-')); if (conv->plus) conv->str = insert_at(conv->str, '+', 0); else if (conv->space) conv->str = insert_at(conv->str, ' ', 0); if ((conv->specifier == 'x' || conv->specifier == 'X') \ && conv->hash && fillchar == '0') signoffset = 2; while ((int)ft_strlen(conv->str) < conv->width) conv->str = insert_at(conv->str, fillchar, \ signoffset + conv->minus * ft_strlen(conv->str)); }
void TheoreticalSpectrumGenerator::addPrecursorPeaks(RichPeakSpectrum & spec, const AASequence & peptide, Int charge) { bool add_metainfo(param_.getValue("add_metainfo").toBool()); DoubleReal pre_int((DoubleReal)param_.getValue("precursor_intensity")); DoubleReal pre_int_H2O((DoubleReal)param_.getValue("precursor_H2O_intensity")); DoubleReal pre_int_NH3((DoubleReal)param_.getValue("precursor_NH3_intensity")); bool add_isotopes(param_.getValue("add_isotopes").toBool()); int max_isotope((int)param_.getValue("max_isotope")); // precursor peak DoubleReal mono_pos = peptide.getMonoWeight(Residue::Full, charge) / DoubleReal(charge); if (add_isotopes) { IsotopeDistribution dist = peptide.getFormula(Residue::Full, charge).getIsotopeDistribution(max_isotope); UInt j(0); for (IsotopeDistribution::ConstIterator it = dist.begin(); it != dist.end(); ++it, ++j) { p_.setMZ((DoubleReal)(mono_pos + j * Constants::NEUTRON_MASS_U) / (DoubleReal)charge); p_.setIntensity(pre_int * it->second); if (add_metainfo) { String name("[M+H]+"); if (charge == 2) { name = "[M+2H]++"; } p_.setMetaValue("IonName", name); } spec.push_back(p_); } } else { p_.setMZ(mono_pos); p_.setIntensity(pre_int); if (add_metainfo) { String name("[M+H]+"); if (charge == 2) { name = "[M+2H]++"; } p_.setMetaValue("IonName", name); } spec.push_back(p_); } // loss peaks of the precursor //loss of water EmpiricalFormula ion = peptide.getFormula(Residue::Full, charge) - EmpiricalFormula("H2O"); mono_pos = ion.getMonoWeight() / DoubleReal(charge); if (add_isotopes) { IsotopeDistribution dist = ion.getIsotopeDistribution(max_isotope); UInt j(0); for (IsotopeDistribution::ConstIterator it = dist.begin(); it != dist.end(); ++it, ++j) { p_.setMZ((DoubleReal)(mono_pos + j * Constants::NEUTRON_MASS_U) / (DoubleReal)charge); p_.setIntensity(pre_int_H2O * it->second); if (add_metainfo) { String name("[M+H]-H2O+"); if (charge == 2) { name = "[M+2H]-H2O++"; } p_.setMetaValue("IonName", name); } spec.push_back(p_); } } else { p_.setMZ(mono_pos); p_.setIntensity(pre_int_H2O); if (add_metainfo) { String name("[M+H]-H2O+"); if (charge == 2) { name = "[M+2H]-H2O++"; } p_.setMetaValue("IonName", name); } spec.push_back(p_); } //loss of ammonia ion = peptide.getFormula(Residue::Full, charge) - EmpiricalFormula("NH3"); mono_pos = ion.getMonoWeight() / DoubleReal(charge); if (add_isotopes) { IsotopeDistribution dist = ion.getIsotopeDistribution(max_isotope); UInt j(0); for (IsotopeDistribution::ConstIterator it = dist.begin(); it != dist.end(); ++it, ++j) { p_.setMZ((DoubleReal)(mono_pos + j * Constants::NEUTRON_MASS_U) / (DoubleReal)charge); p_.setIntensity(pre_int_NH3 * it->second); if (add_metainfo) { String name("[M+H]-NH3+"); if (charge == 2) { name = "[M+2H]-NH3++"; } p_.setMetaValue("IonName", name); } spec.push_back(p_); } } else { p_.setMZ(mono_pos); p_.setIntensity(pre_int_NH3); if (add_metainfo) { String name("[M+H]-NH3+"); if (charge == 2) { name = "[M+2H]-NH3++"; } p_.setMetaValue("IonName", name); } spec.push_back(p_); } spec.sortByPosition(); }