| 57 | } |
| 58 | |
| 59 | void CachedMzMLHandler::readMemdump(MapType& exp_reading, const String& filename) const |
| 60 | { |
| 61 | std::ifstream ifs(filename.c_str(), std::ios::binary); |
| 62 | if (ifs.fail()) |
| 63 | { |
| 64 | throw Exception::FileNotFound(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename); |
| 65 | } |
| 66 | |
| 67 | Size exp_size, chrom_size; |
| 68 | |
| 69 | int file_identifier; |
| 70 | ifs.read((char*)&file_identifier, sizeof(file_identifier)); |
| 71 | if (file_identifier != CACHED_MZML_FILE_IDENTIFIER) |
| 72 | { |
| 73 | throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, |
| 74 | "File might not be a cached mzML file (wrong file magic number). Aborting!", filename); |
| 75 | } |
| 76 | |
| 77 | ifs.seekg(0, ifs.end); // set file pointer to end |
| 78 | ifs.seekg(ifs.tellg(), ifs.beg); // set file pointer to end, in forward direction |
| 79 | ifs.seekg(- static_cast<int>(sizeof(exp_size) + sizeof(chrom_size)), ifs.cur); // move two fields to the left, start reading |
| 80 | ifs.read((char*)&exp_size, sizeof(exp_size)); |
| 81 | ifs.read((char*)&chrom_size, sizeof(chrom_size)); |
| 82 | ifs.seekg(sizeof(file_identifier), ifs.beg); // set file pointer to beginning (after identifier), start reading |
| 83 | |
| 84 | exp_reading.reserve(exp_size); |
| 85 | startProgress(0, exp_size + chrom_size, "reading binary data"); |
| 86 | for (Size i = 0; i < exp_size; i++) |
| 87 | { |
| 88 | setProgress(i); |
| 89 | SpectrumType spectrum; |
| 90 | readSpectrum(spectrum, ifs); |
| 91 | exp_reading.addSpectrum(spectrum); |
| 92 | } |
| 93 | std::vector<ChromatogramType> chromatograms; |
| 94 | for (Size i = 0; i < chrom_size; i++) |
| 95 | { |
| 96 | setProgress(i); |
| 97 | ChromatogramType chromatogram; |
| 98 | readChromatogram(chromatogram, ifs); |
| 99 | chromatograms.push_back(chromatogram); |
| 100 | } |
| 101 | exp_reading.setChromatograms(chromatograms); |
| 102 | |
| 103 | ifs.close(); |
| 104 | endProgress(); |
| 105 | } |
| 106 | |
| 107 | const std::vector<std::streampos>& CachedMzMLHandler::getSpectraIndex() const |
| 108 | { |
no test coverage detected