ExitCodes main_(int, const char **) { //input and output file names .. String in = getStringOption_("in"); String out = getStringOption_("out"); //prevent loading of fragment spectra PeakFileOptions options; options.setMSLevels(vector<Int>(1, 1)); //reading input data MzMLFile f; f.getOptions() = options; f.setLogType(log_type_); PeakMap exp; f.load(in, exp); exp.updateRanges(); //no seeds supported FeatureMap<> seeds; //setup of FeatureFinder FeatureFinder ff; ff.setLogType(log_type_); // A map for the resulting features FeatureMap<> features; // get parameters specific for the feature finder Param feafi_param = getParam_().copy("algorithm:", true); writeDebug_("Parameters passed to FeatureFinder", feafi_param, 3); // Apply the feature finder ff.run(FeatureFinderAlgorithmIsotopeWavelet<Peak1D, Feature>::getProductName(), exp, features, feafi_param, seeds); features.applyMemberFunction(&UniqueIdInterface::setUniqueId); // DEBUG if (debug_level_ > 10) { FeatureMap<>::Iterator it; for (it = features.begin(); it != features.end(); ++it) { if (!it->isMetaEmpty()) { vector<String> keys; it->getKeys(keys); LOG_INFO << "Feature " << it->getUniqueId() << endl; for (Size i = 0; i < keys.size(); i++) { LOG_INFO << " " << keys[i] << " = " << it->getMetaValue(keys[i]) << endl; } } } } //------------------------------------------------------------- // writing files //------------------------------------------------------------- //annotate output with data processing info addDataProcessing_(features, getProcessingInfo_(DataProcessing::QUANTITATION)); // write features to user specified output file FeatureXMLFile map_file; map_file.store(out, features); return EXECUTION_OK; }
ExitCodes main_(int, const char **) override { //------------------------------------------------------------- // parameter handling //------------------------------------------------------------- //input/output files String in(getStringOption_("in")); String out(getStringOption_("out")); //------------------------------------------------------------- // loading input //------------------------------------------------------------- PeakMap exp; MzMLFile f; f.setLogType(log_type_); PeakFileOptions options; options.clearMSLevels(); options.addMSLevel(2); f.getOptions() = options; f.load(in, exp); writeDebug_("Data set contains " + String(exp.size()) + " spectra", 1); //------------------------------------------------------------- // calculations //------------------------------------------------------------- vector<PeptideIdentification> pep_ids; CompNovoIdentificationCID comp_novo_id; // set the options Param algorithm_param = getParam_().copy("algorithm:", true); comp_novo_id.setParameters(algorithm_param); comp_novo_id.getIdentifications(pep_ids, exp); algorithm_param = comp_novo_id.getParameters(); //------------------------------------------------------------- // writing output //------------------------------------------------------------- DateTime now = DateTime::now(); String date_string = now.get(); String identifier("CompNovoCID_" + date_string); for (vector<PeptideIdentification>::iterator it = pep_ids.begin(); it != pep_ids.end(); ++it) { it->assignRanks(); it->setIdentifier(identifier); } vector<ProteinIdentification> prot_ids; ProteinIdentification prot_id; prot_id.setIdentifier(identifier); prot_id.setDateTime(now); StringList ms_runs; exp.getPrimaryMSRunPath(ms_runs); prot_id.setPrimaryMSRunPath(ms_runs); ProteinIdentification::SearchParameters search_parameters; search_parameters.charges = "+2-+3"; if (algorithm_param.getValue("tryptic_only").toBool()) { search_parameters.digestion_enzyme = *(ProteaseDB::getInstance()->getEnzyme("Trypsin")); } else { search_parameters.digestion_enzyme = *(ProteaseDB::getInstance()->getEnzyme("no cleavage")); } search_parameters.mass_type = ProteinIdentification::MONOISOTOPIC; search_parameters.fixed_modifications = algorithm_param.getValue("fixed_modifications"); search_parameters.variable_modifications = algorithm_param.getValue("variable_modifications"); search_parameters.missed_cleavages = (UInt)algorithm_param.getValue("missed_cleavages"); search_parameters.fragment_mass_tolerance = (double)algorithm_param.getValue("fragment_mass_tolerance"); search_parameters.precursor_mass_tolerance = (double)algorithm_param.getValue("precursor_mass_tolerance"); search_parameters.fragment_mass_tolerance_ppm = false; search_parameters.precursor_mass_tolerance_ppm = false; prot_id.setSearchParameters(search_parameters); prot_id.setSearchEngineVersion("0.9beta"); prot_id.setSearchEngine("CompNovo"); prot_ids.push_back(prot_id); IdXMLFile().store(out, prot_ids, pep_ids); return EXECUTION_OK; }
ExitCodes main_(int, const char**) { //input file names String in = getStringOption_("in"); String out = getStringOption_("out"); String out_mzq = getStringOption_("out_mzq"); //prevent loading of fragment spectra PeakFileOptions options; options.setMSLevels(vector<Int>(1, 1)); //reading input data MzMLFile f; f.getOptions() = options; f.setLogType(log_type_); PeakMap exp; f.load(in, exp); exp.updateRanges(); if (exp.getSpectra().empty()) { throw OpenMS::Exception::FileEmpty(__FILE__, __LINE__, __FUNCTION__, "Error: No MS1 spectra in input file."); } // determine type of spectral data (profile or centroided) SpectrumSettings::SpectrumType spectrum_type = exp[0].getType(); if (spectrum_type == SpectrumSettings::RAWDATA) { if (!getFlag_("force")) { throw OpenMS::Exception::IllegalArgument(__FILE__, __LINE__, __FUNCTION__, "Error: Profile data provided but centroided spectra expected. To enforce processing of the data set the -force flag."); } } //load seeds FeatureMap seeds; if (getStringOption_("seeds") != "") { FeatureXMLFile().load(getStringOption_("seeds"), seeds); } //setup of FeatureFinder FeatureFinder ff; ff.setLogType(log_type_); // A map for the resulting features FeatureMap features; // get parameters specific for the feature finder Param feafi_param = getParam_().copy("algorithm:", true); writeDebug_("Parameters passed to FeatureFinder", feafi_param, 3); // Apply the feature finder ff.run(FeatureFinderAlgorithmPicked::getProductName(), exp, features, feafi_param, seeds); features.applyMemberFunction(&UniqueIdInterface::setUniqueId); // DEBUG if (debug_level_ > 10) { FeatureMap::Iterator it; for (it = features.begin(); it != features.end(); ++it) { if (!it->isMetaEmpty()) { vector<String> keys; it->getKeys(keys); LOG_INFO << "Feature " << it->getUniqueId() << endl; for (Size i = 0; i < keys.size(); i++) { LOG_INFO << " " << keys[i] << " = " << it->getMetaValue(keys[i]) << endl; } } } } //------------------------------------------------------------- // writing files //------------------------------------------------------------- //annotate output with data processing info addDataProcessing_(features, getProcessingInfo_(DataProcessing::QUANTITATION)); // write features to user specified output file FeatureXMLFile map_file; // Remove detailed convex hull information and subordinate features // (unless requested otherwise) to reduce file size of feature files // unless debugging is turned on. if (debug_level_ < 5) { FeatureMap::Iterator it; for (it = features.begin(); it != features.end(); ++it) { it->getConvexHull().expandToBoundingBox(); for (Size i = 0; i < it->getConvexHulls().size(); ++i) { it->getConvexHulls()[i].expandToBoundingBox(); } it->getSubordinates().clear(); } } map_file.store(out, features); if (!out_mzq.trim().empty()) { MSQuantifications msq(features, exp.getExperimentalSettings(), exp[0].getDataProcessing()); msq.assignUIDs(); MzQuantMLFile file; file.store(out_mzq, msq); } return EXECUTION_OK; }
ExitCodes main_(int, const char**) { //------------------------------------------------------------- // parameter handling //------------------------------------------------------------- String in(getStringOption_("in")); String id(getStringOption_("id")); String out(getStringOption_("out")); double fragment_mass_tolerance(getDoubleOption_("fragment_mass_tolerance")); bool fragment_mass_unit_ppm = getStringOption_("fragment_mass_unit") == "Da" ? false : true; Size max_peptide_len = getIntOption_("max_peptide_length"); Size max_num_perm = getIntOption_("max_num_perm"); AScore ascore; //------------------------------------------------------------- // loading input //------------------------------------------------------------- vector<PeptideIdentification> pep_ids; vector<ProteinIdentification> prot_ids; vector<PeptideIdentification> pep_out; IdXMLFile().load(id, prot_ids, pep_ids); MSExperiment<> exp; MzMLFile f; f.setLogType(log_type_); PeakFileOptions options; options.clearMSLevels(); options.addMSLevel(2); f.getOptions() = options; f.load(in, exp); exp.sortSpectra(true); SpectrumLookup lookup; lookup.readSpectra(exp.getSpectra()); for (vector<PeptideIdentification>::iterator pep_id = pep_ids.begin(); pep_id != pep_ids.end(); ++pep_id) { Size scan_id = lookup.findByRT(pep_id->getRT()); PeakSpectrum& temp = exp.getSpectrum(scan_id); vector<PeptideHit> scored_peptides; for (vector<PeptideHit>::const_iterator hit = pep_id->getHits().begin(); hit < pep_id->getHits().end(); ++hit) { PeptideHit scored_hit = *hit; addScoreToMetaValues_(scored_hit, pep_id->getScoreType()); // backup score value LOG_DEBUG << "starting to compute AScore RT=" << pep_id->getRT() << " SEQUENCE: " << scored_hit.getSequence().toString() << std::endl; PeptideHit phospho_sites = ascore.compute(scored_hit, temp, fragment_mass_tolerance, fragment_mass_unit_ppm, max_peptide_len, max_num_perm); scored_peptides.push_back(phospho_sites); } PeptideIdentification new_pep_id(*pep_id); new_pep_id.setScoreType("PhosphoScore"); new_pep_id.setHigherScoreBetter(true); new_pep_id.setHits(scored_peptides); pep_out.push_back(new_pep_id); } //------------------------------------------------------------- // writing output //------------------------------------------------------------- IdXMLFile().store(out, prot_ids, pep_out); return EXECUTION_OK; }
ExitCodes main_(int, const char **) { //------------------------------------------------------------- // parameter handling //------------------------------------------------------------- String in = getStringOption_("in"); String out = getStringOption_("out"); //------------------------------------------------------------- // loading input //------------------------------------------------------------- MzMLFile mzMLFile; mzMLFile.setLogType(log_type_); MSExperiment<Peak1D> input; mzMLFile.getOptions().addMSLevel(1); mzMLFile.load(in, input); if (input.empty()) { LOG_WARN << "The given file does not contain any conventional peak data, but might" " contain chromatograms. This tool currently cannot handle them, sorry."; return INCOMPATIBLE_INPUT_DATA; } //check if spectra are sorted for (Size i = 0; i < input.size(); ++i) { if (!input[i].isSorted()) { writeLog_("Error: Not all spectra are sorted according to peak m/z positions. Use FileFilter to sort the input!"); return INCOMPATIBLE_INPUT_DATA; } } //------------------------------------------------------------- // pick //------------------------------------------------------------- FeatureMap<> output; FeatureFinder ff; Param param = getParam_().copy("algorithm:", true); FFSH ffsh; ffsh.setParameters(param); ffsh.setData(input, output, ff); ffsh.run(); //------------------------------------------------------------- // writing output //------------------------------------------------------------- //annotate output with data processing info addDataProcessing_(output, getProcessingInfo_(DataProcessing::PEAK_PICKING)); addDataProcessing_(output, getProcessingInfo_(DataProcessing::QUANTITATION)); output.ensureUniqueId(); for (Size i = 0; i < output.size(); i++) { output[i].ensureUniqueId(); } FeatureXMLFile().store(out, output); return EXECUTION_OK; }
ExitCodes main_(int, const char**) { //------------------------------------------------------------- // parameter handling //------------------------------------------------------------- //input file names String in = getStringOption_("in"); bool write_mzML_index = getFlag_("write_mzML_index"); //input file type FileHandler fh; FileTypes::Type in_type = FileTypes::nameToType(getStringOption_("in_type")); if (in_type == FileTypes::UNKNOWN) { in_type = fh.getType(in); writeDebug_(String("Input file type: ") + FileTypes::typeToName(in_type), 2); } if (in_type == FileTypes::UNKNOWN) { writeLog_("Error: Could not determine input file type!"); return PARSE_ERROR; } //output file names and types String out = getStringOption_("out"); FileTypes::Type out_type = FileTypes::nameToType(getStringOption_("out_type")); if (out_type == FileTypes::UNKNOWN) { out_type = fh.getTypeByFileName(out); } if (out_type == FileTypes::UNKNOWN) { writeLog_("Error: Could not determine output file type!"); return PARSE_ERROR; } bool TIC_DTA2D = getFlag_("TIC_DTA2D"); bool process_lowmemory = getFlag_("process_lowmemory"); writeDebug_(String("Output file type: ") + FileTypes::typeToName(out_type), 1); String uid_postprocessing = getStringOption_("UID_postprocessing"); //------------------------------------------------------------- // reading input //------------------------------------------------------------- typedef MSExperiment<Peak1D> MSExperimentType; MSExperimentType exp; typedef MSExperimentType::SpectrumType SpectrumType; typedef FeatureMap FeatureMapType; FeatureMapType fm; ConsensusMap cm; writeDebug_(String("Loading input file"), 1); if (in_type == FileTypes::CONSENSUSXML) { ConsensusXMLFile().load(in, cm); cm.sortByPosition(); if ((out_type != FileTypes::FEATUREXML) && (out_type != FileTypes::CONSENSUSXML)) { // You you will lose information and waste memory. Enough reasons to issue a warning! writeLog_("Warning: Converting consensus features to peaks. You will lose information!"); exp.set2DData(cm); } } else if (in_type == FileTypes::EDTA) { EDTAFile().load(in, cm); cm.sortByPosition(); if ((out_type != FileTypes::FEATUREXML) && (out_type != FileTypes::CONSENSUSXML)) { // You you will lose information and waste memory. Enough reasons to issue a warning! writeLog_("Warning: Converting consensus features to peaks. You will lose information!"); exp.set2DData(cm); } } else if (in_type == FileTypes::FEATUREXML || in_type == FileTypes::TSV || in_type == FileTypes::PEPLIST || in_type == FileTypes::KROENIK) { fh.loadFeatures(in, fm, in_type); fm.sortByPosition(); if ((out_type != FileTypes::FEATUREXML) && (out_type != FileTypes::CONSENSUSXML)) { // You will lose information and waste memory. Enough reasons to issue a warning! writeLog_("Warning: Converting features to peaks. You will lose information! Mass traces are added, if present as 'num_of_masstraces' and 'masstrace_intensity_<X>' (X>=0) meta values."); exp.set2DData<true>(fm); } } else if (process_lowmemory) { // Special switch for the low memory options: // We can transform the complete experiment directly without first // loading the complete data into memory. PlainMSDataWritingConsumer will // write out mzML to disk as they are read from the input. if (in_type == FileTypes::MZML && out_type == FileTypes::MZML) { PlainMSDataWritingConsumer consumer(out); consumer.getOptions().setWriteIndex(write_mzML_index); consumer.addDataProcessing(getProcessingInfo_(DataProcessing::CONVERSION_MZML)); MzMLFile mzmlfile; mzmlfile.setLogType(log_type_); mzmlfile.transform(in, &consumer); return EXECUTION_OK; } else if (in_type == FileTypes::MZXML && out_type == FileTypes::MZML) { PlainMSDataWritingConsumer consumer(out); consumer.getOptions().setWriteIndex(write_mzML_index); consumer.addDataProcessing(getProcessingInfo_(DataProcessing::CONVERSION_MZML)); MzXMLFile mzxmlfile; mzxmlfile.setLogType(log_type_); mzxmlfile.transform(in, &consumer); return EXECUTION_OK; } else { throw Exception::IllegalArgument(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Process_lowmemory option can only be used with mzML / mzXML input and mzML output data types."); } } else { fh.loadExperiment(in, exp, in_type, log_type_); } //------------------------------------------------------------- // writing output //------------------------------------------------------------- writeDebug_(String("Writing output file"), 1); if (out_type == FileTypes::MZML) { //add data processing entry addDataProcessing_(exp, getProcessingInfo_(DataProcessing:: CONVERSION_MZML)); MzMLFile f; f.setLogType(log_type_); f.getOptions().setWriteIndex(write_mzML_index); ChromatogramTools().convertSpectraToChromatograms(exp, true); f.store(out, exp); } else if (out_type == FileTypes::MZDATA) { //annotate output with data processing info addDataProcessing_(exp, getProcessingInfo_(DataProcessing:: CONVERSION_MZDATA)); MzDataFile f; f.setLogType(log_type_); ChromatogramTools().convertChromatogramsToSpectra<MSExperimentType>(exp); f.store(out, exp); } else if (out_type == FileTypes::MZXML) { //annotate output with data processing info addDataProcessing_(exp, getProcessingInfo_(DataProcessing:: CONVERSION_MZXML)); MzXMLFile f; f.setLogType(log_type_); ChromatogramTools().convertChromatogramsToSpectra<MSExperimentType>(exp); f.store(out, exp); } else if (out_type == FileTypes::DTA2D) { //add data processing entry addDataProcessing_(exp, getProcessingInfo_(DataProcessing:: FORMAT_CONVERSION)); DTA2DFile f; f.setLogType(log_type_); ChromatogramTools().convertChromatogramsToSpectra<MSExperimentType>(exp); if (TIC_DTA2D) { // store the total ion chromatogram (TIC) f.storeTIC(out, exp); } else { // store entire experiment f.store(out, exp); } } else if (out_type == FileTypes::MGF) { //add data processing entry addDataProcessing_(exp, getProcessingInfo_(DataProcessing:: FORMAT_CONVERSION)); MascotGenericFile f; f.setLogType(log_type_); f.store(out, exp, getFlag_("MGF_compact")); } else if (out_type == FileTypes::FEATUREXML) { if ((in_type == FileTypes::FEATUREXML) || (in_type == FileTypes::TSV) || (in_type == FileTypes::PEPLIST) || (in_type == FileTypes::KROENIK)) { if (uid_postprocessing == "ensure") { fm.applyMemberFunction(&UniqueIdInterface::ensureUniqueId); } else if (uid_postprocessing == "reassign") { fm.applyMemberFunction(&UniqueIdInterface::setUniqueId); } } else if (in_type == FileTypes::CONSENSUSXML || in_type == FileTypes::EDTA) { MapConversion::convert(cm, true, fm); } else // not loaded as feature map or consensus map { // The feature specific information is only defaulted. Enough reasons to issue a warning! writeLog_("Warning: Converting peaks to features will lead to incomplete features!"); fm.clear(); fm.reserve(exp.getSize()); typedef FeatureMapType::FeatureType FeatureType; FeatureType feature; feature.setQuality(0, 1); // override default feature.setQuality(1, 1); // override default feature.setOverallQuality(1); // override default for (MSExperimentType::ConstIterator spec_iter = exp.begin(); spec_iter != exp.end(); ++spec_iter ) { feature.setRT(spec_iter->getRT()); for (SpectrumType::ConstIterator peak1_iter = spec_iter->begin(); peak1_iter != spec_iter->end(); ++peak1_iter ) { feature.setMZ(peak1_iter->getMZ()); feature.setIntensity(peak1_iter->getIntensity()); feature.setUniqueId(); fm.push_back(feature); } } fm.updateRanges(); } addDataProcessing_(fm, getProcessingInfo_(DataProcessing:: FORMAT_CONVERSION)); FeatureXMLFile().store(out, fm); } else if (out_type == FileTypes::CONSENSUSXML) { if ((in_type == FileTypes::FEATUREXML) || (in_type == FileTypes::TSV) || (in_type == FileTypes::PEPLIST) || (in_type == FileTypes::KROENIK)) { if (uid_postprocessing == "ensure") { fm.applyMemberFunction(&UniqueIdInterface::ensureUniqueId); } else if (uid_postprocessing == "reassign") { fm.applyMemberFunction(&UniqueIdInterface::setUniqueId); } MapConversion::convert(0, fm, cm); } // nothing to do for consensus input else if (in_type == FileTypes::CONSENSUSXML || in_type == FileTypes::EDTA) { } else // experimental data { MapConversion::convert(0, exp, cm, exp.size()); } addDataProcessing_(cm, getProcessingInfo_(DataProcessing:: FORMAT_CONVERSION)); ConsensusXMLFile().store(out, cm); } else if (out_type == FileTypes::EDTA) { if (fm.size() > 0 && cm.size() > 0) { LOG_ERROR << "Internal error: cannot decide on container (Consensus or Feature)! This is a bug. Please report it!"; return INTERNAL_ERROR; } if (fm.size() > 0) EDTAFile().store(out, fm); else if (cm.size() > 0) EDTAFile().store(out, cm); } else if (out_type == FileTypes::CSV) { // as ibspectra is currently the only csv/text based format we assume // that out_type == FileTypes::CSV means ibspectra, if more formats // are added we need a more intelligent strategy to decide which // conversion is requested // IBSpectra selected as output type if (in_type != FileTypes::CONSENSUSXML) { LOG_ERROR << "Incompatible input data: FileConverter can only convert consensusXML files to ibspectra format."; return INCOMPATIBLE_INPUT_DATA; } IBSpectraFile ibfile; ibfile.store(out, cm); } else { writeLog_("Unknown output file type given. Aborting!"); printUsage_(); return ILLEGAL_PARAMETERS; } return EXECUTION_OK; }
ExitCodes main_(int, const char**) override { //------------------------------------------------------------- // parameter handling //------------------------------------------------------------- //input file names String in = getStringOption_("in"); String read_method = getStringOption_("read_method"); bool load_data = getStringOption_("loadData") == "true"; if (read_method == "streaming") { std::cout << "Read method: streaming" << std::endl; // Create the consumer, set output file name, transform TICConsumer consumer; MzMLFile mzml; mzml.setLogType(log_type_); PeakFileOptions opt = mzml.getOptions(); opt.setFillData(load_data); // whether to actually load any data opt.setSkipXMLChecks(true); // save time by not checking base64 strings for whitespaces opt.setMaxDataPoolSize(100); opt.setAlwaysAppendData(false); mzml.setOptions(opt); mzml.transform(in, &consumer, true, true); std::cout << "There are " << consumer.nr_spectra << " spectra and " << consumer.nr_peaks << " peaks in the input file." << std::endl; std::cout << "The total ion current is " << consumer.TIC << std::endl; size_t after; SysInfo::getProcessMemoryConsumption(after); std::cout << " Memory consumption after " << after << std::endl; } else if (read_method == "regular") { std::cout << "Read method: regular" << std::endl; MzMLFile mzml; mzml.setLogType(log_type_); PeakFileOptions opt = mzml.getOptions(); opt.setFillData(load_data); // whether to actually load any data opt.setSkipXMLChecks(true); // save time by not checking base64 strings for whitespaces mzml.setOptions(opt); PeakMap map; mzml.load(in, map); double TIC = 0.0; long int nr_peaks = 0; for (Size i =0; i < map.size(); i++) { nr_peaks += map[i].size(); for (Size j = 0; j < map[i].size(); j++) { TIC += map[i][j].getIntensity(); } } std::cout << "There are " << map.size() << " spectra and " << nr_peaks << " peaks in the input file." << std::endl; std::cout << "The total ion current is " << TIC << std::endl; size_t after; SysInfo::getProcessMemoryConsumption(after); std::cout << " Memory consumption after " << after << std::endl; } else if (read_method == "indexed") { std::cout << "Read method: indexed" << std::endl; IndexedMzMLFileLoader imzml; // load data from an indexed MzML file OnDiscPeakMap map; imzml.load(in, map); double TIC = 0.0; long int nr_peaks = 0; if (load_data) { for (Size i =0; i < map.getNrSpectra(); i++) { OpenMS::Interfaces::SpectrumPtr sptr = map.getSpectrumById(i); nr_peaks += sptr->getIntensityArray()->data.size(); TIC += std::accumulate(sptr->getIntensityArray()->data.begin(), sptr->getIntensityArray()->data.end(), 0.0); } } std::cout << "There are " << map.getNrSpectra() << " spectra and " << nr_peaks << " peaks in the input file." << std::endl; std::cout << "The total ion current is " << TIC << std::endl; size_t after; SysInfo::getProcessMemoryConsumption(after); std::cout << " Memory consumption after " << after << std::endl; } else if (read_method == "indexed_parallel") { std::cout << "Read method: indexed (parallel)" << std::endl; IndexedMzMLFileLoader imzml; PeakFileOptions opt = imzml.getOptions(); opt.setFillData(load_data); // whether to actually load any data imzml.setOptions(opt); // load data from an indexed MzML file OnDiscPeakMap map; map.openFile(in, true); map.setSkipXMLChecks(true); double TIC = 0.0; long int nr_peaks = 0; if (load_data) { // firstprivate means that each thread has its own instance of the // variable, each copy initialized with the initial value #ifdef _OPENMP #pragma omp parallel for firstprivate(map) #endif for (SignedSize i =0; i < (SignedSize)map.getNrSpectra(); i++) { OpenMS::Interfaces::SpectrumPtr sptr = map.getSpectrumById(i); double nr_peaks_l = sptr->getIntensityArray()->data.size(); double TIC_l = std::accumulate(sptr->getIntensityArray()->data.begin(), sptr->getIntensityArray()->data.end(), 0.0); #ifdef _OPENMP #pragma omp critical (indexed) #endif { TIC += TIC_l; nr_peaks += nr_peaks_l; } } } std::cout << "There are " << map.getNrSpectra() << " spectra and " << nr_peaks << " peaks in the input file." << std::endl; std::cout << "The total ion current is " << TIC << std::endl; size_t after; SysInfo::getProcessMemoryConsumption(after); std::cout << " Memory consumption after " << after << std::endl; } else if (read_method == "cached") { std::cout << "Read method: cached" << std::endl; // Special handling of cached mzML as input types: // we expect two paired input files which we should read into exp std::vector<String> split_out; in.split(".cachedMzML", split_out); if (split_out.size() != 2) { LOG_ERROR << "Cannot deduce base path from input '" << in << "' (note that '.cachedMzML' should only occur once as the final ending)" << std::endl; return ILLEGAL_PARAMETERS; } String in_meta = split_out[0] + ".mzML"; MzMLFile f; f.setLogType(log_type_); CachedmzML cacher; cacher.setLogType(log_type_); CachedmzML cache; cache.createMemdumpIndex(in); const std::vector<std::streampos> spectra_index = cache.getSpectraIndex(); std::ifstream ifs_; ifs_.open(in.c_str(), std::ios::binary); double TIC = 0.0; long int nr_peaks = 0; for (Size i=0; i < spectra_index.size(); ++i) { BinaryDataArrayPtr mz_array(new BinaryDataArray); BinaryDataArrayPtr intensity_array(new BinaryDataArray); int ms_level = -1; double rt = -1.0; ifs_.seekg(spectra_index[i]); CachedmzML::readSpectrumFast(mz_array, intensity_array, ifs_, ms_level, rt); nr_peaks += intensity_array->data.size(); for (Size j = 0; j < intensity_array->data.size(); j++) { TIC += intensity_array->data[j]; } } std::cout << "There are " << spectra_index.size() << " spectra and " << nr_peaks << " peaks in the input file." << std::endl; std::cout << "The total ion current is " << TIC << std::endl; size_t after; SysInfo::getProcessMemoryConsumption(after); std::cout << " Memory consumption after " << after << std::endl; } else if (read_method == "cached_parallel") { std::cout << "Read method: cached parallel" << std::endl; // Special handling of cached mzML as input types: // we expect two paired input files which we should read into exp std::vector<String> split_out; in.split(".cachedMzML", split_out); if (split_out.size() != 2) { LOG_ERROR << "Cannot deduce base path from input '" << in << "' (note that '.cachedMzML' should only occur once as the final ending)" << std::endl; return ILLEGAL_PARAMETERS; } String in_meta = split_out[0] + ".mzML"; MzMLFile f; f.setLogType(log_type_); CachedmzML cacher; cacher.setLogType(log_type_); CachedmzML cache; cache.createMemdumpIndex(in); const std::vector<std::streampos> spectra_index = cache.getSpectraIndex(); FileAbstraction filestream(in); double TIC = 0.0; long int nr_peaks = 0; #ifdef _OPENMP #pragma omp parallel for firstprivate(filestream) #endif for (SignedSize i=0; i < (SignedSize)spectra_index.size(); ++i) { BinaryDataArrayPtr mz_array(new BinaryDataArray); BinaryDataArrayPtr intensity_array(new BinaryDataArray); int ms_level = -1; double rt = -1.0; // we only change the position of the thread-local filestream filestream.getStream().seekg(spectra_index[i]); CachedmzML::readSpectrumFast(mz_array, intensity_array, filestream.getStream(), ms_level, rt); double nr_peaks_l = intensity_array->data.size(); double TIC_l = std::accumulate(intensity_array->data.begin(), intensity_array->data.end(), 0.0); #ifdef _OPENMP #pragma omp critical (indexed) #endif { TIC += TIC_l; nr_peaks += nr_peaks_l; } } std::cout << "There are " << spectra_index.size() << " spectra and " << nr_peaks << " peaks in the input file." << std::endl; std::cout << "The total ion current is " << TIC << std::endl; size_t after; SysInfo::getProcessMemoryConsumption(after); std::cout << " Memory consumption after " << after << std::endl; } return EXECUTION_OK; }