70 enum Measure {MEASURE_PPM = 0, MEASURE_DA};
96 void annotate(
PeakMap& map,
const std::vector<PeptideIdentification>& peptide_ids,
const std::vector<ProteinIdentification>& protein_ids,
const bool clear_ids =
false,
const bool mapMS1 =
false)
98 checkHits_(peptide_ids);
102 std::vector<PeptideIdentification> empty_ids;
105 it->setPeptideIdentifications(empty_ids);
107 std::vector<ProteinIdentification> empty_prot_ids;
111 if (peptide_ids.empty())
return;
117 std::multimap<double, Size> experiment_precursors;
118 for (
Size i = 0; i < map.
size(); i++)
120 experiment_precursors.insert(std::make_pair(map[i].getRT(), i));
124 std::multimap<double, Size> identifications_precursors;
125 for (
Size i = 0; i < peptide_ids.size(); ++i)
127 if (!peptide_ids[i].empty())
129 identifications_precursors.insert(std::make_pair(peptide_ids[i].getRT(), i));
135 std::set<Size> peptides_mapped;
138 std::multimap<double, Size>::const_iterator experiment_iterator = experiment_precursors.begin();
139 std::multimap<double, Size>::const_iterator identifications_iterator = identifications_precursors.begin();
144 while (experiment_iterator != experiment_precursors.end())
147 if (identifications_iterator == identifications_precursors.end())
149 --identifications_iterator;
153 while (identifications_iterator != identifications_precursors.begin() &&
154 (experiment_iterator->first - identifications_iterator->first) < rt_tolerance_)
156 --identifications_iterator;
159 if (identifications_iterator != identifications_precursors.end() && ((experiment_iterator->first - identifications_iterator->first) > rt_tolerance_))
161 ++identifications_iterator;
164 if (identifications_iterator == identifications_precursors.end())
170 while (identifications_iterator != identifications_precursors.end() &&
171 (identifications_iterator->first - experiment_iterator->first) < rt_tolerance_)
175 ((!map[experiment_iterator->second].getPrecursors().
empty()) &&
176 isMatch_(0, peptide_ids[identifications_iterator->second].getMZ(), map[experiment_iterator->second].getPrecursors()[0].getMZ())))
178 map[experiment_iterator->second].getPeptideIdentifications().push_back(peptide_ids[identifications_iterator->second]);
179 peptides_mapped.insert(identifications_iterator->second);
181 ++identifications_iterator;
184 ++experiment_iterator;
188 LOG_INFO <<
"Peptides assigned to a precursor: " << peptides_mapped.size() <<
"\n" 189 <<
" Unassigned peptides: " << peptide_ids.size() - peptides_mapped.size() <<
"\n" 190 <<
" Unmapped (empty) peptides: " << peptide_ids.size() - identifications_precursors.size() << std::endl;
213 std::vector<PeptideIdentification> peptide_ids;
215 for (FeatureMap::const_iterator it = fmap.begin(); it != fmap.end(); ++it)
217 const std::vector<PeptideIdentification>& pi = it->getPeptideIdentifications();
218 for (std::vector<PeptideIdentification>::const_iterator itp = pi.begin(); itp != pi.end(); ++itp)
220 peptide_ids.push_back(*itp);
222 if (!itp->hasMZ()) peptide_ids.back().setMZ(it->getMZ());
223 if (!itp->hasRT()) peptide_ids.back().setRT(it->getRT());
227 annotate(map, peptide_ids, protein_ids, clear_ids, mapMS1);
249 void annotate(
FeatureMap& map,
const std::vector<PeptideIdentification>& ids,
const std::vector<ProteinIdentification>& protein_ids,
bool use_centroid_rt =
false,
bool use_centroid_mz =
false,
const PeakMap& spectra =
PeakMap());
267 void annotate(
ConsensusMap& map,
const std::vector<PeptideIdentification>& ids,
268 const std::vector<ProteinIdentification>& protein_ids,
269 bool measure_from_subelements =
false,
270 bool annotate_ids_with_subelements =
false,
300 const std::vector<PeptideIdentification>& ids,
301 double mz_tol = 0.001,
302 double rt_tol = 0.001)
305 for (
Size spectrum_index = 0; spectrum_index < spectra.
size(); ++spectrum_index)
307 const MSSpectrum& spectrum = spectra[spectrum_index];
310 bool identified(
false);
311 const std::vector<Precursor>& precursors = spectrum.
getPrecursors();
314 for (
Size i_p = 0; i_p < precursors.size(); ++i_p)
317 double mz_p = precursors[i_p].getMZ();
318 double rt_s = spectrum.
getRT();
320 for (
Size i_id = 0; i_id != ids.size(); ++i_id)
325 if (pid.
getHits().empty())
continue;
327 double mz_id = pid.
getMZ();
328 double rt_id = pid.
getRT();
330 if ( fabs(mz_id - mz_p) < mz_tol && fabs(rt_s - rt_id) < rt_tol )
356 void updateMembers_()
override;
370 double getAbsoluteMZTolerance_(
const double mz)
const;
373 bool isMatch_(
const double rt_distance,
const double mz_theoretical,
const double mz_observed)
const;
376 void checkHits_(
const std::vector<PeptideIdentification>& ids)
const;
388 bool checkMassType_(
const std::vector<DataProcessing>& processing)
const;
double rt_tolerance_
Allowed RT deviation.
Definition: IDMapper.h:359
void setProteinIdentifications(const std::vector< ProteinIdentification > &protein_identifications)
sets the protein ProteinIdentification vector
double mz_tolerance_
Allowed m/z deviation.
Definition: IDMapper.h:361
#define LOG_INFO
Macro if a information, e.g. a status should be reported.
Definition: LogStream.h:454
std::vector< double > DoubleList
Vector of double precision real types.
Definition: ListUtils.h:65
void annotate(PeakMap &map, FeatureMap fmap, const bool clear_ids=false, const bool mapMS1=false)
Mapping method for peak maps.
Definition: IDMapper.h:210
std::vector< Size > no_precursors
Definition: IDMapper.h:279
Result of a partitioning by identification state with mapPrecursorsToIdentifications().
Definition: IDMapper.h:277
A container for features.
Definition: FeatureMap.h:93
const std::vector< PeptideHit > & getHits() const
returns the peptide hits as const
Annotates an MSExperiment, FeatureMap or ConsensusMap with peptide identifications.
Definition: IDMapper.h:66
std::vector< Size > unidentified
Definition: IDMapper.h:281
Measure
Definition: IDMapper.h:70
Iterator begin()
Definition: MSExperiment.h:157
A container for consensus elements.
Definition: ConsensusMap.h:75
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:58
Size size() const
Definition: MSExperiment.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
double getMZ() const
returns the MZ of the MS2 spectrum
Iterator end()
Definition: MSExperiment.h:167
Base::iterator iterator
Definition: MSExperiment.h:124
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
void annotate(PeakMap &map, const std::vector< PeptideIdentification > &peptide_ids, const std::vector< ProteinIdentification > &protein_ids, const bool clear_ids=false, const bool mapMS1=false)
Mapping method for peak maps.
Definition: IDMapper.h:96
double getRT() const
returns the RT of the MS2 spectrum where the identification occurred
MSExperiment PeakMap
Two-dimensional map of raw data points or peaks.
Definition: StandardTypes.h:61
bool ignore_charge_
Ignore charge states during matching?
Definition: IDMapper.h:365
bool empty() const
Definition: MSExperiment.h:137
std::vector< Size > identified
Definition: IDMapper.h:280
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
static SpectraIdentificationState mapPrecursorsToIdentifications(const PeakMap &spectra, const std::vector< PeptideIdentification > &ids, double mz_tol=0.001, double rt_tol=0.001)
Mapping of peptide identifications to spectra This helper function partitions all spectra into those ...
Definition: IDMapper.h:299
Measure measure_
Measure used for m/z.
Definition: IDMapper.h:363
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
const std::vector< ProteinIdentification > & getProteinIdentifications() const
returns a const reference to the protein ProteinIdentification vector
const std::vector< ProteinIdentification > & getProteinIdentifications() const
non-mutable access to the protein identifications
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:62