35 #ifndef OPENMS_ANALYSIS_ID_IDMAPPER_H 36 #define OPENMS_ANALYSIS_ID_IDMAPPER_H 70 enum Measure {MEASURE_PPM = 0, MEASURE_DA};
96 template <
typename PeakType>
97 void annotate(
MSExperiment<PeakType>& map,
const std::vector<PeptideIdentification>& peptide_ids,
const std::vector<ProteinIdentification>& protein_ids,
const bool clear_ids =
false,
const bool mapMS1 =
false)
99 checkHits_(peptide_ids);
103 std::vector<PeptideIdentification> empty_ids;
106 it->setPeptideIdentifications(empty_ids);
108 std::vector<ProteinIdentification> empty_prot_ids;
112 if (peptide_ids.empty())
return;
118 std::multimap<double, Size> experiment_precursors;
119 for (
Size i = 0; i < map.
size(); i++)
121 experiment_precursors.insert(std::make_pair(map[i].getRT(), i));
125 std::multimap<double, Size> identifications_precursors;
126 for (
Size i = 0; i < peptide_ids.size(); ++i)
128 if (!peptide_ids[i].empty())
130 identifications_precursors.insert(std::make_pair(peptide_ids[i].getRT(), i));
136 std::set<Size> peptides_mapped;
139 std::multimap<double, Size>::const_iterator experiment_iterator = experiment_precursors.begin();
140 std::multimap<double, Size>::const_iterator identifications_iterator = identifications_precursors.begin();
145 while (experiment_iterator != experiment_precursors.end())
148 if (identifications_iterator == identifications_precursors.end())
150 --identifications_iterator;
154 while (identifications_iterator != identifications_precursors.begin() &&
155 (experiment_iterator->first - identifications_iterator->first) < rt_tolerance_)
157 --identifications_iterator;
160 if (identifications_iterator != identifications_precursors.end() && ((experiment_iterator->first - identifications_iterator->first) > rt_tolerance_))
162 ++identifications_iterator;
165 if (identifications_iterator == identifications_precursors.end())
171 while (identifications_iterator != identifications_precursors.end() &&
172 (identifications_iterator->first - experiment_iterator->first) < rt_tolerance_)
176 ((!map[experiment_iterator->second].getPrecursors().
empty()) &&
177 isMatch_(0, peptide_ids[identifications_iterator->second].getMZ(), map[experiment_iterator->second].getPrecursors()[0].getMZ())))
179 map[experiment_iterator->second].getPeptideIdentifications().push_back(peptide_ids[identifications_iterator->second]);
180 peptides_mapped.insert(identifications_iterator->second);
182 ++identifications_iterator;
185 ++experiment_iterator;
189 LOG_INFO <<
"Peptides assigned to a precursor: " << peptides_mapped.size() <<
"\n" 190 <<
" Unassigned peptides: " << peptide_ids.size() - peptides_mapped.size() <<
"\n" 191 <<
" Unmapped (empty) peptides: " << peptide_ids.size() - identifications_precursors.size() << std::endl;
211 template <
typename PeakType>
215 std::vector<PeptideIdentification> peptide_ids;
217 for (FeatureMap::const_iterator it = fmap.begin(); it != fmap.end(); ++it)
219 const std::vector<PeptideIdentification>& pi = it->getPeptideIdentifications();
220 for (std::vector<PeptideIdentification>::const_iterator itp = pi.begin(); itp != pi.end(); ++itp)
222 peptide_ids.push_back(*itp);
224 if (!itp->hasMZ()) peptide_ids.back().setMZ(it->getMZ());
225 if (!itp->hasRT()) peptide_ids.back().setRT(it->getRT());
229 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);
265 void annotate(
ConsensusMap& map,
const std::vector<PeptideIdentification>& ids,
const std::vector<ProteinIdentification>& protein_ids,
bool measure_from_subelements =
false,
bool annotate_ids_with_subelements =
false);
268 void updateMembers_();
282 double getAbsoluteMZTolerance_(
const double mz)
const;
285 bool isMatch_(
const double rt_distance,
const double mz_theoretical,
const double mz_observed)
const;
288 void checkHits_(
const std::vector<PeptideIdentification>& ids)
const;
300 bool checkMassType_(
const std::vector<DataProcessing>& processing)
const;
306 #endif // OPENMS_ANALYSIS_ID_IDMAPPER_H double rt_tolerance_
Allowed RT deviation.
Definition: IDMapper.h:271
void setProteinIdentifications(const std::vector< ProteinIdentification > &protein_identifications)
sets the protein ProteinIdentification vector
Size size() const
Definition: MSExperiment.h:117
const std::vector< ProteinIdentification > & getProteinIdentifications() const
non-mutable access to the protein identifications
double mz_tolerance_
Allowed m/z deviation.
Definition: IDMapper.h:273
#define LOG_INFO
Macro if a information, e.g. a status should be reported.
Definition: LogStream.h:455
void annotate(MSExperiment< PeakType > &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:97
std::vector< double > DoubleList
Vector of double precision real types.
Definition: ListUtils.h:66
const std::vector< ProteinIdentification > & getProteinIdentifications() const
returns a const reference to the protein ProteinIdentification vector
A container for features.
Definition: FeatureMap.h:93
Annotates an MSExperiment, FeatureMap or ConsensusMap with peptide identifications.
Definition: IDMapper.h:66
Measure
Definition: IDMapper.h:70
Iterator begin()
Definition: MSExperiment.h:147
void annotate(MSExperiment< PeakType > &map, FeatureMap fmap, const bool clear_ids=false, const bool mapMS1=false)
Mapping method for peak maps.
Definition: IDMapper.h:212
A container for consensus elements.
Definition: ConsensusMap.h:72
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:59
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Iterator end()
Definition: MSExperiment.h:157
Base::iterator iterator
Definition: MSExperiment.h:114
bool ignore_charge_
Ignore charge states during matching?
Definition: IDMapper.h:277
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:69
bool empty() const
Definition: MSExperiment.h:127
Measure measure_
Measure used for m/z.
Definition: IDMapper.h:275
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:63