35 #ifndef OPENMS_ANALYSIS_ID_IDMAPPER_H 
   36 #define OPENMS_ANALYSIS_ID_IDMAPPER_H 
   66     enum Measure {MEASURE_PPM = 0, MEASURE_DA};
 
   89     template <
typename PeakType>
 
   98       std::multimap<DoubleReal, Size> experiment_precursors;
 
   99       for (
Size i = 0; i < map.
size(); i++)
 
  101         experiment_precursors.insert(std::make_pair(map[i].getRT(), i));
 
  105       std::multimap<DoubleReal, Size> identifications_precursors;
 
  106       for (
Size i = 0; i < ids.size(); i++)
 
  108         identifications_precursors.insert(std::make_pair(ids[i].getMetaValue(
"RT"), i));
 
  112       std::multimap<DoubleReal, Size>::iterator experiment_iterator = experiment_precursors.begin();
 
  113       std::multimap<DoubleReal, Size>::iterator identifications_iterator = identifications_precursors.begin();
 
  115       while (experiment_iterator != experiment_precursors.end() && identifications_iterator != identifications_precursors.end())
 
  117         while (identifications_iterator != identifications_precursors.end())
 
  120           if (fabs(experiment_iterator->first - identifications_iterator->first) < rt_tolerance_)
 
  123             if (!map[experiment_iterator->second].getPrecursors().
empty())
 
  125               if (fabs((
DoubleReal)(ids[identifications_iterator->second].getMetaValue(
"MZ")) - map[experiment_iterator->second].getPrecursors()[0].getMZ()) < mz_tolerance_)
 
  127                 if (!(ids[identifications_iterator->second].empty()))
 
  129                   map[experiment_iterator->second].getPeptideIdentifications().push_back(ids[identifications_iterator->second]);
 
  135           ++identifications_iterator;
 
  137         identifications_iterator = identifications_precursors.begin();
 
  138         ++experiment_iterator;
 
  142       LOG_INFO << 
"Unassigned peptides: " << ids.size() - matches << 
"\n" 
  143                << 
"Peptides assigned to a precursor: " << matches << std::endl;
 
  164     template <
typename FeatureType>
 
  165     void annotate(
FeatureMap<FeatureType> & map, 
const std::vector<PeptideIdentification> & ids, 
const std::vector<ProteinIdentification> & protein_ids, 
bool use_centroid_rt = 
false, 
bool use_centroid_mz = 
false)
 
  175       if (!(use_centroid_rt && use_centroid_mz))
 
  179           if (f_it->getConvexHulls().empty())
 
  181             use_centroid_rt = 
true;
 
  182             use_centroid_mz = 
true;
 
  183             LOG_WARN << 
"IDMapper warning: at least one feature has no convex hull - using centroid coordinates for matching" << std::endl;
 
  189       bool use_avg_mass = 
false;           
 
  190       if (use_centroid_mz && (param_.getValue(
"mz_reference") == 
"peptide"))
 
  198       std::vector<DBoundingBox<2> > boxes;
 
  199       DoubleReal min_rt = std::numeric_limits<DoubleReal>::max(),
 
  200                  max_rt = -std::numeric_limits<DoubleReal>::max();
 
  202       boxes.reserve(map.size());
 
  204            f_it != map.end(); ++f_it)
 
  207         if (!(use_centroid_rt && use_centroid_mz))
 
  209           box = f_it->getConvexHull().getBoundingBox();
 
  221         increaseBoundingBox_(box);
 
  222         boxes.push_back(box);
 
  224         min_rt = std::min(min_rt, box.
minPosition().getX());
 
  225         max_rt = std::max(max_rt, box.
maxPosition().getX());
 
  231       std::vector<std::vector<SignedSize> > hash_table;
 
  241         hash_table.resize(
SignedSize(floor(max_rt)) - offset + 1);
 
  242         for (
Size index = 0; index < boxes.size(); ++index)
 
  248             hash_table[i - offset].push_back(index);
 
  254         LOG_WARN << 
"IDMapper received an empty FeatureMap! All peptides are mapped as 'unassigned'!" << std::endl;
 
  258       Size matches_none = 0, matches_single = 0, matches_multi = 0;
 
  262       for (std::vector<PeptideIdentification>::const_iterator id_it =
 
  263              ids.begin(); id_it != ids.end(); ++id_it)
 
  267         if (id_it->getHits().empty()) 
continue;
 
  272         getIDDetails_(*id_it, rt_value, mz_values, charges, use_avg_mass);
 
  274         if ((rt_value < min_rt) || (rt_value > max_rt))             
 
  283         Size matching_features = 0;
 
  284         for (std::vector<SignedSize>::iterator hash_it =
 
  285                hash_table[index].begin(); hash_it != hash_table[index].end();
 
  288           Feature & feat = map[*hash_it];
 
  291           bool check_charge = !ignore_charge_;
 
  292           if (check_charge && (mz_values.size() == 1))               
 
  295             check_charge = 
false;                 
 
  300           for (DoubleList::iterator mz_it = mz_values.begin();
 
  301                mz_it != mz_values.end(); ++mz_it, ++index)
 
  303             if (check_charge && (charges[index] != feat.
getCharge()))
 
  309             if (boxes[*hash_it].encloses(id_pos))                 
 
  320               bool found_match = 
false;
 
  321               for (std::vector<ConvexHull2D>::iterator ch_it =
 
  331                 increaseBoundingBox_(box);
 
  340               if (found_match) 
break;                   
 
  344         if (matching_features == 0)
 
  349         else if (matching_features == 1) ++matches_single;
 
  350         else ++matches_multi;
 
  354       LOG_INFO << 
"Unassigned peptides: " << matches_none << 
"\n" 
  355                << 
"Peptides assigned to exactly one feature: " << matches_single << 
"\n" 
  356                << 
"Peptides assigned to multiple features: " << matches_multi << 
"\n" 
  375     void annotate(
ConsensusMap & map, 
const std::vector<PeptideIdentification> & ids, 
const std::vector<ProteinIdentification> & protein_ids, 
bool measure_from_subelements = 
false);
 
  378     void updateMembers_();
 
  398     void checkHits_(
const std::vector<PeptideIdentification> & ids) 
const;
 
  410     bool checkMassType_(
const std::vector<DataProcessing> & processing) 
const;
 
  416 #endif // OPENMS_ANALYSIS_ID_IDMAPPER_H 
bool encloses(const PositionType &position) const 
Checks whether this range contains a certain point. 
Definition: DBoundingBox.h:159
const ChargeType & getCharge() const 
Non-mutable access to charge state. 
void setMaxX(CoordinateType const c)
Mutator for min_ coordinate of the larger point. 
Definition: DIntervalBase.h:278
const std::vector< PeptideIdentification > & getPeptideIdentifications() const 
returns a const reference to the PeptideIdentification vector 
bool contains(Int s) const 
Returns if a string is contains in the list. 
void setMinY(CoordinateType const c)
Mutator for max_ coordinate of the smaller point. 
Definition: DIntervalBase.h:271
Size size() const 
Definition: MSExperiment.h:117
const std::vector< ProteinIdentification > & getProteinIdentifications() const 
non-mutable access to the protein identifications 
Definition: FeatureMap.h:410
#define LOG_INFO
Macro if a information, e.g. a status should be reported. 
Definition: LogStream.h:455
const std::vector< ProteinIdentification > & getProteinIdentifications() const 
returns a const reference to the protein ProteinIdentification vector 
AnnotationStatistics getAnnotationStatistics() const 
Definition: FeatureMap.h:520
void annotate(FeatureMap< FeatureType > &map, const std::vector< PeptideIdentification > &ids, const std::vector< ProteinIdentification > &protein_ids, bool use_centroid_rt=false, bool use_centroid_mz=false)
Mapping method for feature maps. 
Definition: IDMapper.h:165
A container for features. 
Definition: FeatureMap.h:111
void setMaxY(CoordinateType const c)
Mutator for max_ coordinate of the larger point. 
Definition: DIntervalBase.h:285
Annotates an MSExperiment, FeatureMap or ConsensusMap with peptide identifications. 
Definition: IDMapper.h:62
const std::vector< PeptideIdentification > & getUnassignedPeptideIdentifications() const 
non-mutable access to the unassigned peptide identifications 
Definition: FeatureMap.h:428
Measure
Definition: IDMapper.h:66
A container for consensus elements. 
Definition: ConsensusMap.h:60
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference. 
Definition: Types.h:151
CoordinateType getRT() const 
Returns the RT coordinate (index 0) 
Definition: Peak2D.h:203
#define LOG_WARN
Macro if a warning, a piece of information which should be read by the user, should be logged...
Definition: LogStream.h:451
const std::vector< DataProcessing > & getDataProcessing() const 
returns a const reference to the description of the applied data processing 
Definition: FeatureMap.h:446
DoubleReal mz_tolerance_
Allowed m/z deviation. 
Definition: IDMapper.h:383
const std::vector< ConvexHull2D > & getConvexHulls() const 
Non-mutable access to the convex hulls. 
bool ignore_charge_
Ignore charge states during matching? 
Definition: IDMapper.h:387
Base::iterator Iterator
Definition: FeatureMap.h:154
An LC-MS feature. 
Definition: Feature.h:66
Representation of a mass spectrometry experiment. 
Definition: MSExperiment.h:68
PositionType const & minPosition() const 
Accessor to minimum position. 
Definition: DIntervalBase.h:121
size_t Size
Size type e.g. used as variable which can hold result of size() 
Definition: Types.h:144
bool empty() const 
Definition: MSExperiment.h:127
void setMinX(CoordinateType const c)
Mutator for min_ coordinate of the smaller point. 
Definition: DIntervalBase.h:264
Measure measure_
Measure used for m/z. 
Definition: IDMapper.h:385
PositionType const & maxPosition() const 
Accessor to maximum position. 
Definition: DIntervalBase.h:127
A base class for all classes handling default parameters. 
Definition: DefaultParamHandler.h:90
A D-dimensional bounding box. 
Definition: DBoundingBox.h:51
DoubleReal rt_tolerance_
Allowed RT deviation. 
Definition: IDMapper.h:381
void annotate(MSExperiment< PeakType > &map, const std::vector< PeptideIdentification > &ids, const std::vector< ProteinIdentification > &protein_ids)
Mapping method for peak maps. 
Definition: IDMapper.h:90
DoubleReal list. 
Definition: DoubleList.h:56
Represents the peptide hits for a spectrum. 
Definition: PeptideIdentification.h:63
Int list. 
Definition: IntList.h:56