From 1f82b4719fd296e80ef975dba6f93479bcfc71e4 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Fri, 13 Oct 2023 15:47:44 -0600 Subject: [PATCH] Per #2699, update consensus deriviation logic in tc_pairs.cc to check for required and minimum number of diagnostic members. --- src/tools/tc_utils/tc_pairs/tc_pairs.cc | 73 ++++++++++++++----- .../tc_utils/tc_pairs/tc_pairs_conf_info.cc | 16 ++-- .../tc_utils/tc_pairs/tc_pairs_conf_info.h | 4 +- 3 files changed, 64 insertions(+), 29 deletions(-) diff --git a/src/tools/tc_utils/tc_pairs/tc_pairs.cc b/src/tools/tc_utils/tc_pairs/tc_pairs.cc index 03990c95f9..93f36553fe 100644 --- a/src/tools/tc_utils/tc_pairs/tc_pairs.cc +++ b/src/tools/tc_utils/tc_pairs/tc_pairs.cc @@ -1256,12 +1256,13 @@ void derive_interp12(TrackInfoArray &tracks) { //////////////////////////////////////////////////////////////////////// int derive_consensus(TrackInfoArray &tracks) { - int i, j, k, l; + int i, j, k, l, n_diag_inputs; ConcatString cur_case; - StringArray case_list, case_cmp, req_list; + StringArray case_list, case_cmp; + StringArray req_cons_mem, req_diag_mem; TrackInfoArray con_tracks; TrackInfo new_track; - bool found, skip; + bool found, skip_cons, skip_diag; const char *sep = " "; int n_add = 0; @@ -1299,15 +1300,22 @@ int derive_consensus(TrackInfoArray &tracks) { // Initialize con_tracks.clear(); new_track.clear(); - req_list.clear(); + req_cons_mem.clear(); + req_diag_mem.clear(); + n_diag_inputs = 0; // Loop through the consensus members - for(k=0, skip=false; + for(k=0, skip_cons=false, skip_diag=false; k 0) n_diag_inputs++; found = true; mlog << Debug(5) << "[Case " << i+1 << "] For case \"" @@ -1338,38 +1347,64 @@ int derive_consensus(TrackInfoArray &tracks) { << conf_info.Consensus[j].Members[k] << "\" was not found.\n"; - // Check if it was a required model - if(conf_info.Consensus[j].Required[k]) { + // Check if it was a required diagnostics model + if(conf_info.Consensus[j].DiagRequired[k]) { mlog << Debug(4) << "[Case " << i+1 << "] For case \"" << case_list[i] - << "\" skipping consensus model \"" + << "\" skipping diagnostics for consensus model \"" + << conf_info.Consensus[j].Name + << "\" since required diagnostics member \"" + << conf_info.Consensus[j].Members[k] + << "\" was not found.\n"; + skip_diag = true; + } + + // Check if it was a required consensus model + if(conf_info.Consensus[j].ConsRequired[k]) { + mlog << Debug(4) + << "[Case " << i+1 << "] For case \"" << case_list[i] + << "\" skipping derivation of consensus model \"" << conf_info.Consensus[j].Name << "\" since required member \"" << conf_info.Consensus[j].Members[k] << "\" was not found.\n"; - skip = true; + skip_cons = true; break; } } + } // end for k // If a required member was missing, continue to the next case - if(skip) continue; + if(skip_cons) continue; + + // Check that the required number of diagnostics inputs were found + if(n_diag_inputs < conf_info.Consensus[j].MinDiagReq) { + mlog << Debug(4) + << "[Case " << i+1 << "] For case \"" << case_list[i] + << "\" skipping diagnostics for consensus model \"" + << conf_info.Consensus[j].Name + << "\" since the minimum number of required members were not found (" + << n_diag_inputs << " < " << conf_info.Consensus[j].MinDiagReq << ").\n"; + skip_diag = true; + } - // Check that the required number of tracks were found - if(con_tracks.n() < conf_info.Consensus[j].MinReq) { + // Check that the required number of consensus tracks were found + if(con_tracks.n() < conf_info.Consensus[j].MinConsReq) { mlog << Debug(4) << "[Case " << i+1 << "] For case \"" << case_list[i] - << "\" skipping consensus model \"" << conf_info.Consensus[j].Name + << "\" skipping derivation of consensus model \"" + << conf_info.Consensus[j].Name << "\" since the minimum number of required members were not found (" - << con_tracks.n() << " < " - << conf_info.Consensus[j].MinReq << ").\n"; + << con_tracks.n() << " < " << conf_info.Consensus[j].MinConsReq << ").\n"; continue; } // Derive the consensus model from the TrackInfoArray new_track = consensus(con_tracks, conf_info.Consensus[j].Name, - conf_info.Consensus[j].MinReq, req_list); + req_cons_mem, conf_info.Consensus[j].MinConsReq, + req_diag_mem, conf_info.Consensus[j].MinDiagReq, + skip_diag); if(mlog.verbosity_level() >= 5) { mlog << Debug(5) diff --git a/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc b/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc index 5cf352e6e9..14cf82ae83 100644 --- a/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc +++ b/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc @@ -240,17 +240,17 @@ void TCPairsConfInfo::process_config() { for(i=0; idict_value()->lookup_string(conf_key_name); - Consensus[i].Members = (*dict)[i]->dict_value()->lookup_string_array(conf_key_members); - Consensus[i].Required = (*dict)[i]->dict_value()->lookup_bool_array(conf_key_required); + Consensus[i].Name = (*dict)[i]->dict_value()->lookup_string(conf_key_name); + Consensus[i].Members = (*dict)[i]->dict_value()->lookup_string_array(conf_key_members); + Consensus[i].ConsRequired = (*dict)[i]->dict_value()->lookup_bool_array(conf_key_required); - // If Required is empty, default to false. - if(Consensus[i].Required.n() == 0) { + // If ConsRequired is empty, default to false. + if(Consensus[i].ConsRequired.n() == 0) { for(j=0; j " << "\"consensus." << conf_key_required @@ -260,7 +260,7 @@ void TCPairsConfInfo::process_config() { } // Conf: Consensus: min_req (error if missing) - Consensus[i].MinReq = (*dict)[i]->dict_value()->lookup_int(conf_key_min_req); + Consensus[i].MinConsReq = (*dict)[i]->dict_value()->lookup_int(conf_key_min_req); // Conf: Consensus: diag_required (warn if missing) Consensus[i].DiagRequired = (*dict)[i]->dict_value()->lookup_bool_array(conf_key_diag_required, false); diff --git a/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.h b/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.h index 6d40592717..8354c3405a 100644 --- a/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.h +++ b/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.h @@ -27,8 +27,8 @@ struct ConsensusInfo { ConcatString Name; StringArray Members; - BoolArray Required; - int MinReq; + BoolArray ConsRequired; + int MinConsReq; BoolArray DiagRequired; int MinDiagReq; bool WriteMembers;