49 static void augment(std::vector<PeptideIdentification>& pep_ids,
50 std::vector<std::string> positive_weights,
51 std::vector<std::string> negative_weights)
54 if (pep_ids.empty())
return;
56 if (pep_ids[0].getHits().empty())
return;
59 std::sort(positive_weights.begin(), positive_weights.end());
60 std::sort(negative_weights.begin(), negative_weights.end());
61 std::vector<std::string> v_intersection;
63 std::set_intersection(positive_weights.begin(), positive_weights.end(),
64 negative_weights.begin(), negative_weights.end(),
65 std::back_inserter(v_intersection));
67 if (!v_intersection.empty())
throw std::runtime_error(
"Positive and negative weights may not overlap.");
70 auto p_template = pep_ids[0].getHits()[0];
71 p_template.setScore(0);
72 std::vector<String> keys;
73 p_template.getKeys(keys);
74 p_template.setMetaValue(
"NuXL:augmented",
"true");
77 for (
const auto&
k : keys)
84 std::map<String, double> minima;
85 std::map<String, double> maxima;
87 for (
const auto&
k : positive_weights)
93 for (
const auto& pid : pep_ids)
95 for (
const auto& ph : pid.getHits())
97 for (
const auto&
k : positive_weights)
99 auto dv = ph.getMetaValue(
k);
102 if (minima[
k] > (
int)dv) minima[
k] = (
int)dv;
103 if (maxima[
k] < (
int)dv) maxima[
k] = (
int)dv;
107 if (minima[
k] > (
double)dv) minima[
k] = (
double)dv;
108 if (maxima[
k] < (
double)dv) maxima[
k] = (
double)dv;
116 for (
const auto& s : positive_weights)
119 p.setMetaValue(s, maxima[s] + 1000.0 * (maxima[s] - minima[s]));
120 std::vector<PeptideHit> phs;
125 pep_ids.push_back(pid);
130 for (
const auto& s : negative_weights)
133 p.setMetaValue(s, minima[s] - 1000.0 * (maxima[s] - minima[s]));
134 std::vector<PeptideHit> phs;
139 pep_ids.push_back(pid);
147 for (
auto& pid : pep_ids)
149 auto& phs = pid.getHits();
150 phs.erase(remove_if(phs.begin(), phs.end(), [](
const PeptideHit& ph){
return ph.metaValueExists(
"NuXL:augmented"); }), phs.end());
const double k
Definition: Constants.h:158
Definition: NuXLFeatureAugmentation.h:46
void setRT(double rt)
sets the RT of the MS2 spectrum where the identification occurred
const double c
Definition: Constants.h:214
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Representation of a peptide hit.
Definition: PeptideHit.h:55
void setHits(const std::vector< PeptideHit > &hits)
Sets the peptide hits.
integer value
Definition: DataValue.h:70
static void removeAugmented(std::vector< PeptideIdentification > &pep_ids)
Definition: NuXLFeatureAugmentation.h:144
static void augment(std::vector< PeptideIdentification > &pep_ids, std::vector< std::string > positive_weights, std::vector< std::string > negative_weights)
Definition: NuXLFeatureAugmentation.h:49
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:63
double value
Definition: DataValue.h:71