From 0ee728c4d09afe4177436268569e5cf2aa0355f4 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Sat, 31 Aug 2019 18:29:40 +0200 Subject: [PATCH] C: build_ref_db: now adds a comment with the threshold used to build the DB --- src/build_reference_db.c | 23 ++++++++++++++++++++++- src/build_reference_db.h | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/build_reference_db.c b/src/build_reference_db.c index 260474c..1948270 100755 --- a/src/build_reference_db.c +++ b/src/build_reference_db.c @@ -29,6 +29,7 @@ #include "obi_lcs.h" #include "obidms_taxonomy.h" #include "obidmscolumn_array.h" +#include "libjson/json_utils.h" #define DEBUG_LEVEL 0 // TODO has to be defined somewhere else (cython compil flag?) @@ -167,6 +168,8 @@ int build_reference_db(const char* dms_name, obifloat_t score_array_writable[1000]; bool modified; bool merged; + char threshold_str[5]; + char* new_comments; // Discuss keeping the matrix view or not matrix_view_name = calloc((strlen(o_view_name)+strlen("_matrix")+1), sizeof(char)); @@ -185,7 +188,7 @@ int build_reference_db(const char* dms_name, "", "", matrix_view_name, - "{}", // TODO proper comments? + "{}", false, false, threshold, true, 0, true, 1) < 0) @@ -788,6 +791,24 @@ int build_reference_db(const char* dms_name, } } + // Add information about the threshold used to build the DB + snprintf(threshold_str, 5, "%f", threshold); + + new_comments = obi_add_comment((o_view->infos)->comments, DB_THRESHOLD_KEY_IN_COMMENTS, threshold_str); + if (new_comments == NULL) + { + obidebug(1, "\nError adding a comment (db threshold) to a view, key: %s, value: %s", DB_THRESHOLD_KEY_IN_COMMENTS, threshold_str); + return -1; + } + + if (obi_view_write_comments(o_view, new_comments) < 0) + { + obidebug(1, "\nError adding a comment (db threshold) to a view, key: %s, value: %s", DB_THRESHOLD_KEY_IN_COMMENTS, threshold_str); + return -1; + } + + free(new_comments); + // Close views and DMS if (obi_save_and_close_view(refs_view) < 0) { diff --git a/src/build_reference_db.h b/src/build_reference_db.h index 3f3bc33..5365f68 100755 --- a/src/build_reference_db.h +++ b/src/build_reference_db.h @@ -21,6 +21,7 @@ #define LCA_TAXID_COLUMN_NAME "LCA_TAXID" #define LCA_TAXID_ARRAY_COLUMN_NAME "LCA_TAXID" #define LCA_SCORE_ARRAY_COLUMN_NAME "LCA_SCORE" +#define DB_THRESHOLD_KEY_IN_COMMENTS "ref_db_threshold" /** @@ -28,6 +29,9 @@ * * Note: The columns where the results are written are automatically named and created. * + * Note: The threshold used to build the db is saved in the view's comments with the key + * defined by the DB_THRESHOLD_KEY_IN_COMMENTS macro. + * * @param dms_name The name of the DMS. * @param refs_view_name The name of the view containing the reference sequences annotated with their taxids. * @param taxonomy_name The name of the taxonomy stored in the DMS.