END_SECTION START_SECTION(const PeakFileOptions& getOptions() const) { MzDataFile file; TEST_EQUAL(file.getOptions().hasMSLevels(), false) const PeakFileOptions o = file.getOptions(); TEST_EQUAL(o.hasMSLevels(), false) }
END_SECTION START_SECTION(setOptions(const PeakFileOptions & options)) { MzDataFile file; TEST_EQUAL(file.getOptions().hasMSLevels(), false) const PeakFileOptions o = file.getOptions(); PeakFileOptions options = o; options.addMSLevel(1); file.setOptions(options); TEST_EQUAL(file.getOptions().hasMSLevels(), true) }
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 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**) { //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; }
///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// PeakFileOptions* ptr = 0; PeakFileOptions* nullPointer = 0; START_SECTION((PeakFileOptions())) ptr = new PeakFileOptions(); TEST_NOT_EQUAL(ptr, nullPointer) END_SECTION START_SECTION((~PeakFileOptions())) delete ptr; END_SECTION START_SECTION((void setCompression(bool compress))) PeakFileOptions tmp; tmp.setCompression(true); TEST_EQUAL(tmp.getCompression(), true); END_SECTION START_SECTION((bool getCompression() const)) PeakFileOptions tmp; TEST_EQUAL(tmp.getCompression(), false); END_SECTION START_SECTION((void setMetadataOnly(bool only))) PeakFileOptions tmp; tmp.setMetadataOnly(true); TEST_EQUAL(tmp.getMetadataOnly(), true); END_SECTION
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; }