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

Method writeUserParam_

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

Source from the content-addressed store, hash-verified

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 {
3491 std::vector<String> cvParams;
3492 std::vector<String> userParams;
3493
3494 std::vector<String> keys;
3495 meta.getKeys(keys);
3496
3497 for (std::vector<String>::iterator key = keys.begin(); key != keys.end(); ++key)
3498 {
3499 if (exclude.count(*key)) continue; // skip excluded entries
3500
3501 // special treatment of GO and BTO terms
3502 // <cvParam cvRef="BTO" accession="BTO:0000199" name="cardiac muscle"/>
3503
3504 if (*key == "GO cellular component" || *key == "brenda source tissue")
3505 {
3506 // the CVTerm info is in the meta value
3507 const ControlledVocabulary::CVTerm* c = cv_.checkAndGetTermByName(meta.getMetaValue(*key));
3508
3509 if (c != nullptr)
3510 {
3511 // TODO: validate CV, we currently cannot do this as the relations in the BTO and GO are not captured by our CV impl
3512 cvParams.push_back(writeCV_(*c, DataValue::EMPTY));
3513 }
3514 }
3515 else
3516 {
3517 bool writtenAsCVTerm = false;
3518 const ControlledVocabulary::CVTerm* c = cv_.checkAndGetTermByName(*key);
3519 if (c != nullptr)
3520 {
3521 if (validateCV_(*c, path, validator))
3522 {
3523 // write CV
3524 cvParams.push_back(writeCV_(*c, meta.getMetaValue(*key)));
3525 writtenAsCVTerm = true;
3526 }
3527 }
3528
3529 // if we could not write it as CVTerm we will store it at least as userParam
3530 if (!writtenAsCVTerm)
3531 {
3532 String userParam = "<userParam name=\"" + *key + "\" type=\"";
3533
3534 const DataValue& d = meta.getMetaValue(*key);
3535 //determine type
3536 if (d.valueType() == DataValue::INT_VALUE)
3537 {
3538 userParam += "xsd:integer";
3539 }
3540 else if (d.valueType() == DataValue::DOUBLE_VALUE)
3541 {
3542 userParam += "xsd:double";
3543 }
3544 else //string or lists are converted to string
3545 {
3546 userParam += "xsd:string";

Callers

nothing calls this directly

Calls 13

countMethod · 0.80
checkAndGetTermByNameMethod · 0.80
getMetaValueMethod · 0.80
hasUnitMethod · 0.80
getUnitMethod · 0.80
prefixMethod · 0.80
writeXMLEscapeFunction · 0.50
StringClass · 0.50
getKeysMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected