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

Method handlePTMs

src/openms/source/FORMAT/InspectInfile.cpp:173–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171 }
172
173 void InspectInfile::handlePTMs(const String& modification_line, const String& modifications_filename, const bool monoisotopic)
174 {
175 PTMname_residues_mass_type_.clear();
176 // to store the information about modifications from the ptm xml file
177 std::map<String, pair<String, String> > ptm_informations;
178 if (!modification_line.empty()) // if modifications are used look whether whether composition and residues (and type and name) is given, the name (type) is used (then the modifications file is needed) or only the mass and residues (and type and name) is given
179 {
180 vector<String> modifications, mod_parts;
181 modification_line.split(':', modifications); // get the single modifications
182 if (modifications.empty())
183 {
184 modifications.push_back(modification_line);
185 }
186 // to get masses from a formula
187 EmpiricalFormula add_formula, substract_formula;
188
189 String types = "OPT#FIX#";
190 String name, residues, mass, type;
191
192 // 0 - mass; 1 - composition; 2 - ptm name
193 Int mass_or_composition_or_name(-1);
194
195 for (vector<String>::const_iterator mod_i = modifications.begin(); mod_i != modifications.end(); ++mod_i)
196 {
197 if (mod_i->empty())
198 {
199 continue;
200 }
201 // clear the formulae
202 add_formula = substract_formula = EmpiricalFormula();
203 name = residues = mass = type = "";
204
205 // get the single parts of the modification string
206 mod_i->split(',', mod_parts);
207 if (mod_parts.empty())
208 mod_parts.push_back(*mod_i);
209 mass_or_composition_or_name = -1;
210
211 // check whether the first part is a mass, composition or name
212
213 // check whether it is a mass
214 try
215 {
216 mass = mod_parts.front();
217 // to check whether the first part is a mass, it is converted into a float and then back into a string and compared to the given string
218 // remove + signs because they don't appear in a float
219 if (mass.hasPrefix("+"))
220 {
221 mass.erase(0, 1);
222 }
223 if (mass.hasSuffix("+"))
224 {
225 mass.erase(mass.length() - 1, 1);
226 }
227 if (mass.hasSuffix("-")) // a - sign at the end will not be converted
228 {
229 mass.erase(mass.length() - 1, 1);
230 mass.insert(0, "-");

Callers 2

Calls 15

frontMethod · 0.80
toFloatMethod · 0.80
substrMethod · 0.80
toUpperMethod · 0.80
EmpiricalFormulaFunction · 0.50
StringClass · 0.50
clearMethod · 0.45
emptyMethod · 0.45
splitMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected