30 template <
typename MapType>
31 concept IsFCMap = std::same_as<MapType, OpenMS::FeatureMap> || std::same_as<MapType, OpenMS::ConsensusMap>;
72 template <
typename DataType>
void setReference(
const DataType& data)
75 if (data.empty())
return;
78 use_feature_rt_ = param_.getValue(
"use_feature_rt").toBool();
79 score_cutoff_ = param_.getValue(
"score_cutoff").toBool();
80 score_type_ = StringUtils::toStr(param_.getValue(
"score_type"));
81 bool sorted = getRetentionTimes_(data, rt_data);
82 computeMedians_(rt_data, reference_, sorted);
84 if (reference_.empty())
86 throw Exception::MissingInformation(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Could not extract retention time information from the reference file");
99 template <
typename DataType>
100 void align(
const std::vector<DataType>& data,
101 std::vector<TransformationDescription>& transformations,
102 Int reference_index = -1)
105 bool use_internal_reference = (reference_index >= 0);
110 if (use_internal_reference) reference_.clear();
112 checkParameters_(data.size());
113 startProgress(0, 3,
"aligning maps");
115 reference_index_ = reference_index;
116 if (use_internal_reference)
118 if (reference_index >=
Int(data.size()))
121 OPENMS_PRETTY_FUNCTION,
122 reference_index, data.size());
124 setReference(data[reference_index]);
128 std::vector<SeqToList> rt_data(data.size() - use_internal_reference);
129 bool all_sorted =
true;
130 for (
Size i = 0, j = 0; i < data.size(); ++i)
132 if ((reference_index >= 0) && (i ==
Size(reference_index)))
136 all_sorted &= getRetentionTimes_(data[i], rt_data[j++]);
140 if (!use_internal_reference && reference_.empty())
142 alignToAutoReference_(rt_data, transformations, all_sorted);
146 computeTransformations_(rt_data, transformations, all_sorted);
149 if (reference_index_ >= 0) reference_.clear();
174 bool use_feature_rt_{};
180 bool consensus_reference_{};
183 Size auto_reference_min_points_{};
189 bool score_cutoff_{};
195 bool (*better_) (double, double) = [](
double,
double) {
return true;};
207 bool sorted =
false);
250 better_ = [](double, double)
253 else if (features[0].getPeptideIdentifications()[0].isHigherScoreBetter())
255 better_ = [](
double a,
double b)
260 better_ = [](
double a,
double b)
264 for (
auto feat_it = features.cbegin(); feat_it != features.cend(); ++feat_it)
269 std::string sequence;
270 double rt_distance = std::numeric_limits<double>::max();
271 bool any_hit =
false;
273 feat_it->getPeptideIdentifications().begin(); pep_it !=
274 feat_it->getPeptideIdentifications().end(); ++pep_it)
276 if (!pep_it->getHits().empty())
279 double current_distance = fabs(pep_it->getRT() -
281 if (current_distance < rt_distance)
283 const PeptideHit* best_hit = getBestScoringHit(pep_it->getHits(), pep_it->isHigherScoreBetter());
284 if (best_hit && better_(best_hit->
getScore(), min_score_))
287 rt_distance = current_distance;
293 if (any_hit) rt_data[sequence].push_back(feat_it->getRT());
297 getRetentionTimes_(feat_it->getPeptideIdentifications(), rt_data);
301 if (!use_feature_rt_ &&
302 param_.getValue(
"use_unassigned_peptides").toBool())
304 getRetentionTimes_(features.getUnassignedPeptideIdentifications(),
310 for (SeqToList::iterator rt_it = rt_data.begin(); rt_it != rt_data.end();
314 sort(rt_values.begin(), rt_values.end());
315 DoubleList::iterator it = unique(rt_values.begin(), rt_values.end());
316 rt_values.resize(it - rt_values.begin());
330 std::vector<TransformationDescription>&
331 transforms,
bool sorted =
false,
bool verbose =
true);
357 std::vector<TransformationDescription>& transforms,
372 std::vector<TransformationDescription>& transforms,
373 bool sorted,
bool verbose);
std::string toString() const
returns the peptide as string with modifications embedded in brackets
A base class for all classes handling default parameters.
Definition DefaultParamHandler.h:66
Int overflow exception.
Definition Exception.h:211
typename VecMember::const_iterator const_iterator
Definition ExposedVector.h:69
Definition IdentificationData.h:87
A map alignment algorithm based on peptide identifications from MS2 spectra.
Definition MapAlignmentAlgorithmIdentification.h:63
bool getRetentionTimes_(const PeptideIdentificationList &peptides, SeqToList &rt_data)
Collect retention time data from peptide IDs.
const PeptideHit * getBestScoringHit(const std::vector< PeptideHit > &hits, const bool is_higher_score_better)
Get the best-scoring PeptideHit from a list of hits.
void setReference(const DataType &data)
Definition MapAlignmentAlgorithmIdentification.h:72
bool getRetentionTimes_(const IdentificationData &id_data, SeqToList &rt_data)
Collect retention time data from spectrum matches.
~MapAlignmentAlgorithmIdentification() override
Destructor.
void checkParameters_(const Size runs)
Check that parameter values are valid.
void getReference_()
Get reference retention times.
bool getRetentionTimes_(const IsFCMap auto &features, SeqToList &rt_data)
Collect retention time data from peptide IDs contained in feature maps or consensus maps.
Definition MapAlignmentAlgorithmIdentification.h:246
Int reference_index_
Index of input file to use as reference (if any)
Definition MapAlignmentAlgorithmIdentification.h:165
MapAlignmentAlgorithmIdentification & operator=(const MapAlignmentAlgorithmIdentification &)
Assignment operator intentionally not implemented -> private.
std::map< std::string, double > SeqToValue
Type to store one representative retention time per peptide sequence.
Definition MapAlignmentAlgorithmIdentification.h:162
SeqToValue reference_
Reference retention times (per peptide sequence)
Definition MapAlignmentAlgorithmIdentification.h:168
double min_score_
Minimum score to reach for a peptide to be considered.
Definition MapAlignmentAlgorithmIdentification.h:186
std::map< std::string, DoubleList > SeqToList
Type to store retention times given for individual peptide sequences.
Definition MapAlignmentAlgorithmIdentification.h:159
Size min_run_occur_
Minimum number of runs a peptide must occur in.
Definition MapAlignmentAlgorithmIdentification.h:171
void computeTransformations_(std::vector< SeqToList > &rt_data, std::vector< TransformationDescription > &transforms, bool sorted=false, bool verbose=true)
Compute retention time transformations from RT data grouped by peptide sequence.
std::string score_type_
Score type to use for filtering.
Definition MapAlignmentAlgorithmIdentification.h:192
MapAlignmentAlgorithmIdentification()
Default constructor.
Int selectReference_(const std::vector< SeqToList > &rt_data) const
Choose the input map that shares the most identified sequences with every other map as the reference.
IdentificationData::ScoreTypeRef handleIdDataScoreType_(const IdentificationData &id_data)
Helper function to find/define the score type for processing IdentificationData.
void align(const std::vector< DataType > &data, std::vector< TransformationDescription > &transformations, Int reference_index=-1)
Align feature maps, consensus maps, or peptide identifications.
Definition MapAlignmentAlgorithmIdentification.h:100
void computeMedians_(SeqToList &rt_data, SeqToValue &medians, bool sorted=false)
Compute the median retention time for each peptide sequence.
void alignToInput_(std::vector< SeqToList > &rt_data, Size index, std::vector< TransformationDescription > &transforms, bool sorted, bool verbose)
Compute RT transformations with one of the input maps as the reference.
MapAlignmentAlgorithmIdentification(const MapAlignmentAlgorithmIdentification &)
Copy constructor intentionally not implemented -> private.
void alignToAutoReference_(std::vector< SeqToList > &rt_data, std::vector< TransformationDescription > &transforms, bool sorted)
Compute RT transformations without a given reference, as parameter auto_reference asks.
Represents a single spectrum match (candidate) for a specific tandem mass spectrum (MS/MS).
Definition PeptideHit.h:52
double getScore() const
returns the PSM score
const AASequence & getSequence() const
returns the peptide sequence
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
Definition MapAlignmentAlgorithmIdentification.h:31
int Int
Signed integer type.
Definition Types.h:72
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
std::vector< double > DoubleList
Vector of double precision real types.
Definition TypeAliases.h:31
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Wrapper that adds operator< to iterators, so they can be used as (part of) keys in maps/sets or multi...
Definition MetaData.h:20