virtual void read(const string& filename, const string& head, MSData& result, int runIndex = 0) const { if (runIndex != 0) throw ReaderFail("[Reader_BTDX::read] multiple runs not supported"); shared_ptr<istream> is(new pwiz::util::random_access_compressed_ifstream(filename.c_str())); if (!is.get() || !*is) throw runtime_error(("[Reader_BTDX::read] Unable to open file " + filename)); result.fileDescription.fileContent.set(MS_MSn_spectrum); result.fileDescription.fileContent.set(MS_centroid_spectrum); SourceFilePtr sourceFile(new SourceFile); sourceFile->id = "BTDX1"; bfs::path p(filename); sourceFile->name = p.leaf(); string location = bfs::complete(p.branch_path()).string(); if (location.empty()) location = "."; sourceFile->location = string("file:///") + location; result.fileDescription.sourceFilePtrs.push_back(sourceFile); result.id = result.run.id = bfs::basename(filename); result.run.spectrumListPtr = SpectrumListPtr(SpectrumList_BTDX::create(is, result)); result.run.chromatogramListPtr = ChromatogramListPtr(new ChromatogramListSimple); return; }
PWIZ_API_DECL void Reader_ABI::read(const string& filename, const string& head, MSData& result, int runIndex, const Config& config) const { try { runIndex++; // one-based index WiffFilePtr wifffile = WiffFile::create(filename); // Loading the experiments is an expensive operation, so cache them. ExperimentsMap experimentsMap; cacheExperiments(wifffile, experimentsMap, runIndex); SpectrumList_ABI* sl = new SpectrumList_ABI(result, wifffile, experimentsMap, runIndex, config); ChromatogramList_ABI* cl = new ChromatogramList_ABI(result, wifffile, experimentsMap, runIndex); result.run.spectrumListPtr = SpectrumListPtr(sl); result.run.chromatogramListPtr = ChromatogramListPtr(cl); fillInMetadata(filename, result, wifffile, experimentsMap, runIndex); } catch (std::exception& e) { throw std::runtime_error(e.what()); } catch (...) { throw runtime_error("[Reader_ABI::read()] unhandled exception"); } }
PWIZ_API_DECL ChromatogramListPtr ChromatogramList_mz5::create(boost::shared_ptr<ReferenceRead_mz5> readPtr, boost::shared_ptr<Connection_mz5> connectionPtr, const MSData& msd) { return ChromatogramListPtr(new ChromatogramList_mz5Impl(readPtr, connectionPtr, msd)); }
PWIZ_API_DECL void Reader_ABI::read(const string& filename, const string& head, vector<MSDataPtr>& results, const Config& config) const { try { WiffFilePtr wifffile = WiffFile::create(filename); int sampleCount = wifffile->getSampleCount(); for (int i=1; i <= sampleCount; ++i) { try { MSDataPtr msDataPtr = MSDataPtr(new MSData); MSData& result = *msDataPtr; // Loading the experiments is an expensive operation, so cache them. ExperimentsMap experimentsMap; cacheExperiments(wifffile, experimentsMap, i); SpectrumList_ABI* sl = new SpectrumList_ABI(result, wifffile, experimentsMap, i, config); ChromatogramList_ABI* cl = new ChromatogramList_ABI(result, wifffile, experimentsMap, i); result.run.spectrumListPtr = SpectrumListPtr(sl); result.run.chromatogramListPtr = ChromatogramListPtr(cl); fillInMetadata(filename, result, wifffile, experimentsMap, i); results.push_back(msDataPtr); } catch (exception& e) { // TODO: make this a critical logged warning cerr << "[Reader_ABI::read] Error opening run " << i << " in " << bfs::path(filename).leaf() << ":\n" << e.what() << endl; } } } catch (std::exception& e) { throw std::runtime_error(e.what()); } catch (...) { throw runtime_error("[Reader_ABI::read()] unhandled exception"); } }