Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] FileConverter FeatureXML to OMS #17

Open
wants to merge 4 commits into
base: idfile-integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion THIRDPARTY
Submodule THIRDPARTY updated 790 files
1 change: 1 addition & 0 deletions src/openms/include/OpenMS/FORMAT/OMSFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ namespace OpenMS

protected:

// qint64 as key for unique_id, due to sqlite restriction to signed integers.
using Key = qint64;

LogType log_type_;
Expand Down
10 changes: 5 additions & 5 deletions src/openms/source/FORMAT/OMSFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
}


Expand Down Expand Up @@ -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?
Expand Down
44 changes: 30 additions & 14 deletions src/topp/FileConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@
#include <OpenMS/FORMAT/IBSpectraFile.h>
#include <OpenMS/FORMAT/SqMassFile.h>
#include <OpenMS/FORMAT/CachedMzML.h>
#include <OpenMS/FORMAT/OMSFile.h>
#include <OpenMS/DATASTRUCTURES/StringListUtils.h>
#include <OpenMS/APPLICATIONS/TOPPBase.h>
#include <OpenMS/KERNEL/ConversionHelper.h>
#include <OpenMS/KERNEL/ChromatogramTools.h>

#include <OpenMS/FORMAT/DATAACCESS/MSDataWritingConsumer.h>
#include <OpenMS/FORMAT/DATAACCESS/MSDataCachedConsumer.h>
#include <OpenMS/METADATA/ID/IdentificationDataConverter.h>




using namespace OpenMS;
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -338,7 +343,7 @@ class TOPPFileConverter :
String method("none,ensure,reassign");
setValidStrings_("UID_postprocessing", ListUtils::create<String>(method));

vector<String> output_formats = {"mzML", "mzXML", "cachedMzML", "mgf", "featureXML", "consensusXML", "edta", "mzData", "dta2d", "csv", "sqmass"};
vector<String> output_formats = {"mzML", "mzXML", "cachedMzML", "mgf", "featureXML", "consensusXML", "edta", "mzData", "dta2d", "csv", "sqmass","oms"};
registerOutputFile_("out", "<file>", "", "Output file");
setValidFormats_("out", output_formats);
registerStringOption_("out_type", "<type>", "", "Output file type -- default: determined from file extension or content\nNote: that not all conversion paths work or make sense.", false, true);
Expand Down Expand Up @@ -429,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);
Expand Down Expand Up @@ -504,7 +504,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.");
Expand Down Expand Up @@ -710,7 +711,7 @@ class TOPPFileConverter :
CONVERSION_MZDATA));
MzDataFile f;
f.setLogType(log_type_);
ChromatogramTools().convertChromatogramsToSpectra<MSExperimentType>(exp);
ChromatogramTools().convertChromatogramsToSpectra<MSExperiment>(exp);
f.store(out, exp);
}
else if (out_type == FileTypes::MZXML)
Expand All @@ -722,7 +723,7 @@ class TOPPFileConverter :
f.setLogType(log_type_);
f.getOptions().setForceMQCompatability(force_MaxQuant_compatibility);
f.getOptions().setWriteIndex(write_scan_index);
//ChromatogramTools().convertChromatogramsToSpectra<MSExperimentType>(exp);
//ChromatogramTools().convertChromatogramsToSpectra<MSExperiment>(exp);
f.store(out, exp);
}
else if (out_type == FileTypes::DTA2D)
Expand All @@ -732,7 +733,7 @@ class TOPPFileConverter :
FORMAT_CONVERSION));
DTA2DFile f;
f.setLogType(log_type_);
ChromatogramTools().convertChromatogramsToSpectra<MSExperimentType>(exp);
ChromatogramTools().convertChromatogramsToSpectra<MSExperiment>(exp);
if (TIC_DTA2D)
{
// store the total ion chromatogram (TIC)
Expand Down Expand Up @@ -773,6 +774,11 @@ class TOPPFileConverter :
{
MapConversion::convert(cm, true, fm);
}
else if (in_type == FileTypes::OMS)
{
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!
Expand All @@ -783,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
)
Expand Down Expand Up @@ -880,6 +886,16 @@ 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;
}
IdentificationDataConverter::importFeatureIDs(fm);
OMSFile().store(out, fm);
oliveralka marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
writeLog_("Unknown output file type given. Aborting!");
Expand Down