MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / storeConsensusFeatures_

Method storeConsensusFeatures_

src/openms/source/FORMAT/OMSFileStore.cpp:1499–1573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1497
1498
1499 void OMSFileStore::storeConsensusFeatures_(const ConsensusMap& consensus)
1500 {
1501 if (consensus.empty()) return;
1502
1503 // create table(s) for BaseFeature parent class:
1504 // any meta infos on features?
1505 bool any_metainfo = any_of(consensus.begin(), consensus.end(), [](const ConsensusFeature& feature) {
1506 return !feature.isMetaEmpty();
1507 });
1508 // any ID observations on features?
1509 bool any_idmatches = any_of(consensus.begin(), consensus.end(), [](const ConsensusFeature& feature) {
1510 return !feature.getIDMatches().empty();
1511 });
1512 createTableBaseFeature_(any_metainfo, any_idmatches);
1513
1514 createTable_("FEAT_FeatureHandle",
1515 "feature_id INTEGER NOT NULL, " \
1516 "map_index INTEGER NOT NULL, " \
1517 "FOREIGN KEY (feature_id) REFERENCES FEAT_BaseFeature (id)");
1518 SQLite::Statement query_handle(*db_,
1519 "INSERT INTO FEAT_FeatureHandle VALUES (" \
1520 ":feature_id, " \
1521 ":map_index)");
1522
1523 // any ratios on consensus features?
1524 unique_ptr<SQLite::Statement> query_ratio; // only assign if needed below
1525 if (any_of(consensus.begin(), consensus.end(), [](const ConsensusFeature& feature) {
1526 return !feature.getRatios().empty();
1527 }))
1528 {
1529 createTable_("FEAT_ConsensusRatio",
1530 "feature_id INTEGER NOT NULL, " \
1531 "ratio_index INTEGER NOT NULL CHECK (ratio_index >= 0), " \
1532 "ratio_value REAL, " \
1533 "denominator_ref TEXT, " \
1534 "numerator_ref TEXT, " \
1535 "description TEXT, " \
1536 "FOREIGN KEY (feature_id) REFERENCES FEAT_BaseFeature (id)");
1537 query_ratio = make_unique<SQLite::Statement>(*db_, "INSERT INTO FEAT_ConsensusRatio VALUES (" \
1538 ":feature_id, " \
1539 ":ratio_index, " \
1540 ":ratio_value, " \
1541 ":denominator_ref, " \
1542 ":numerator_ref, " \
1543 ":description)");
1544 }
1545
1546 // consensus features and their subfeatures are stored in DFS-like order:
1547 int feature_id = 0;
1548 for (const ConsensusFeature& feat : consensus)
1549 {
1550 storeBaseFeature_(feat, feature_id, -1);
1551 int parent_id = feature_id;
1552 for (const FeatureHandle& handle : feat.getFeatures())
1553 {
1554 storeBaseFeature_(BaseFeature(handle), ++feature_id, parent_id);
1555 query_handle.bind(":feature_id", feature_id);
1556 query_handle.bind(":map_index", int64_t(handle.getMapIndex()));

Callers

nothing calls this directly

Calls 11

concatenateFunction · 0.85
isMetaEmptyMethod · 0.80
getRatiosMethod · 0.80
getFeaturesMethod · 0.80
BaseFeatureFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getMapIndexMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected