MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / load

Method load

src/openms/source/FORMAT/PercolatorInfile.cpp:59–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 }
58
59 vector<PeptideIdentification> PercolatorInfile::load(
60 const String& pin_file,
61 bool higher_score_better,
62 const String& score_name,
63 const StringList& extra_scores,
64 StringList& filenames,
65 String decoy_prefix)
66 {
67 CsvFile csv(pin_file, '\t');
68 StringList header;
69 //TODO DANGEROUS! Our CSV reader does not support comment lines!!
70 csv.getRow(0, header);
71
72 unordered_map<String, size_t> to_idx; // map column name to column index
73 {
74 int idx{};
75 for (const auto& h : header) { to_idx[h] = idx++; }
76 }
77
78 int file_name_column_index{-1};
79 if (auto it = std::find(header.begin(), header.end(), "FileName"); it != header.end())
80 {
81 file_name_column_index = it - header.begin();
82 }
83
84 // get column indices of extra scores
85 std::set<String> found_extra_scores; // additional (non-main) scores that should be stored in the PeptideHit, order important for comparable idXML
86 for (const String& s : extra_scores)
87 {
88 if (auto it = std::find(header.begin(), header.end(), s); it != header.end())
89 {
90 found_extra_scores.insert(s);
91 }
92 else
93 {
94 OPENMS_LOG_WARN << "Extra score: " << s << " not found in Percolator input file." << endl;
95 }
96 }
97
98 // charge columns are not standardized, so we check for the format and create hash to lookup column name to charge mapping
99 std::regex charge_one_hot_pattern("^charge\\d+$");
100 std::regex sage_one_hot_pattern("^z=\\d+$");
101 String charge_prefix;
102 unordered_map<String, int> col_name_to_charge;
103
104 // Special handling for sage: sage produces an additional column for PSMs outside of the "suggested" charge search range (e.g., charge 2-5).
105 // The reason is that sage searches always for the charge annotated in the spectrum raw file. Only if the annotation is missing it will search
106 // the suggested charge range.
107 bool found_sage_otherz_charge_column{false};
108 for (const String& c : header)
109 {
110 if (std::regex_match(c, charge_one_hot_pattern))
111 {
112 col_name_to_charge[c] = c.substr(6).toInt();
113 charge_prefix = "charge";
114 }
115 else if (std::regex_match(c, sage_one_hot_pattern))
116 {

Callers

nothing calls this directly

Calls 15

getRowMethod · 0.80
toIntMethod · 0.80
substrMethod · 0.80
rowCountMethod · 0.80
atMethod · 0.80
backMethod · 0.80
toDoubleMethod · 0.80
setSpectrumReferenceMethod · 0.80
countMethod · 0.80
addPeptideEvidenceMethod · 0.80
StringClass · 0.50
PeptideEvidenceFunction · 0.50

Tested by

no test coverage detected