From f07e9706707671b6c1163989c871a024ea9a84f5 Mon Sep 17 00:00:00 2001 From: Joshua Charkow Date: Wed, 3 Apr 2024 12:56:27 -0400 Subject: [PATCH] feature: output peak_shape_metrics to OSW file if compute_peak_shape_metrics is enabled, output the results to the .OSW file NOTE: currently does not work in conjuction with UIS scores --- .../ANALYSIS/OPENSWATH/OpenSwathOSWWriter.h | 4 +- .../ANALYSIS/OPENSWATH/OpenSwathOSWWriter.cpp | 52 +++++++++++++++++-- src/topp/OpenSwathWorkflow.cpp | 4 +- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathOSWWriter.h b/src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathOSWWriter.h index 59cd33d37fb..f5b2ae5cc53 100644 --- a/src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathOSWWriter.h +++ b/src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathOSWWriter.h @@ -95,6 +95,7 @@ namespace OpenMS bool use_ms1_traces_; bool sonar_; bool enable_uis_scoring_; + bool enable_compute_peak_shape_metrics_; public: @@ -103,7 +104,8 @@ namespace OpenMS const String& input_filename = "inputfile", bool ms1_scores = false, bool sonar = false, - bool uis_scores = false); + bool uis_scores = false, + bool compute_peak_shape_metrics = false); bool isActive() const; diff --git a/src/openms/source/ANALYSIS/OPENSWATH/OpenSwathOSWWriter.cpp b/src/openms/source/ANALYSIS/OPENSWATH/OpenSwathOSWWriter.cpp index 15008a8bd30..e47832bf54a 100644 --- a/src/openms/source/ANALYSIS/OPENSWATH/OpenSwathOSWWriter.cpp +++ b/src/openms/source/ANALYSIS/OPENSWATH/OpenSwathOSWWriter.cpp @@ -14,14 +14,15 @@ namespace OpenMS { - OpenSwathOSWWriter::OpenSwathOSWWriter(const String& output_filename, const UInt64 run_id, const String& input_filename, bool ms1_scores, bool sonar, bool uis_scores) : + OpenSwathOSWWriter::OpenSwathOSWWriter(const String& output_filename, const UInt64 run_id, const String& input_filename, bool ms1_scores, bool sonar, bool uis_scores, bool compute_peak_shape_metrics): output_filename_(output_filename), input_filename_(input_filename), run_id_(Internal::SqliteHelper::clearSignBit(run_id)), doWrite_(!output_filename.empty()), use_ms1_traces_(ms1_scores), sonar_(sonar), - enable_uis_scoring_(uis_scores) + enable_uis_scoring_(uis_scores), + enable_compute_peak_shape_metrics_(compute_peak_shape_metrics) {} bool OpenSwathOSWWriter::isActive() const @@ -142,7 +143,23 @@ namespace OpenMS "VAR_MI_SCORE REAL NULL," \ "VAR_MI_RATIO_SCORE REAL NULL," \ "VAR_ISOTOPE_CORRELATION_SCORE REAL NULL," \ - "VAR_ISOTOPE_OVERLAP_SCORE REAL NULL);"; + "VAR_ISOTOPE_OVERLAP_SCORE REAL NULL," \ + "WIDTH_5 REAL NULL," \ + "WIDTH_10 REAL NULL," \ + "WIDTH_50 REAL NULL," \ + "START_5 REAL NULL," \ + "START_10 REAL NULL," \ + "START_50 REAL NULL," \ + "END_5 REAL NULL," \ + "END_10 REAL NULL," \ + "END_50 REAL NULL," \ + "TOTAL_WIDTH REAL NULL," \ + "TAILING_FACTOR REAL NULL," \ + "ASYMMETRY_FACTOR REAL NULL," \ + "BASELINE_SLOPE REAL NULL," \ + "BASELINE_DELTA_2_HEIGHT REAL NULL," \ + "POINTS_ACROSS_BASELINE REAL NULL," \ + "POINTS_ACROSS_HALF_HEIGHT REAL NULL);"; // Execute SQL create statement conn.executeStatement(create_sql); @@ -221,13 +238,38 @@ namespace OpenMS total_mi = sub_it.getMetaValue("total_mi").toString(); } sql_feature_ms2_transition << "INSERT INTO FEATURE_TRANSITION "\ - "(FEATURE_ID, TRANSITION_ID, AREA_INTENSITY, TOTAL_AREA_INTENSITY, APEX_INTENSITY, TOTAL_MI) VALUES (" + "(FEATURE_ID, TRANSITION_ID, AREA_INTENSITY, TOTAL_AREA_INTENSITY, APEX_INTENSITY, TOTAL_MI" + << (enable_compute_peak_shape_metrics_ ? ", WIDTH_5, WIDTH_10, WIDTH_50, START_5, START_10, START_50, END_5, END_10, END_50, TOTAL_WIDTH, TAILING_FACTOR, ASYMMETRY_FACTOR, BASELINE_SLOPE, BASELINE_DELTA_2_HEIGHT, POINTS_ACROSS_BASELINE, POINTS_ACROSS_HALF_HEIGHT" : "") + << ") VALUES (" << feature_id << ", " << sub_it.getMetaValue("native_id") << ", " << sub_it.getIntensity() << ", " << sub_it.getMetaValue("total_xic") << ", " << sub_it.getMetaValue("peak_apex_int") << ", " - << total_mi << "); "; + << total_mi; + + if (enable_compute_peak_shape_metrics_) + { + sql_feature_ms2_transition << ", " + << sub_it.getMetaValue("width_at_5") << ", " + << sub_it.getMetaValue("width_at_10") << ", " + << sub_it.getMetaValue("width_at_50") << ", " + << sub_it.getMetaValue("start_position_at_5") << ", " + << sub_it.getMetaValue("start_position_at_10") << ", " + << sub_it.getMetaValue("start_position_at_50") << ", " + << sub_it.getMetaValue("end_position_at_5") << ", " + << sub_it.getMetaValue("end_position_at_10") << ", " + << sub_it.getMetaValue("end_position_at_50") << ", " + << sub_it.getMetaValue("total_width") << ", " + << sub_it.getMetaValue("tailing_factor") << ", " + << sub_it.getMetaValue("asymmetry_factor") << ", " + << sub_it.getMetaValue("slope_of_baseline") << ", " + << sub_it.getMetaValue("baseline_delta_2_height") << ", " + << sub_it.getMetaValue("points_across_baseline") << ", " + << sub_it.getMetaValue("points_across_half_height"); + } + + sql_feature_ms2_transition << "); "; } else if (sub_it.metaValueExists("FeatureLevel") && sub_it.getMetaValue("FeatureLevel") == "MS1" && sub_it.getIntensity() > 0.0) { diff --git a/src/topp/OpenSwathWorkflow.cpp b/src/topp/OpenSwathWorkflow.cpp index 59006d706ff..86e1b9a431f 100644 --- a/src/topp/OpenSwathWorkflow.cpp +++ b/src/topp/OpenSwathWorkflow.cpp @@ -755,6 +755,8 @@ class TOPPOpenSwathWorkflow Param feature_finder_param = getParam_().copy("Scoring:", true); feature_finder_param.setValue("use_ms1_ion_mobility", getStringOption_("use_ms1_ion_mobility")); + bool compute_peak_shape_metrics = feature_finder_param.getValue("TransitionGroupPicker:compute_peak_shape_metrics").toBool(); + Param tsv_reader_param = getParam_().copy("Library:", true); if (use_emg_score) { @@ -921,7 +923,7 @@ class TOPPOpenSwathWorkflow /////////////////////////////////// FeatureMap out_featureFile; OpenSwathTSVWriter tsvwriter(out_tsv, file_list[0], use_ms1_traces, sonar); // only active if filename not empty - OpenSwathOSWWriter oswwriter(out_osw, run_id, file_list[0], use_ms1_traces, sonar, enable_uis_scoring); // only active if filename not empty + OpenSwathOSWWriter oswwriter(out_osw, run_id, file_list[0], use_ms1_traces, sonar, enable_uis_scoring, compute_peak_shape_metrics); // only active if filename not empty /////////////////////////////////// // Extract and score