| 136 | } |
| 137 | |
| 138 | void MzMLHandlerHelper::decodeBase64Arrays(std::vector<BinaryData>& data, const bool skipXMLCheck) |
| 139 | { |
| 140 | // decode all base64 arrays |
| 141 | for (auto& bindata : data) |
| 142 | { |
| 143 | // remove whitespaces from binary data |
| 144 | // this should not be necessary, but line breaks inside the base64 data are unfortunately no exception |
| 145 | if (!skipXMLCheck) |
| 146 | { |
| 147 | bindata.base64.removeWhitespaces(); |
| 148 | } |
| 149 | |
| 150 | // Catch proteowizard invalid conversion where |
| 151 | // (i) no data type is set |
| 152 | // (ii) data type is set to integer for pic compression |
| 153 | // |
| 154 | // Since numpress arrays are always 64 bit and decode to double arrays, |
| 155 | // this should be safe. However, we cannot generally assume that DT_NONE |
| 156 | // means that we are dealing with a 64 bit float type. |
| 157 | if (bindata.np_compression != MSNumpressCoder::NONE && |
| 158 | bindata.data_type == BinaryData::DT_NONE) |
| 159 | { |
| 160 | MzMLHandlerHelper::warning(0, String("Invalid mzML format: Numpress-compressed binary data array '") + |
| 161 | bindata.meta.getName() + "' has no child term of MS:1000518 (binary data type) set. Assuming 64 bit float data type."); |
| 162 | bindata.data_type = BinaryData::DT_FLOAT; |
| 163 | bindata.precision = BinaryData::PRE_64; |
| 164 | } |
| 165 | if (bindata.np_compression == MSNumpressCoder::PIC && |
| 166 | bindata.data_type == BinaryData::DT_INT) |
| 167 | { |
| 168 | bindata.data_type = BinaryData::DT_FLOAT; |
| 169 | bindata.precision = BinaryData::PRE_64; |
| 170 | } |
| 171 | |
| 172 | // decode data and check if the length of the decoded data matches the expected length |
| 173 | if (bindata.data_type == BinaryData::DT_FLOAT) |
| 174 | { |
| 175 | if (bindata.np_compression != MSNumpressCoder::NONE) |
| 176 | { |
| 177 | // If its numpress, we don't distinguish 32 / 64 bit as the numpress |
| 178 | // decoder always works with 64 bit (takes std::vector<double>) |
| 179 | MSNumpressCoder::NumpressConfig config; |
| 180 | config.np_compression = bindata.np_compression; |
| 181 | MSNumpressCoder().decodeNP(bindata.base64, bindata.floats_64, bindata.compression, config); |
| 182 | |
| 183 | // Next, ensure that we only look at the float array even if the |
| 184 | // mzML tags say 32 bit data (I am looking at you, proteowizard) |
| 185 | bindata.precision = BinaryData::PRE_64; |
| 186 | } |
| 187 | else if (bindata.precision == BinaryData::PRE_64) |
| 188 | { |
| 189 | Base64::decode(bindata.base64, Base64::BYTEORDER_LITTLEENDIAN, bindata.floats_64, bindata.compression); |
| 190 | if (bindata.size != bindata.floats_64.size()) |
| 191 | { |
| 192 | MzMLHandlerHelper::warning(0, String("Float binary data array '") + bindata.meta.getName() + |
| 193 | "' has length " + bindata.floats_64.size() + ", but should have length " + bindata.size + "."); |
| 194 | bindata.size = bindata.floats_64.size(); |
| 195 | } |
nothing calls this directly
no test coverage detected