86 if (data.empty())
return;
87 use_feature_rt_ = param_.getValue(
"use_feature_rt").toBool();
89 bool sorted = getRetentionTimes_(data, rt_data);
90 computeMedians_(rt_data, reference_, sorted);
91 if (reference_.empty())
93 throw Exception::MissingInformation(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Could not extract retention time information from the reference file");
106 template <
typename DataType>
107 void align(std::vector<DataType>& data,
108 std::vector<TransformationDescription>& transformations,
109 Int reference_index = -1)
111 checkParameters_(data.size());
112 startProgress(0, 3,
"aligning maps");
114 reference_index_ = reference_index;
116 bool use_internal_reference = (reference_index >= 0);
117 if (use_internal_reference)
119 if (reference_index >=
static_cast<Int>(data.size()))
122 OPENMS_PRETTY_FUNCTION, reference_index,
125 setReference(data[reference_index]);
129 std::vector<SeqToList> rt_data(data.size() - use_internal_reference);
130 bool all_sorted =
true;
131 for (
Size i = 0, j = 0; i < data.size(); ++i)
133 if ((reference_index >= 0) && (i ==
Size(reference_index)))
137 all_sorted &= getRetentionTimes_(data[i], rt_data[j++]);
141 computeTransformations_(rt_data, transformations, all_sorted);
175 bool (*better_) (double,double) = [](
double,
double) {
return true;};
187 bool sorted =
false);
224 template <
typename MapType>
229 better_ = [](double, double)
232 else if (features[0].getPeptideIdentifications()[0].isHigherScoreBetter())
234 better_ = [](
double a,
double b)
239 better_ = [](
double a,
double b)
244 feat_it != features.
end(); ++feat_it)
250 double rt_distance = std::numeric_limits<double>::max();
251 bool any_hit =
false;
252 for (std::vector<PeptideIdentification>::iterator pep_it =
253 feat_it->getPeptideIdentifications().begin(); pep_it !=
254 feat_it->getPeptideIdentifications().end(); ++pep_it)
256 if (!pep_it->getHits().empty())
259 double current_distance = fabs(pep_it->getRT() -
261 if (current_distance < rt_distance)
264 if (better_(pep_it->getHits()[0].getScore(), min_score_))
266 sequence = pep_it->getHits()[0].getSequence().toString();
267 rt_distance = current_distance;
273 if (any_hit) rt_data[sequence].push_back(feat_it->getRT());
277 getRetentionTimes_(feat_it->getPeptideIdentifications(), rt_data);
281 if (!use_feature_rt_ &&
282 param_.getValue(
"use_unassigned_peptides").toBool())
284 getRetentionTimes_(features.getUnassignedPeptideIdentifications(),
290 for (SeqToList::iterator rt_it = rt_data.begin(); rt_it != rt_data.end();
294 sort(rt_values.begin(), rt_values.end());
295 DoubleList::iterator it = unique(rt_values.begin(), rt_values.end());
296 rt_values.resize(it - rt_values.begin());
309 std::vector<TransformationDescription>&
310 transforms,
bool sorted =
false);
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
Int overflow exception.
Definition: Exception.h:248
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:80
Iterator begin()
Definition: MSExperiment.h:157
std::vector< SpectrumType >::iterator Iterator
Mutable iterator.
Definition: MSExperiment.h:111
Iterator end()
Definition: MSExperiment.h:167
A map alignment algorithm based on peptide identifications from MS2 spectra.
Definition: MapAlignmentAlgorithmIdentification.h:74
void computeTransformations_(std::vector< SeqToList > &rt_data, std::vector< TransformationDescription > &transforms, bool sorted=false)
Compute retention time transformations from RT data grouped by peptide sequence.
bool getRetentionTimes_(std::vector< PeptideIdentification > &peptides, SeqToList &rt_data)
Collect retention time data ("RT" MetaInfo) from peptide IDs.
bool getRetentionTimes_(PeakMap &experiment, SeqToList &rt_data)
Collect retention time data ("RT" MetaInfo) from peptide IDs annotated to spectra.
~MapAlignmentAlgorithmIdentification() override
Destructor.
std::map< String, double > SeqToValue
Type to store one representative retention time per peptide sequence.
Definition: MapAlignmentAlgorithmIdentification.h:154
void checkParameters_(const Size runs)
Check that parameter values are valid.
void getReference_()
Get reference retention times.
Int reference_index_
Index of input file to use as reference (if any)
Definition: MapAlignmentAlgorithmIdentification.h:157
void align(std::vector< DataType > &data, std::vector< TransformationDescription > &transformations, Int reference_index=-1)
Align feature maps, consensus maps, peak maps, or peptide identifications.
Definition: MapAlignmentAlgorithmIdentification.h:107
bool score_cutoff_
Actually use the above defined score_cutoff? Needed since it is hard to define a non-cutting score fo...
Definition: MapAlignmentAlgorithmIdentification.h:172
bool use_feature_rt_
Use feature RT instead of RT from best peptide ID in the feature.
Definition: MapAlignmentAlgorithmIdentification.h:166
SeqToValue reference_
Reference retention times (per peptide sequence)
Definition: MapAlignmentAlgorithmIdentification.h:160
double min_score_
Minimum score to reach for a peptide to be considered.
Definition: MapAlignmentAlgorithmIdentification.h:169
Size min_run_occur_
Minimum number of runs a peptide must occur in.
Definition: MapAlignmentAlgorithmIdentification.h:163
std::map< String, DoubleList > SeqToList
Type to store retention times given for individual peptide sequences.
Definition: MapAlignmentAlgorithmIdentification.h:151
MapAlignmentAlgorithmIdentification & operator=(const MapAlignmentAlgorithmIdentification &)
Assignment operator intentionally not implemented -> private.
MapAlignmentAlgorithmIdentification()
Default constructor.
void setReference(DataType &data)
Definition: MapAlignmentAlgorithmIdentification.h:83
void computeMedians_(SeqToList &rt_data, SeqToValue &medians, bool sorted=false)
Compute the median retention time for each peptide sequence.
MapAlignmentAlgorithmIdentification(const MapAlignmentAlgorithmIdentification &)
Copy constructor intentionally not implemented -> private.
bool getRetentionTimes_(MapType &features, SeqToList &rt_data)
Collect retention time data ("RT" MetaInfo) from peptide IDs contained in feature maps or consensus m...
Definition: MapAlignmentAlgorithmIdentification.h:225
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
A more convenient string class.
Definition: String.h:61
int Int
Signed integer type.
Definition: Types.h:102
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
std::vector< double > DoubleList
Vector of double precision real types.
Definition: ListUtils.h:62
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47