| 168 | |
| 169 | |
| 170 | void PercolatorOutfile::load(const String& filename, |
| 171 | ProteinIdentification& proteins, |
| 172 | vector<PeptideIdentification>& peptides, |
| 173 | SpectrumMetaDataLookup& lookup, |
| 174 | enum ScoreType output_score) |
| 175 | { |
| 176 | SpectrumMetaDataLookup::MetaDataFlags lookup_flags = |
| 177 | (SpectrumMetaDataLookup::MDF_RT | |
| 178 | SpectrumMetaDataLookup::MDF_PRECURSORMZ | |
| 179 | SpectrumMetaDataLookup::MDF_PRECURSORCHARGE); |
| 180 | |
| 181 | if (lookup.reference_formats.empty()) |
| 182 | { |
| 183 | // MS-GF+ Percolator (mzid?) format: |
| 184 | lookup.addReferenceFormat(R"(_SII_(?<INDEX1>\d+)_\d+_\d+_(?<CHARGE>\d+)_\d+)"); |
| 185 | // Mascot Percolator format (RT may be missing, e.g. for searches via |
| 186 | // ProteomeDiscoverer): |
| 187 | lookup.addReferenceFormat(R"(spectrum:[^;]+[(scans:)(scan=)(spectrum=)](?<INDEX0>\d+)[^;]+;rt:(?<RT>\d*(\.\d+)?);mz:(?<MZ>\d+(\.\d+)?);charge:(?<CHARGE>-?\d+))"); |
| 188 | // X! Tandem Percolator format: |
| 189 | lookup.addReferenceFormat(R"(_(?<INDEX0>\d+)_(?<CHARGE>\d+)_\d+$)"); |
| 190 | } |
| 191 | |
| 192 | vector<String> items; |
| 193 | CsvFile source(filename, '\t'); |
| 194 | source.getRow(0, items); |
| 195 | String header = ListUtils::concatenate<String>(items, '\t'); |
| 196 | if (header != |
| 197 | "PSMId\tscore\tq-value\tposterior_error_prob\tpeptide\tproteinIds") |
| 198 | { |
| 199 | throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, |
| 200 | header, "Not a valid header for Percolator (PSM level) output"); |
| 201 | } |
| 202 | |
| 203 | set<String> accessions; |
| 204 | Size no_charge = 0, no_rt = 0, no_mz = 0; // counters for missing data |
| 205 | peptides.clear(); |
| 206 | |
| 207 | for (Size row = 1; row < source.rowCount(); ++row) |
| 208 | { |
| 209 | source.getRow(row, items); |
| 210 | |
| 211 | SpectrumMetaDataLookup::SpectrumMetaData meta_data; |
| 212 | try |
| 213 | { |
| 214 | lookup.getSpectrumMetaData(items[0], meta_data, lookup_flags); |
| 215 | } |
| 216 | catch (...) |
| 217 | { |
| 218 | String msg = "Error: Could not extract data for spectrum reference '" + |
| 219 | items[0] + "' from row " + String(row); |
| 220 | OPENMS_LOG_ERROR << msg << endl; |
| 221 | } |
| 222 | |
| 223 | PeptideHit hit; |
| 224 | if (meta_data.precursor_charge != 0) |
| 225 | { |
| 226 | hit.setCharge(meta_data.precursor_charge); |
| 227 | } |
nothing calls this directly
no test coverage detected