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

Method readExperiment

src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp:238–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236 }
237
238 void MzMLSqliteHandler::readExperiment(MSExperiment& exp, bool meta_only) const
239 {
240 SqliteConnector conn(filename_);
241 sqlite3* db = conn.getDB();
242
243 Size nr_results = 0;
244 if (write_full_meta_)
245 {
246 std::string select_sql = "SELECT " \
247 "RUN.ID as run_id," \
248 "RUN.NATIVE_ID as native_id," \
249 "RUN.FILENAME as filename," \
250 "RUN_EXTRA.DATA as data " \
251 "FROM RUN " \
252 "LEFT JOIN RUN_EXTRA ON RUN.ID = RUN_EXTRA.RUN_ID " \
253 ";";
254
255 sqlite3_stmt* stmt;
256 conn.prepareStatement(&stmt, select_sql);
257 sqlite3_step(stmt);
258
259 // read data (throw exception if we find multiple runs)
260 while (sqlite3_column_type(stmt, 0) != SQLITE_NULL)
261 {
262 if (nr_results > 0)
263 {
264 throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
265 "More than one run found, cannot read both into memory");
266 }
267
268 const void* raw_text = sqlite3_column_blob(stmt, 3);
269 size_t blob_bytes = sqlite3_column_bytes(stmt, 3);
270
271 // create mzML file and parse full structure
272 if (blob_bytes > 0)
273 {
274 MzMLFile f;
275 std::string uncompressed;
276 OpenMS::ZlibCompression::uncompressString(raw_text, blob_bytes, uncompressed);
277 f.loadBuffer(uncompressed, exp);
278
279 nr_results++;
280 }
281 else
282 {
283 const unsigned char* native_id = sqlite3_column_text(stmt, 1);
284 const unsigned char* filename = sqlite3_column_text(stmt, 2);
285 OPENMS_LOG_WARN << "Warning: no full meta data found for run " << native_id << " from file " << filename << std::endl;
286 }
287 sqlite3_step(stmt);
288 }
289
290 // free memory
291 sqlite3_finalize(stmt);
292
293 if (nr_results == 0)
294 {
295 OPENMS_LOG_WARN << "Warning: no meta data found, fall back to inference from SQL data structures." << std::endl;

Callers 4

getAllSpectraMethod · 0.80
loadMethod · 0.80
transformMethod · 0.80
START_SECTIONFunction · 0.80

Calls 10

prepareSpectra_Function · 0.85
getRunIDFunction · 0.85
prepareStatementMethod · 0.80
loadBufferMethod · 0.80
setChromatogramsMethod · 0.80
setSqlRunIDMethod · 0.80
getChromatogramsMethod · 0.80
getNrChromatogramsMethod · 0.45
getNrSpectraMethod · 0.45
setSpectraMethod · 0.45

Tested by 2

getAllSpectraMethod · 0.64
START_SECTIONFunction · 0.64