71 const String& input_filename =
"inputfile",
72 bool ms1_scores =
false,
74 bool uis_scores =
false) :
75 output_filename_(output_filename),
76 input_filename_(input_filename),
78 doWrite_(!output_filename.empty()),
79 use_ms1_traces_(ms1_scores),
81 enable_uis_scoring_(uis_scores)
84 static int callback(
void * ,
int argc,
char **argv,
char **azColName)
89 printf(
"%s = %s\n", azColName[i], argv[i] ? argv[i] :
"NULL");
107 char *zErrMsg =
nullptr;
111 rc = sqlite3_open(output_filename_.c_str(), &db);
114 fprintf(stderr,
"Can't open database: %s\n", sqlite3_errmsg(db));
118 const char * create_sql =
119 "CREATE TABLE RUN(" \
120 "ID INT PRIMARY KEY NOT NULL," \
121 "FILENAME TEXT NOT NULL); " \
123 "CREATE TABLE FEATURE(" \
124 "ID INT PRIMARY KEY NOT NULL," \
125 "RUN_ID INT NOT NULL," \
126 "PRECURSOR_ID INT NOT NULL," \
127 "EXP_RT REAL NOT NULL," \
128 "NORM_RT REAL NOT NULL," \
129 "DELTA_RT REAL NOT NULL," \
130 "LEFT_WIDTH REAL NOT NULL," \
131 "RIGHT_WIDTH REAL NOT NULL); " \
133 "CREATE TABLE FEATURE_MS1(" \
134 "FEATURE_ID INT NOT NULL," \
135 "AREA_INTENSITY REAL NOT NULL," \
136 "APEX_INTENSITY REAL NOT NULL," \
137 "VAR_MASSDEV_SCORE REAL NOT NULL," \
138 "VAR_MI_SCORE REAL NULL," \
139 "VAR_ISOTOPE_CORRELATION_SCORE REAL NOT NULL," \
140 "VAR_ISOTOPE_OVERLAP_SCORE REAL NOT NULL," \
141 "VAR_XCORR_COELUTION REAL NOT NULL," \
142 "VAR_XCORR_SHAPE REAL NOT NULL); " \
144 "CREATE TABLE FEATURE_MS2(" \
145 "FEATURE_ID INT NOT NULL," \
146 "AREA_INTENSITY REAL NOT NULL," \
147 "TOTAL_AREA_INTENSITY REAL NOT NULL," \
148 "APEX_INTENSITY REAL NOT NULL," \
149 "TOTAL_MI REAL NULL," \
150 "VAR_BSERIES_SCORE REAL NOT NULL," \
151 "VAR_DOTPROD_SCORE REAL NOT NULL," \
152 "VAR_INTENSITY_SCORE REAL NOT NULL," \
153 "VAR_ISOTOPE_CORRELATION_SCORE REAL NOT NULL," \
154 "VAR_ISOTOPE_OVERLAP_SCORE REAL NOT NULL," \
155 "VAR_LIBRARY_CORR REAL NOT NULL," \
156 "VAR_LIBRARY_DOTPROD REAL NOT NULL," \
157 "VAR_LIBRARY_MANHATTAN REAL NOT NULL," \
158 "VAR_LIBRARY_RMSD REAL NOT NULL," \
159 "VAR_LIBRARY_ROOTMEANSQUARE REAL NOT NULL," \
160 "VAR_LIBRARY_SANGLE REAL NOT NULL," \
161 "VAR_LOG_SN_SCORE REAL NOT NULL," \
162 "VAR_MANHATTAN_SCORE REAL NOT NULL," \
163 "VAR_MASSDEV_SCORE REAL NOT NULL," \
164 "VAR_MASSDEV_SCORE_WEIGHTED REAL NOT NULL," \
165 "VAR_MI_SCORE REAL NULL," \
166 "VAR_MI_WEIGHTED_SCORE REAL NULL," \
167 "VAR_MI_RATIO_SCORE REAL NULL," \
168 "VAR_NORM_RT_SCORE REAL NOT NULL," \
169 "VAR_XCORR_COELUTION REAL NOT NULL," \
170 "VAR_XCORR_COELUTION_WEIGHTED REAL NOT NULL," \
171 "VAR_XCORR_SHAPE REAL NOT NULL," \
172 "VAR_XCORR_SHAPE_WEIGHTED REAL NOT NULL," \
173 "VAR_YSERIES_SCORE REAL NOT NULL," \
174 "VAR_ELUTION_MODEL_FIT_SCORE REAL NULL," \
175 "VAR_SONAR_LAG REAL NULL," \
176 "VAR_SONAR_SHAPE REAL NULL," \
177 "VAR_SONAR_LOG_SN REAL NULL," \
178 "VAR_SONAR_LOG_DIFF REAL NULL," \
179 "VAR_SONAR_LOG_TREND REAL NULL," \
180 "VAR_SONAR_RSQ REAL NULL); " \
182 "CREATE TABLE FEATURE_TRANSITION(" \
183 "FEATURE_ID INT NOT NULL," \
184 "TRANSITION_ID INT NOT NULL," \
185 "AREA_INTENSITY REAL NOT NULL," \
186 "TOTAL_AREA_INTENSITY REAL NOT NULL," \
187 "APEX_INTENSITY REAL NOT NULL," \
188 "TOTAL_MI REAL NULL," \
189 "VAR_INTENSITY_SCORE REAL NULL," \
190 "VAR_INTENSITY_RATIO_SCORE REAL NULL," \
191 "VAR_LOG_INTENSITY REAL NULL," \
192 "VAR_XCORR_COELUTION REAL NULL," \
193 "VAR_XCORR_SHAPE REAL NULL," \
194 "VAR_LOG_SN_SCORE REAL NULL," \
195 "VAR_MASSDEV_SCORE REAL NULL," \
196 "VAR_MI_SCORE REAL NULL," \
197 "VAR_MI_RATIO_SCORE REAL NULL," \
198 "VAR_ISOTOPE_CORRELATION_SCORE REAL NULL," \
199 "VAR_ISOTOPE_OVERLAP_SCORE REAL NULL); " ;
203 rc = sqlite3_exec(db, create_sql, callback,
nullptr, &zErrMsg);
204 if( rc != SQLITE_OK )
206 std::string error_message = zErrMsg;
207 sqlite3_free(zErrMsg);
213 std::stringstream sql_run;
214 sql_run <<
"INSERT INTO RUN (ID, FILENAME) VALUES (" 215 << *(int64_t*)&run_id_ <<
", '" 216 << input_filename_ <<
"'); ";
219 rc = sqlite3_exec(db, sql_run.str().c_str(), callback,
nullptr, &zErrMsg);
220 if( rc != SQLITE_OK )
222 std::string error_message = zErrMsg;
223 sqlite3_free(zErrMsg);
249 std::stringstream sql, sql_feature, sql_feature_ms1, sql_feature_ms2, sql_feature_ms2_transition, sql_feature_uis_transition;
251 for (FeatureMap::iterator feature_it = output.begin(); feature_it != output.end(); ++feature_it)
253 UInt64 uint64_feature_id = feature_it->getUniqueId();
254 int64_t feature_id = *(int64_t*)&uint64_feature_id;
256 for (std::vector<Feature>::iterator sub_it = feature_it->getSubordinates().begin(); sub_it != feature_it->getSubordinates().end(); ++sub_it)
258 if (sub_it->metaValueExists(
"FeatureLevel") && sub_it->getMetaValue(
"FeatureLevel") ==
"MS2")
260 std::string total_mi =
"NULL";
261 if (!sub_it->getMetaValue(
"total_mi").isEmpty())
263 total_mi = sub_it->getMetaValue(
"total_mi").toString();
265 sql_feature_ms2_transition <<
"INSERT INTO FEATURE_TRANSITION (FEATURE_ID, TRANSITION_ID, AREA_INTENSITY, TOTAL_AREA_INTENSITY, APEX_INTENSITY, TOTAL_MI) VALUES (" 266 << feature_id <<
", " 267 << sub_it->getMetaValue(
"native_id") <<
", " 268 << sub_it->getIntensity() <<
", " 269 << sub_it->getMetaValue(
"total_xic") <<
", " 270 << sub_it->getMetaValue(
"peak_apex_int") <<
", " 271 << total_mi <<
"); ";
273 else if (sub_it->metaValueExists(
"FeatureLevel") && sub_it->getMetaValue(
"FeatureLevel") ==
"MS1")
275 std::string var_ms1_mi_score =
"NULL";
276 if (!feature_it->getMetaValue(
"var_ms1_mi_score").isEmpty())
278 var_ms1_mi_score = feature_it->getMetaValue(
"var_ms1_mi_score").toString();
280 sql_feature_ms1 <<
"INSERT INTO FEATURE_MS1 (FEATURE_ID, AREA_INTENSITY, APEX_INTENSITY, VAR_MASSDEV_SCORE, VAR_MI_SCORE, VAR_ISOTOPE_CORRELATION_SCORE, VAR_ISOTOPE_OVERLAP_SCORE, VAR_XCORR_COELUTION, VAR_XCORR_SHAPE) VALUES (" 281 << feature_id <<
", " 282 << sub_it->getIntensity() <<
", " 283 << sub_it->getMetaValue(
"peak_apex_int") <<
", " 284 << feature_it->getMetaValue(
"var_ms1_ppm_diff") <<
", " 285 << var_ms1_mi_score <<
", " 286 << feature_it->getMetaValue(
"var_ms1_isotope_correlation") <<
", " 287 << feature_it->getMetaValue(
"var_ms1_isotope_overlap") <<
", " 288 << feature_it->getMetaValue(
"var_ms1_xcorr_coelution") <<
", " 289 << feature_it->getMetaValue(
"var_ms1_xcorr_shape") <<
"); ";
293 sql_feature <<
"INSERT INTO FEATURE (ID, RUN_ID, PRECURSOR_ID, EXP_RT, NORM_RT, DELTA_RT, LEFT_WIDTH, RIGHT_WIDTH) VALUES (" 294 << feature_id <<
", '" 295 << *(int64_t*)&run_id_ <<
"', " 297 << feature_it->getRT() <<
", " 298 << feature_it->getMetaValue(
"norm_RT") <<
", " 299 << feature_it->getMetaValue(
"delta_rt") <<
", " 300 << feature_it->getMetaValue(
"leftWidth") <<
", " 301 << feature_it->getMetaValue(
"rightWidth") <<
"); ";
304 std::string var_elution_model_fit_score =
"NULL", var_sonar_lag =
"NULL", var_sonar_shape =
"NULL", var_sonar_log_sn =
"NULL", var_sonar_log_diff =
"NULL", var_sonar_log_trend =
"NULL", var_sonar_rsq =
"NULL", total_mi =
"NULL", var_mi_score =
"NULL", var_mi_weighted_score =
"NULL", var_mi_ratio_score =
"NULL";
306 if (!feature_it->getMetaValue(
"var_elution_model_fit_score").isEmpty())
308 var_elution_model_fit_score = feature_it->getMetaValue(
"var_elution_model_fit_score").toString();
310 if (!feature_it->getMetaValue(
"var_sonar_lag").isEmpty())
312 var_sonar_lag = feature_it->getMetaValue(
"var_sonar_lag").toString();
314 if (!feature_it->getMetaValue(
"var_sonar_shape").isEmpty())
316 var_sonar_shape = feature_it->getMetaValue(
"var_sonar_shape").toString();
318 if (!feature_it->getMetaValue(
"var_sonar_log_sn").isEmpty())
320 var_sonar_log_sn = feature_it->getMetaValue(
"var_sonar_log_sn").toString();
322 if (!feature_it->getMetaValue(
"var_sonar_log_diff").isEmpty())
324 var_sonar_log_diff = feature_it->getMetaValue(
"var_sonar_log_diff").toString();
326 if (!feature_it->getMetaValue(
"var_sonar_log_trend").isEmpty())
328 var_sonar_log_trend = feature_it->getMetaValue(
"var_sonar_log_trend").toString();
330 if (!feature_it->getMetaValue(
"var_sonar_rsq").isEmpty())
332 var_sonar_rsq = feature_it->getMetaValue(
"var_sonar_rsq").toString();
334 if (!feature_it->getMetaValue(
"total_mi").isEmpty())
336 total_mi = feature_it->getMetaValue(
"total_mi").toString();
338 if (!feature_it->getMetaValue(
"var_mi_score").isEmpty())
340 var_mi_score = feature_it->getMetaValue(
"var_mi_score").toString();
342 if (!feature_it->getMetaValue(
"var_mi_weighted_score").isEmpty())
344 var_mi_weighted_score = feature_it->getMetaValue(
"var_mi_weighted_score").toString();
346 if (!feature_it->getMetaValue(
"var_mi_ratio_score").isEmpty())
348 var_mi_ratio_score = feature_it->getMetaValue(
"var_mi_ratio_score").toString();
351 sql_feature_ms2 <<
"INSERT INTO FEATURE_MS2 (FEATURE_ID, AREA_INTENSITY, TOTAL_AREA_INTENSITY, APEX_INTENSITY, TOTAL_MI, VAR_BSERIES_SCORE, VAR_DOTPROD_SCORE, VAR_INTENSITY_SCORE, VAR_ISOTOPE_CORRELATION_SCORE, VAR_ISOTOPE_OVERLAP_SCORE, VAR_LIBRARY_CORR, VAR_LIBRARY_DOTPROD, VAR_LIBRARY_MANHATTAN, VAR_LIBRARY_RMSD, VAR_LIBRARY_ROOTMEANSQUARE, VAR_LIBRARY_SANGLE, VAR_LOG_SN_SCORE, VAR_MANHATTAN_SCORE, VAR_MASSDEV_SCORE, VAR_MASSDEV_SCORE_WEIGHTED, VAR_MI_SCORE, VAR_MI_WEIGHTED_SCORE, VAR_MI_RATIO_SCORE, VAR_NORM_RT_SCORE, VAR_XCORR_COELUTION,VAR_XCORR_COELUTION_WEIGHTED, VAR_XCORR_SHAPE, VAR_XCORR_SHAPE_WEIGHTED, VAR_YSERIES_SCORE, VAR_ELUTION_MODEL_FIT_SCORE, VAR_SONAR_LAG, VAR_SONAR_SHAPE, VAR_SONAR_LOG_SN, VAR_SONAR_LOG_DIFF, VAR_SONAR_LOG_TREND, VAR_SONAR_RSQ) VALUES (" 352 << feature_id <<
", " 353 << feature_it->getIntensity() <<
", " 354 << feature_it->getMetaValue(
"total_xic") <<
", " 355 << feature_it->getMetaValue(
"peak_apices_sum") <<
", " 357 << feature_it->getMetaValue(
"var_bseries_score") <<
", " 358 << feature_it->getMetaValue(
"var_dotprod_score") <<
", " 359 << feature_it->getMetaValue(
"var_intensity_score") <<
", " 360 << feature_it->getMetaValue(
"var_isotope_correlation_score") <<
", " 361 << feature_it->getMetaValue(
"var_isotope_overlap_score") <<
", " 362 << feature_it->getMetaValue(
"var_library_corr") <<
", " 363 << feature_it->getMetaValue(
"var_library_dotprod") <<
", " 364 << feature_it->getMetaValue(
"var_library_manhattan") <<
", " 365 << feature_it->getMetaValue(
"var_library_rmsd") <<
", " 366 << feature_it->getMetaValue(
"var_library_rootmeansquare") <<
", " 367 << feature_it->getMetaValue(
"var_library_sangle") <<
", " 368 << feature_it->getMetaValue(
"var_log_sn_score") <<
", " 369 << feature_it->getMetaValue(
"var_manhatt_score") <<
", " 370 << feature_it->getMetaValue(
"var_massdev_score") <<
", " 371 << feature_it->getMetaValue(
"var_massdev_score_weighted") <<
", " 372 << var_mi_score <<
", " 373 << var_mi_weighted_score <<
", " 374 << var_mi_ratio_score <<
", " 375 << feature_it->getMetaValue(
"var_norm_rt_score") <<
", " 376 << feature_it->getMetaValue(
"var_xcorr_coelution") <<
", " 377 << feature_it->getMetaValue(
"var_xcorr_coelution_weighted") <<
", " 378 << feature_it->getMetaValue(
"var_xcorr_shape") <<
", " 379 << feature_it->getMetaValue(
"var_xcorr_shape_weighted") <<
", " 380 << feature_it->getMetaValue(
"var_yseries_score") <<
", " 381 << var_elution_model_fit_score <<
", " 382 << var_sonar_lag <<
", " 383 << var_sonar_shape <<
", " 384 << var_sonar_log_sn <<
", " 385 << var_sonar_log_diff <<
", " 386 << var_sonar_log_trend <<
", " 387 << var_sonar_rsq <<
"); ";
389 if (enable_uis_scoring_)
391 std::vector<String> id_target_transition_names = ListUtils::create<String>((
String)feature_it->getMetaValue(
"id_target_transition_names"),
';');
392 std::vector<double> id_target_area_intensity = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_area_intensity"),
';');
393 std::vector<double> id_target_total_area_intensity = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_total_area_intensity"),
';');
394 std::vector<double> id_target_apex_intensity = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_apex_intensity"),
';');
395 std::vector<double> id_target_intensity_score = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_intensity_score"),
';');
396 std::vector<double> id_target_intensity_ratio_score = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_intensity_ratio_score"),
';');
397 std::vector<double> id_target_log_intensity = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_ind_log_intensity"),
';');
398 std::vector<double> id_target_ind_xcorr_coelution = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_ind_xcorr_coelution"),
';');
399 std::vector<double> id_target_ind_xcorr_shape = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_ind_xcorr_shape"),
';');
400 std::vector<double> id_target_ind_log_sn_score = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_ind_log_sn_score"),
';');
401 std::vector<double> id_target_ind_massdev_score = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_ind_massdev_score"),
';');
402 std::vector<double> id_target_ind_isotope_correlation = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_ind_isotope_correlation"),
';');
403 std::vector<double> id_target_ind_isotope_overlap = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_target_ind_isotope_overlap"),
';');
405 if ((
String)feature_it->getMetaValue(
"id_target_num_transitions") !=
"")
407 int id_target_num_transitions = feature_it->getMetaValue(
"id_target_num_transitions").toString().
toInt();
409 std::vector<std::string> id_target_total_mi(id_target_num_transitions,
"NULL");
410 if (!feature_it->getMetaValue(
"id_target_total_mi").isEmpty())
412 id_target_total_mi = ListUtils::create<std::string>((
String)feature_it->getMetaValue(
"id_target_total_mi"),
';');
415 std::vector<std::string> id_target_ind_mi_score(id_target_num_transitions,
"NULL");
416 if (!feature_it->getMetaValue(
"id_target_ind_mi_score").isEmpty() && feature_it->getMetaValue(
"id_target_ind_mi_score") !=
"")
418 id_target_ind_mi_score = ListUtils::create<std::string>((
String)feature_it->getMetaValue(
"id_target_ind_mi_score"),
';');
421 std::vector<std::string> id_target_ind_mi_ratio_score(id_target_num_transitions,
"NULL");
422 if (!feature_it->getMetaValue(
"id_target_ind_mi_ratio_score").isEmpty())
424 id_target_ind_mi_ratio_score = ListUtils::create<std::string>((
String)feature_it->getMetaValue(
"id_target_ind_mi_ratio_score"),
';');
427 for (
int i = 0; i < id_target_num_transitions; ++i)
429 if (id_target_total_mi[i] ==
"")
431 id_target_total_mi[i] =
"NULL";
433 if (id_target_ind_mi_score[i] ==
"")
435 id_target_ind_mi_score[i] =
"NULL";
437 if (id_target_ind_mi_ratio_score[i] ==
"")
439 id_target_ind_mi_ratio_score[i] =
"NULL";
442 sql_feature_uis_transition <<
"INSERT INTO FEATURE_TRANSITION (FEATURE_ID, TRANSITION_ID, AREA_INTENSITY, TOTAL_AREA_INTENSITY, APEX_INTENSITY, TOTAL_MI, VAR_INTENSITY_SCORE, VAR_INTENSITY_RATIO_SCORE, VAR_LOG_INTENSITY, VAR_XCORR_COELUTION, VAR_XCORR_SHAPE, VAR_LOG_SN_SCORE, VAR_MASSDEV_SCORE, VAR_MI_SCORE, VAR_MI_RATIO_SCORE, VAR_ISOTOPE_CORRELATION_SCORE, VAR_ISOTOPE_OVERLAP_SCORE) VALUES (" 443 << feature_id <<
", " 444 << id_target_transition_names[i] <<
", " 445 << id_target_area_intensity[i] <<
", " 446 << id_target_total_area_intensity[i] <<
", " 447 << id_target_apex_intensity[i] <<
", " 448 << id_target_total_mi[i] <<
", " 449 << id_target_intensity_score[i] <<
", " 450 << id_target_intensity_ratio_score[i] <<
", " 451 << id_target_log_intensity[i] <<
", " 452 << id_target_ind_xcorr_coelution[i] <<
", " 453 << id_target_ind_xcorr_shape[i] <<
", " 454 << id_target_ind_log_sn_score[i] <<
", " 455 << id_target_ind_massdev_score[i] <<
", " 456 << id_target_ind_mi_score[i] <<
", " 457 << id_target_ind_mi_ratio_score[i] <<
", " 458 << id_target_ind_isotope_correlation[i] <<
", " 459 << id_target_ind_isotope_overlap[i] <<
"); ";
463 std::vector<String> id_decoy_transition_names = ListUtils::create<String>((
String)feature_it->getMetaValue(
"id_decoy_transition_names"),
';');
464 std::vector<double> id_decoy_area_intensity = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_area_intensity"),
';');
465 std::vector<double> id_decoy_total_area_intensity = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_total_area_intensity"),
';');
466 std::vector<double> id_decoy_apex_intensity = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_apex_intensity"),
';');
467 std::vector<double> id_decoy_intensity_score = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_intensity_score"),
';');
468 std::vector<double> id_decoy_intensity_ratio_score = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_intensity_ratio_score"),
';');
469 std::vector<double> id_decoy_log_intensity = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_ind_log_intensity"),
';');
470 std::vector<double> id_decoy_ind_xcorr_coelution = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_ind_xcorr_coelution"),
';');
471 std::vector<double> id_decoy_ind_xcorr_shape = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_ind_xcorr_shape"),
';');
472 std::vector<double> id_decoy_ind_log_sn_score = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_ind_log_sn_score"),
';');
473 std::vector<double> id_decoy_ind_massdev_score = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_ind_massdev_score"),
';');
474 std::vector<double> id_decoy_ind_isotope_correlation = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_ind_isotope_correlation"),
';');
475 std::vector<double> id_decoy_ind_isotope_overlap = ListUtils::create<double>((
String)feature_it->getMetaValue(
"id_decoy_ind_isotope_overlap"),
';');
477 if ((
String)feature_it->getMetaValue(
"id_decoy_num_transitions") !=
"")
479 int id_decoy_num_transitions = feature_it->getMetaValue(
"id_decoy_num_transitions").toString().toInt();
481 std::vector<std::string> id_decoy_total_mi(id_decoy_num_transitions,
"NULL");
482 if (!feature_it->getMetaValue(
"id_decoy_total_mi").isEmpty())
484 id_decoy_total_mi = ListUtils::create<std::string>((
String)feature_it->getMetaValue(
"id_decoy_total_mi"),
';');
487 std::vector<std::string> id_decoy_ind_mi_score(id_decoy_num_transitions,
"NULL");
488 if (!feature_it->getMetaValue(
"id_decoy_ind_mi_score").isEmpty() && feature_it->getMetaValue(
"id_decoy_ind_mi_score") !=
"")
490 id_decoy_ind_mi_score = ListUtils::create<std::string>((
String)feature_it->getMetaValue(
"id_decoy_ind_mi_score"),
';');
493 std::vector<std::string> id_decoy_ind_mi_ratio_score(id_decoy_num_transitions,
"NULL");
494 if (!feature_it->getMetaValue(
"id_decoy_ind_mi_ratio_score").isEmpty())
496 id_decoy_ind_mi_ratio_score = ListUtils::create<std::string>((
String)feature_it->getMetaValue(
"id_decoy_ind_mi_ratio_score"),
';');
499 for (
int i = 0; i < feature_it->getMetaValue(
"id_decoy_num_transitions").toString().toInt(); ++i)
501 if (id_decoy_total_mi[i] ==
"")
503 id_decoy_total_mi[i] =
"NULL";
505 if (id_decoy_ind_mi_score[i] ==
"")
507 id_decoy_ind_mi_score[i] =
"NULL";
509 if (id_decoy_ind_mi_ratio_score[i] ==
"")
511 id_decoy_ind_mi_ratio_score[i] =
"NULL";
514 sql_feature_uis_transition <<
"INSERT INTO FEATURE_TRANSITION (FEATURE_ID, TRANSITION_ID, AREA_INTENSITY, TOTAL_AREA_INTENSITY, APEX_INTENSITY, TOTAL_MI, VAR_INTENSITY_SCORE, VAR_INTENSITY_RATIO_SCORE, VAR_LOG_INTENSITY, VAR_XCORR_COELUTION, VAR_XCORR_SHAPE, VAR_LOG_SN_SCORE, VAR_MASSDEV_SCORE, VAR_MI_SCORE, VAR_MI_RATIO_SCORE, VAR_ISOTOPE_CORRELATION_SCORE, VAR_ISOTOPE_OVERLAP_SCORE) VALUES (" 515 << feature_id <<
", " 516 << id_decoy_transition_names[i] <<
", " 517 << id_decoy_area_intensity[i] <<
", " 518 << id_decoy_total_area_intensity[i] <<
", " 519 << id_decoy_apex_intensity[i] <<
", " 520 << id_decoy_total_mi[i] <<
", " 521 << id_decoy_intensity_score[i] <<
", " 522 << id_decoy_intensity_ratio_score[i] <<
", " 523 << id_decoy_log_intensity[i] <<
", " 524 << id_decoy_ind_xcorr_coelution[i] <<
", " 525 << id_decoy_ind_xcorr_shape[i] <<
", " 526 << id_decoy_ind_log_sn_score[i] <<
", " 527 << id_decoy_ind_massdev_score[i] <<
", " 528 << id_decoy_ind_mi_score[i] <<
", " 529 << id_decoy_ind_mi_ratio_score[i] <<
", " 530 << id_decoy_ind_isotope_correlation[i] <<
", " 531 << id_decoy_ind_isotope_overlap[i] <<
"); ";
537 if (enable_uis_scoring_)
539 sql << sql_feature.str() << sql_feature_ms1.str() << sql_feature_ms2.str() << sql_feature_uis_transition.str();
543 sql << sql_feature.str() << sql_feature_ms1.str() << sql_feature_ms2.str() << sql_feature_ms2_transition.str();
565 char *zErrMsg =
nullptr;
570 rc = sqlite3_open(output_filename_.c_str(), &db);
573 fprintf(stderr,
"Can't open database: %s\n", sqlite3_errmsg(db));
576 sqlite3_exec(db,
"BEGIN TRANSACTION",
nullptr,
nullptr, &zErrMsg);
578 for (
Size i = 0; i < to_osw_output.size(); i++)
580 rc = sqlite3_exec(db, to_osw_output[i].c_str(), callback,
nullptr, &zErrMsg);
581 if( rc != SQLITE_OK )
583 std::string error_message = zErrMsg;
584 sqlite3_free(zErrMsg);
590 sqlite3_exec(db,
"END TRANSACTION",
nullptr,
nullptr, &zErrMsg);
String input_filename_
Definition: OpenSwathOSWWriter.h:61
String output_filename_
Definition: OpenSwathOSWWriter.h:60
A more convenient string class.
Definition: String.h:57
void writeLines(const std::vector< String > &to_osw_output)
Write data to disk.
Definition: OpenSwathOSWWriter.h:562
A container for features.
Definition: FeatureMap.h:93
bool sonar_
Definition: OpenSwathOSWWriter.h:65
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
bool use_ms1_traces_
Definition: OpenSwathOSWWriter.h:64
static int callback(void *, int argc, char **argv, char **azColName)
Definition: OpenSwathOSWWriter.h:84
Class to write out an OpenSwath OSW SQLite output (PyProphet input)
Definition: OpenSwathOSWWriter.h:58
void writeHeader()
Initializes file by generating SQLite tables.
Definition: OpenSwathOSWWriter.h:104
bool enable_uis_scoring_
Definition: OpenSwathOSWWriter.h:66
A generator for unique ids.
Definition: UniqueIdGenerator.h:59
A method or algorithm argument contains illegal values.
Definition: Exception.h:648
String prepareLine(const OpenSwath::LightCompound &, const OpenSwath::LightTransition *, FeatureMap &output, String id) const
Prepare a single line (feature) for output.
Definition: OpenSwathOSWWriter.h:245
Int toInt() const
Conversion to int.
bool doWrite_
Definition: OpenSwathOSWWriter.h:63
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
Definition: TransitionExperiment.h:149
OpenMS::UInt64 run_id_
Definition: OpenSwathOSWWriter.h:62
Definition: TransitionExperiment.h:46
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenSwathOSWWriter(const String &output_filename, const String &input_filename="inputfile", bool ms1_scores=false, bool sonar=false, bool uis_scores=false)
Definition: OpenSwathOSWWriter.h:70
bool isActive() const
Definition: OpenSwathOSWWriter.h:95