Loads a Swath run from a single mzML file
| 117 | |
| 118 | /// Loads a Swath run from a single mzML file |
| 119 | std::vector<OpenSwath::SwathMap> SwathFile::loadMzML(const String& file, |
| 120 | const String& tmp, |
| 121 | boost::shared_ptr<ExperimentalSettings>& exp_meta, |
| 122 | const String& readoptions, |
| 123 | Interfaces::IMSDataConsumer* plugin_consumer) |
| 124 | { |
| 125 | std::cout << "Loading mzML file " << file << " using readoptions " << readoptions << std::endl; |
| 126 | String tmp_fname = tmp.hasSuffix('/') ? File::getUniqueName() : ""; // use tmp-filename if just a directory was given |
| 127 | |
| 128 | startProgress(0, 1, "Loading metadata file " + file); |
| 129 | boost::shared_ptr<PeakMap> exp_stripped = populateMetaData_(file); |
| 130 | exp_meta = exp_stripped; |
| 131 | |
| 132 | // First pass through the file -> get the meta data |
| 133 | std::cout << "Will analyze the metadata first to determine the number of SWATH windows and the window sizes." << std::endl; |
| 134 | std::vector<int> swath_counter; |
| 135 | int nr_ms1_spectra; |
| 136 | std::vector<OpenSwath::SwathMap> known_window_boundaries; |
| 137 | |
| 138 | countScansInSwath_(exp_stripped->getSpectra(), swath_counter, nr_ms1_spectra, known_window_boundaries); |
| 139 | std::cout << "Determined there to be " << swath_counter.size() |
| 140 | << " SWATH windows and in total " << nr_ms1_spectra << " MS1 spectra" << std::endl; |
| 141 | endProgress(); |
| 142 | |
| 143 | std::shared_ptr<FullSwathFileConsumer> dataConsumer; |
| 144 | startProgress(0, 1, "Loading data file " + file); |
| 145 | if (readoptions == "normal") |
| 146 | { |
| 147 | dataConsumer = std::make_shared<RegularSwathFileConsumer>(known_window_boundaries); |
| 148 | dataConsumer->setExperimentalSettings(*exp_meta.get()); |
| 149 | } |
| 150 | else if (readoptions == "cache") |
| 151 | { |
| 152 | dataConsumer = std::make_shared<CachedSwathFileConsumer>(known_window_boundaries, tmp, tmp_fname, nr_ms1_spectra, swath_counter); |
| 153 | dataConsumer->setExperimentalSettings(*exp_meta.get()); |
| 154 | } |
| 155 | else if (readoptions == "split") |
| 156 | { |
| 157 | // WARNING: swath_maps will be empty when querying retrieveSwathMaps() |
| 158 | dataConsumer = std::make_shared<MzMLSwathFileConsumer>(known_window_boundaries, tmp, tmp_fname, nr_ms1_spectra, swath_counter); |
| 159 | dataConsumer->setExperimentalSettings(*exp_meta.get()); |
| 160 | } |
| 161 | else |
| 162 | { |
| 163 | throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, |
| 164 | "Unknown or unsupported option " + readoptions); |
| 165 | } |
| 166 | |
| 167 | std::vector<Interfaces::IMSDataConsumer *> consumer_list; |
| 168 | // only use plugin if non-empty |
| 169 | if (plugin_consumer) |
| 170 | { |
| 171 | exp_meta->setMetaValue("nr_ms1_spectra", nr_ms1_spectra); // required for SwathQC::getExpSettingsFunc() |
| 172 | plugin_consumer->setExperimentalSettings(*exp_meta.get()); // set the meta data |
| 173 | exp_meta->removeMetaValue("nr_ms1_spectra"); // served its need. remove |
| 174 | // plugin_consumer->setExpectedSize(nr_ms1_spectra + accumulate(swath_counter)); // not needed currently |
| 175 | consumer_list.push_back(plugin_consumer); |
| 176 | } |