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

Method writeCV_

src/openms/source/FORMAT/HANDLERS/MzMLHandler.cpp:3452–3487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3450 }
3451
3452 String MzMLHandler::writeCV_(const ControlledVocabulary::CVTerm& c, const DataValue& metaValue) const
3453 {
3454 String cvTerm = "<cvParam cvRef=\"" + c.id.prefix(':') + "\" accession=\"" + c.id + "\" name=\"" + c.name;
3455 if (!metaValue.isEmpty())
3456 {
3457 cvTerm += "\" value=\"" + writeXMLEscape(metaValue.toString());
3458 if (metaValue.hasUnit())
3459 {
3460 // unitAccession="UO:0000021" unitName="gram" unitCvRef="UO"
3461 //
3462 // We need to identify the correct CV term for the *unit* by
3463 // retrieving the identifier and looking up the term within the
3464 // correct ontology in our cv_ object.
3465 char s[8];
3466 snprintf(s, sizeof(s), "%07d", metaValue.getUnit()); // all CV use 7 digit identifiers padded with zeros
3467 String unitstring = String(s);
3468 if (metaValue.getUnitType() == DataValue::UnitType::UNIT_ONTOLOGY)
3469 {
3470 unitstring = "UO:" + unitstring;
3471 }
3472 else if (metaValue.getUnitType() == DataValue::UnitType::MS_ONTOLOGY)
3473 {
3474 unitstring = "MS:" + unitstring;
3475 }
3476 else
3477 {
3478 warning(LOAD, String("Unhandled unit ontology '") );
3479 }
3480
3481 ControlledVocabulary::CVTerm unit = cv_.getTerm(unitstring);
3482 cvTerm += "\" unitAccession=\"" + unit.id + "\" unitName=\"" + unit.name + "\" unitCvRef=\"" + unit.id.prefix(2);
3483 }
3484 }
3485 cvTerm += "\"/>\n";
3486 return cvTerm;
3487 }
3488
3489 void MzMLHandler::writeUserParam_(std::ostream& os, const MetaInfoInterface& meta, UInt indent, const String& path, const Internal::MzMLValidator& validator, const std::set<String>& exclude) const
3490 {

Callers

nothing calls this directly

Calls 7

prefixMethod · 0.80
hasUnitMethod · 0.80
getUnitMethod · 0.80
writeXMLEscapeFunction · 0.50
StringClass · 0.50
isEmptyMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected