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

Method writeBinaryFloatDataArray_

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

Source from the content-addressed store, hash-verified

5506 }
5507
5508 void MzMLHandler::writeBinaryFloatDataArray_(std::ostream& os,
5509 const PeakFileOptions& pf_options_,
5510 const OpenMS::DataArrays::FloatDataArray& array,
5511 const Size spec_chrom_idx,
5512 const Size array_idx,
5513 bool isSpectrum,
5514 const Internal::MzMLValidator& validator)
5515 {
5516 String encoded_string;
5517 bool no_numpress = true;
5518 std::vector<float> data_to_encode = array;
5519 MetaInfoDescription array_metadata = array;
5520 // bool is32bit = true;
5521
5522 // Compute the array-type and the compression CV term
5523 String cv_term_type;
5524 String compression_term;
5525 String compression_term_no_np;
5526 MSNumpressCoder::NumpressConfig np_config;
5527 // if (array_type == "float_data")
5528 {
5529 // Try and identify whether we have a CV term for this particular array (otherwise write the array name itself)
5530 ControlledVocabulary::CVTerm bi_term = getChildWithName_("MS:1000513", array.getName()); // name: binary data array
5531
5532 String unit_cv_term = "";
5533 if (array_metadata.metaValueExists("unit_accession"))
5534 {
5535 ControlledVocabulary::CVTerm unit = cv_.getTerm(array_metadata.getMetaValue("unit_accession"));
5536 unit_cv_term = " unitAccession=\"" + unit.id + "\" unitName=\"" + unit.name + "\" unitCvRef=\"" + unit.id.prefix(2) + "\"";
5537 array_metadata.removeMetaValue("unit_accession"); // prevent this from being written as userParam
5538 }
5539
5540 if (!bi_term.id.empty())
5541 {
5542 cv_term_type = "\t\t\t\t\t\t<cvParam cvRef=\"MS\" accession=\"" + bi_term.id + "\" name=\"" + bi_term.name + "\"" + unit_cv_term + " />\n";
5543 }
5544 else
5545 {
5546 cv_term_type = "\t\t\t\t\t\t<cvParam cvRef=\"MS\" accession=\"MS:1000786\" name=\"non-standard data array\" value=\"" +
5547 array.getName() + "\"" + unit_cv_term + " />\n";
5548 }
5549
5550 compression_term = MzMLHandlerHelper::getCompressionTerm_(pf_options_, pf_options_.getNumpressConfigurationFloatDataArray(), "\t\t\t\t\t\t", true);
5551 compression_term_no_np = MzMLHandlerHelper::getCompressionTerm_(pf_options_, pf_options_.getNumpressConfigurationFloatDataArray(), "\t\t\t\t\t\t", false);
5552 np_config = pf_options_.getNumpressConfigurationFloatDataArray();
5553 }
5554
5555 String data_processing_ref_string = "";
5556 if (!array.getDataProcessing().empty())
5557 {
5558 data_processing_ref_string = String("dataProcessingRef=\"dp_sp_") + spec_chrom_idx + "_bi_" + array_idx + "\"";
5559 }
5560
5561 // Try numpress encoding (if it is enabled) and fall back to regular encoding if it fails
5562 if (np_config.np_compression != MSNumpressCoder::NONE)
5563 {
5564 MSNumpressCoder().encodeNP(data_to_encode, encoded_string, pf_options_.getCompression(), np_config);
5565 if (!encoded_string.empty())

Callers

nothing calls this directly

Calls 14

MSNumpressCoderFunction · 0.85
encodeFunction · 0.85
metaValueExistsMethod · 0.80
getMetaValueMethod · 0.80
prefixMethod · 0.80
encodeNPMethod · 0.80
getCompressionMethod · 0.80
StringClass · 0.50
getNameMethod · 0.45
removeMetaValueMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected