| 5429 | |
| 5430 | template <typename DataType> |
| 5431 | void MzMLHandler::writeBinaryDataArray_(std::ostream& os, |
| 5432 | const PeakFileOptions& pf_options_, |
| 5433 | std::vector<DataType>& data_to_encode, |
| 5434 | bool is32bit, |
| 5435 | String array_type) |
| 5436 | { |
| 5437 | String encoded_string; |
| 5438 | bool no_numpress = true; |
| 5439 | |
| 5440 | // Compute the array-type and the compression CV term |
| 5441 | String cv_term_type; |
| 5442 | String compression_term; |
| 5443 | String compression_term_no_np; |
| 5444 | MSNumpressCoder::NumpressConfig np_config; |
| 5445 | if (array_type == "mz") |
| 5446 | { |
| 5447 | cv_term_type = "\t\t\t\t\t\t<cvParam cvRef=\"MS\" accession=\"MS:1000514\" name=\"m/z array\" unitAccession=\"MS:1000040\" unitName=\"m/z\" unitCvRef=\"MS\" />\n"; |
| 5448 | compression_term = MzMLHandlerHelper::getCompressionTerm_(pf_options_, pf_options_.getNumpressConfigurationMassTime(), "\t\t\t\t\t\t", true); |
| 5449 | compression_term_no_np = MzMLHandlerHelper::getCompressionTerm_(pf_options_, pf_options_.getNumpressConfigurationMassTime(), "\t\t\t\t\t\t", false); |
| 5450 | np_config = pf_options_.getNumpressConfigurationMassTime(); |
| 5451 | } |
| 5452 | else if (array_type == "time") |
| 5453 | { |
| 5454 | cv_term_type = "\t\t\t\t\t\t<cvParam cvRef=\"MS\" accession=\"MS:1000595\" name=\"time array\" unitAccession=\"UO:0000010\" unitName=\"second\" unitCvRef=\"MS\" />\n"; |
| 5455 | compression_term = MzMLHandlerHelper::getCompressionTerm_(pf_options_, pf_options_.getNumpressConfigurationMassTime(), "\t\t\t\t\t\t", true); |
| 5456 | compression_term_no_np = MzMLHandlerHelper::getCompressionTerm_(pf_options_, pf_options_.getNumpressConfigurationMassTime(), "\t\t\t\t\t\t", false); |
| 5457 | np_config = pf_options_.getNumpressConfigurationMassTime(); |
| 5458 | } |
| 5459 | else if (array_type == "intensity") |
| 5460 | { |
| 5461 | cv_term_type = "\t\t\t\t\t\t<cvParam cvRef=\"MS\" accession=\"MS:1000515\" name=\"intensity array\" unitAccession=\"MS:1000131\" unitName=\"number of detector counts\" unitCvRef=\"MS\"/>\n"; |
| 5462 | compression_term = MzMLHandlerHelper::getCompressionTerm_(pf_options_, pf_options_.getNumpressConfigurationIntensity(), "\t\t\t\t\t\t", true); |
| 5463 | compression_term_no_np = MzMLHandlerHelper::getCompressionTerm_(pf_options_, pf_options_.getNumpressConfigurationIntensity(), "\t\t\t\t\t\t", false); |
| 5464 | np_config = pf_options_.getNumpressConfigurationIntensity(); |
| 5465 | } |
| 5466 | else |
| 5467 | { |
| 5468 | throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Unknown array type", array_type); |
| 5469 | } |
| 5470 | |
| 5471 | // Try numpress encoding (if it is enabled) and fall back to regular encoding if it fails |
| 5472 | if (np_config.np_compression != MSNumpressCoder::NONE) |
| 5473 | { |
| 5474 | MSNumpressCoder().encodeNP(data_to_encode, encoded_string, pf_options_.getCompression(), np_config); |
| 5475 | if (!encoded_string.empty()) |
| 5476 | { |
| 5477 | // numpress succeeded |
| 5478 | no_numpress = false; |
| 5479 | os << "\t\t\t\t\t<binaryDataArray encodedLength=\"" << encoded_string.size() << "\">\n"; |
| 5480 | os << cv_term_type; |
| 5481 | os << "\t\t\t\t\t\t<cvParam cvRef=\"MS\" accession=\"MS:1000523\" name=\"64-bit float\" />\n"; |
| 5482 | } |
| 5483 | } |
| 5484 | |
| 5485 | // Regular DataArray without numpress (either 32 or 64 bit encoded) |
| 5486 | if (is32bit && no_numpress) |
| 5487 | { |
| 5488 | compression_term = compression_term_no_np; // select the no-numpress term |
nothing calls this directly
no test coverage detected