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

Method load

src/openms/source/FORMAT/MSPFile.cpp:52–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 MSPFile::~MSPFile() = default;
51
52 void MSPFile::load(const String & filename, vector<PeptideIdentification> & ids, PeakMap & exp)
53 {
54 if (!File::exists(filename))
55 {
56 throw Exception::FileNotFound(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename);
57 }
58 if (!File::readable(filename))
59 {
60 throw Exception::FileNotReadable(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename);
61 }
62
63 // groups everything inside the shortest pair of parentheses
64 const std::regex rex(R"(\((.*?)\))");
65 // matches 2+ whitespaces or tabs or returns " ", "\t", "\r"
66 // Note: this is a hack because one of the encountered formats has single whitespaces in quotes.
67 // TODO choose a format during construction of the class. If we actually knew how to call and define them.
68 const std::regex ws_rex(R"(\s{2,}|\t|\r)");
69
70 exp.reset();
71
72 //set DocumentIdentifier
73 exp.setLoadedFileType(filename);
74 exp.setLoadedFilePath(filename);
75
76 String line;
77 ifstream is(filename.c_str());
78
79 std::map<String, String> modname_to_unimod;
80 modname_to_unimod["Pyro-glu"] = "Gln->pyro-Glu";
81 modname_to_unimod["CAM"] = "Carbamidomethyl";
82 modname_to_unimod["AB_old_ICATd8"] = "ICAT-D:2H(8)";
83 modname_to_unimod["AB_old_ICATd0"] = "ICAT-D";
84
85 bool parse_headers(param_.getValue("parse_headers").toBool());
86 bool parse_peakinfo(param_.getValue("parse_peakinfo").toBool());
87 bool parse_firstpeakinfo_only(param_.getValue("parse_firstpeakinfo_only").toBool());
88 std::string instrument((std::string)param_.getValue("instrument"));
89 bool inst_type_correct(true);
90 [[maybe_unused]] bool spectrast_format(false); // TODO: implement usage
91 Size spectrum_number = 0;
92
93 PeakSpectrum spec;
94
95 // line number counter
96 Size line_number = 0;
97
98 while (getline(is, line))
99 {
100 ++line_number;
101
102 if (line.hasPrefix("Name:"))
103 {
104 vector<String> split, split2;
105 line.split(' ', split);
106 split[1].split('/', split2);
107 String peptide = split2[0];
108 // in newer NIST versions, the charge is followed by the modification(s) e.g. "_1(0,A,Acetyl)"
109 vector<String> split3;

Callers 15

main_Method · 0.45
main_Method · 0.45
main_Method · 0.45
main_Method · 0.45
main_Method · 0.45
main_Method · 0.45
filterByBlackListMethod · 0.45
main_Method · 0.45
main_Method · 0.45
main_Method · 0.45
loadAndCleanupIDFile_Method · 0.45

Calls 15

setLoadedFileTypeMethod · 0.80
setLoadedFilePathMethod · 0.80
toIntMethod · 0.80
backMethod · 0.80
getPrecursorsMethod · 0.80
toDoubleMethod · 0.80
emplace_backMethod · 0.80
prefixMethod · 0.80
cbeginMethod · 0.80
cendMethod · 0.80
getSequenceMethod · 0.80

Tested by 15

main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36
main_Method · 0.36