Skip to content

Commit

Permalink
feature: output peak_shape_metrics to OSW file
Browse files Browse the repository at this point in the history
if compute_peak_shape_metrics is enabled, output the results to the .OSW
file

NOTE: currently does not work in conjuction with UIS scores
  • Loading branch information
jcharkow committed Apr 3, 2024
1 parent c435a61 commit f07e970
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ namespace OpenMS
bool use_ms1_traces_;
bool sonar_;
bool enable_uis_scoring_;
bool enable_compute_peak_shape_metrics_;

public:

Expand All @@ -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;

Expand Down
52 changes: 47 additions & 5 deletions src/openms/source/ANALYSIS/OPENSWATH/OpenSwathOSWWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 3 additions & 1 deletion src/topp/OpenSwathWorkflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f07e970

Please sign in to comment.