From fefe19375b1a67b99c7fcc518d1293e787539e8a Mon Sep 17 00:00:00 2001 From: oliveralka Date: Tue, 31 Aug 2021 13:12:50 +0200 Subject: [PATCH 1/4] add oms to fileconverter --- src/topp/FileConverter.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/topp/FileConverter.cpp b/src/topp/FileConverter.cpp index b8a98a6524d..051c2c8f120 100644 --- a/src/topp/FileConverter.cpp +++ b/src/topp/FileConverter.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,9 @@ #include #include +#include + + using namespace OpenMS; @@ -125,6 +129,7 @@ using namespace std; @ref OpenMS::KroenikFile "kroenik" @ref OpenMS::EDTAFile "edta" @ref OpenMS::SqMassFile "sqmass" + @ref OpenMS::OMSFile "oms" @note See @ref TOPP_IDFileConverter for similar functionality for protein/peptide identification file formats. @@ -338,7 +343,7 @@ class TOPPFileConverter : String method("none,ensure,reassign"); setValidStrings_("UID_postprocessing", ListUtils::create(method)); - vector output_formats = {"mzML", "mzXML", "cachedMzML", "mgf", "featureXML", "consensusXML", "edta", "mzData", "dta2d", "csv", "sqmass"}; + vector output_formats = {"mzML", "mzXML", "cachedMzML", "mgf", "featureXML", "consensusXML", "edta", "mzData", "dta2d", "csv", "sqmass","oms"}; registerOutputFile_("out", "", "", "Output file"); setValidFormats_("out", output_formats); registerStringOption_("out_type", "", "", "Output file type -- default: determined from file extension or content\nNote: that not all conversion paths work or make sense.", false, true); @@ -504,7 +509,8 @@ class TOPPFileConverter : fh.loadFeatures(in, fm, in_type); fm.sortByPosition(); if ((out_type != FileTypes::FEATUREXML) && - (out_type != FileTypes::CONSENSUSXML)) + (out_type != FileTypes::CONSENSUSXML) && + (out_type != FileTypes::OMS)) { // 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>=0) meta values."); @@ -880,6 +886,15 @@ class TOPPFileConverter : SqMassFile sqm; sqm.store(out, exp); } + else if (out_type == FileTypes::OMS) + { + if (in_type != FileTypes::FEATUREXML) + { + OPENMS_LOG_ERROR << "Incompatible input data: FileConverter can only convert featureXML files to oms format."; + return INCOMPATIBLE_INPUT_DATA; + } + OMSFile().store(out, fm); + } else { writeLog_("Unknown output file type given. Aborting!"); From 1128150db8a5175d29f47b98e331b989e4e25b84 Mon Sep 17 00:00:00 2001 From: oliveralka Date: Fri, 3 Sep 2021 16:08:16 +0200 Subject: [PATCH 2/4] [FIX] --- src/openms/include/OpenMS/FORMAT/OMSFile.h | 2 +- src/openms/source/FORMAT/OMSFile.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/openms/include/OpenMS/FORMAT/OMSFile.h b/src/openms/include/OpenMS/FORMAT/OMSFile.h index f850db4eb29..7e1f03a2212 100644 --- a/src/openms/include/OpenMS/FORMAT/OMSFile.h +++ b/src/openms/include/OpenMS/FORMAT/OMSFile.h @@ -90,7 +90,7 @@ namespace OpenMS protected: - using Key = qint64; + using Key = quint64; LogType log_type_; diff --git a/src/openms/source/FORMAT/OMSFile.cpp b/src/openms/source/FORMAT/OMSFile.cpp index 8dc2f676f39..07bff2a5a61 100644 --- a/src/openms/source/FORMAT/OMSFile.cpp +++ b/src/openms/source/FORMAT/OMSFile.cpp @@ -297,9 +297,9 @@ namespace OpenMS "parent_id INTEGER NOT NULL, " \ "name TEXT NOT NULL, " \ "data_value_id INTEGER NOT NULL, " \ + "UNIQUE (parent_id, name), " \ "FOREIGN KEY (parent_id) REFERENCES " + parent_ref + ", " \ - "FOREIGN KEY (data_value_id) REFERENCES DataValue (id), " \ - "UNIQUE (parent_id, name)"); + "FOREIGN KEY (data_value_id) REFERENCES DataValue (id)"); } @@ -1313,7 +1313,7 @@ namespace OpenMS query_feat.bindValue(":overall_quality", feature.getOverallQuality()); query_feat.bindValue(":rt_quality", feature.getQuality(0)); query_feat.bindValue(":mz_quality", feature.getQuality(1)); - query_feat.bindValue(":unique_id", qint64(feature.getUniqueId())); + query_feat.bindValue(":unique_id", quint64(feature.getUniqueId())); if (feature.hasPrimaryID()) { query_feat.bindValue(":primary_molecule_id", getAddress_(feature.getPrimaryID())); @@ -1478,9 +1478,9 @@ namespace OpenMS void OMSFile::OMSFileStore::storeMapMetaData_(const FeatureMap& features) { createTable_("FEAT_MapMetaData", - "unique_id INTEGER, " \ - "identifier TEXT, " \ - "file_path TEXT, " \ + "unique_id INTEGER UNIQUE NOT NULL, " \ + "identifier TEXT, " \ + "file_path TEXT, " \ "file_type TEXT"); QSqlQuery query(QSqlDatabase::database(db_name_)); // @TODO: worth using a prepared query for just one insert? @@ -1489,7 +1489,7 @@ namespace OpenMS ":identifier, " \ ":file_path, " \ ":file_type)"); - query.bindValue(":unique_id", qint64(features.getUniqueId())); + query.bindValue(":unique_id", quint64(features.getUniqueId())); // qint64 (-4317911969993237730) seems to change Uint64 (14128832103716313886) > quint64 (14128832103716313886) query.bindValue(":identifier", features.getIdentifier().toQString()); query.bindValue(":file_path", features.getLoadedFilePath().toQString()); String file_type = FileTypes::typeToName(features.getLoadedFileType()); @@ -1503,7 +1503,7 @@ namespace OpenMS { createTableMetaInfo_("FEAT_MapMetaData", "unique_id"); QSqlQuery query_meta = getQueryMetaInfo_("FEAT_MapMetaData"); - storeMetaInfo_(features, qint64(features.getUniqueId()), query_meta); + storeMetaInfo_(features, quint64(features.getUniqueId()), query_meta); } } From 6a6e611f1b4bd70189f7d27b87b86b0efa6bfdcd Mon Sep 17 00:00:00 2001 From: oliveralka Date: Mon, 13 Sep 2021 17:28:47 +0200 Subject: [PATCH 3/4] add fxml export --- src/topp/FileConverter.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/topp/FileConverter.cpp b/src/topp/FileConverter.cpp index 051c2c8f120..5e728242237 100644 --- a/src/topp/FileConverter.cpp +++ b/src/topp/FileConverter.cpp @@ -779,6 +779,12 @@ class TOPPFileConverter : { MapConversion::convert(cm, true, fm); } + else if (in_type == FileTypes::OMS) + { + FeatureMap fm; + OMSFile().load(in, fm); + IdentificationDataConverter::exportFeatureIDs(fm); + } else // not loaded as feature map or consensus map { // The feature specific information is only defaulted. Enough reasons to issue a warning! @@ -893,6 +899,7 @@ class TOPPFileConverter : OPENMS_LOG_ERROR << "Incompatible input data: FileConverter can only convert featureXML files to oms format."; return INCOMPATIBLE_INPUT_DATA; } + IdentificationDataConverter::importFeatureIDs(fm); OMSFile().store(out, fm); } else From d40720f5a2ac67d623c26a48bad81ec865408673 Mon Sep 17 00:00:00 2001 From: oliveralka Date: Mon, 4 Oct 2021 19:40:03 +0200 Subject: [PATCH 4/4] Use qint instead uf quint --- THIRDPARTY | 2 +- src/openms/include/OpenMS/FORMAT/OMSFile.h | 3 ++- src/openms/source/FORMAT/OMSFile.cpp | 6 +++--- src/topp/FileConverter.cpp | 20 +++++++------------- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/THIRDPARTY b/THIRDPARTY index 7430be869d9..52b731c4677 160000 --- a/THIRDPARTY +++ b/THIRDPARTY @@ -1 +1 @@ -Subproject commit 7430be869d9351ca0521374403b35ea3d0ffe082 +Subproject commit 52b731c4677fd445a2a13cde609a42c55bff9d51 diff --git a/src/openms/include/OpenMS/FORMAT/OMSFile.h b/src/openms/include/OpenMS/FORMAT/OMSFile.h index 7e1f03a2212..6027ae1d501 100644 --- a/src/openms/include/OpenMS/FORMAT/OMSFile.h +++ b/src/openms/include/OpenMS/FORMAT/OMSFile.h @@ -90,7 +90,8 @@ namespace OpenMS protected: - using Key = quint64; + // qint64 as key for unique_id, due to sqlite restriction to signed integers. + using Key = qint64; LogType log_type_; diff --git a/src/openms/source/FORMAT/OMSFile.cpp b/src/openms/source/FORMAT/OMSFile.cpp index 07bff2a5a61..076e1dace62 100644 --- a/src/openms/source/FORMAT/OMSFile.cpp +++ b/src/openms/source/FORMAT/OMSFile.cpp @@ -1313,7 +1313,7 @@ namespace OpenMS query_feat.bindValue(":overall_quality", feature.getOverallQuality()); query_feat.bindValue(":rt_quality", feature.getQuality(0)); query_feat.bindValue(":mz_quality", feature.getQuality(1)); - query_feat.bindValue(":unique_id", quint64(feature.getUniqueId())); + query_feat.bindValue(":unique_id", qint64(feature.getUniqueId())); if (feature.hasPrimaryID()) { query_feat.bindValue(":primary_molecule_id", getAddress_(feature.getPrimaryID())); @@ -1489,7 +1489,7 @@ namespace OpenMS ":identifier, " \ ":file_path, " \ ":file_type)"); - query.bindValue(":unique_id", quint64(features.getUniqueId())); // qint64 (-4317911969993237730) seems to change Uint64 (14128832103716313886) > quint64 (14128832103716313886) + query.bindValue(":unique_id", qint64(features.getUniqueId())); query.bindValue(":identifier", features.getIdentifier().toQString()); query.bindValue(":file_path", features.getLoadedFilePath().toQString()); String file_type = FileTypes::typeToName(features.getLoadedFileType()); @@ -1503,7 +1503,7 @@ namespace OpenMS { createTableMetaInfo_("FEAT_MapMetaData", "unique_id"); QSqlQuery query_meta = getQueryMetaInfo_("FEAT_MapMetaData"); - storeMetaInfo_(features, quint64(features.getUniqueId()), query_meta); + storeMetaInfo_(features, qint64(features.getUniqueId()), query_meta); } } diff --git a/src/topp/FileConverter.cpp b/src/topp/FileConverter.cpp index 5e728242237..6baf1b5dccd 100644 --- a/src/topp/FileConverter.cpp +++ b/src/topp/FileConverter.cpp @@ -434,14 +434,9 @@ class TOPPFileConverter : //------------------------------------------------------------- // reading input //------------------------------------------------------------- - typedef PeakMap MSExperimentType; - MSExperimentType exp; - - typedef MSExperimentType::SpectrumType SpectrumType; - - typedef FeatureMap FeatureMapType; - - FeatureMapType fm; + typedef MSExperiment::SpectrumType SpectrumType; + MSExperiment exp; + FeatureMap fm; ConsensusMap cm; writeDebug_(String("Loading input file"), 1); @@ -716,7 +711,7 @@ class TOPPFileConverter : CONVERSION_MZDATA)); MzDataFile f; f.setLogType(log_type_); - ChromatogramTools().convertChromatogramsToSpectra(exp); + ChromatogramTools().convertChromatogramsToSpectra(exp); f.store(out, exp); } else if (out_type == FileTypes::MZXML) @@ -728,7 +723,7 @@ class TOPPFileConverter : f.setLogType(log_type_); f.getOptions().setForceMQCompatability(force_MaxQuant_compatibility); f.getOptions().setWriteIndex(write_scan_index); - //ChromatogramTools().convertChromatogramsToSpectra(exp); + //ChromatogramTools().convertChromatogramsToSpectra(exp); f.store(out, exp); } else if (out_type == FileTypes::DTA2D) @@ -738,7 +733,7 @@ class TOPPFileConverter : FORMAT_CONVERSION)); DTA2DFile f; f.setLogType(log_type_); - ChromatogramTools().convertChromatogramsToSpectra(exp); + ChromatogramTools().convertChromatogramsToSpectra(exp); if (TIC_DTA2D) { // store the total ion chromatogram (TIC) @@ -781,7 +776,6 @@ class TOPPFileConverter : } else if (in_type == FileTypes::OMS) { - FeatureMap fm; OMSFile().load(in, fm); IdentificationDataConverter::exportFeatureIDs(fm); } @@ -795,7 +789,7 @@ class TOPPFileConverter : feature.setQuality(0, 1); // override default feature.setQuality(1, 1); // override default feature.setOverallQuality(1); // override default - for (MSExperimentType::ConstIterator spec_iter = exp.begin(); + for (MSExperiment::ConstIterator spec_iter = exp.begin(); spec_iter != exp.end(); ++spec_iter )