Commit 9080bc30 authored by Mikaël Salson's avatar Mikaël Salson

Merge branch 'feature-a/3360-warnings' into 'dev'

Better handling of warnings

Closes #3811

See merge request !711
parents b878a714 1b93d0a7
Pipeline #150557 failed with stages
in 7 minutes and 43 seconds
......@@ -53,8 +53,11 @@ void CloneOutput::setSeg(string subkey, json val)
set(KEY_SEG, subkey, val);
}
void Output::add_warning(string code, string msg, string level)
void Output::add_warning(string code, string msg, string level, bool phony)
{
if (phony) {
cout << WARNING_STRING << "(" + code + ")" << " " << msg << endl;
}
json_add_warning(j, code, msg, level);
}
......
......@@ -26,7 +26,7 @@ public:
void set(string key, string subkey, json val);
void set(string key, string subkey, string subsubkey, json val);
void add_warning(string code, string msg, string level);
void add_warning(string code, string msg, string level, bool phony=true);
};
......
......@@ -1336,7 +1336,7 @@ void FineSegmenter::findCDR3(){
// Reminder: JUNCTIONstart is 1-based
}
void FineSegmenter::checkWarnings(CloneOutput *clone)
void FineSegmenter::checkWarnings(CloneOutput *clone, bool phony)
{
if (isSegmented())
{
......@@ -1345,7 +1345,7 @@ void FineSegmenter::checkWarnings(CloneOutput *clone)
&& (box_J->ref_label.find("IGHJ1") != string::npos)
&& ((getMidLength() >= 90) || (getMidLength() <= 94)))
{
clone->add_warning("W61", "Non-recombined D7-27/J1 sequence", LEVEL_ERROR);
clone->add_warning(W61_NON_RECOMBINED_D7_27_J1, "Non-recombined D7-27/J1 sequence", LEVEL_ERROR, phony);
}
// Multiple candidate assignations
......@@ -1357,7 +1357,7 @@ void FineSegmenter::checkWarnings(CloneOutput *clone)
if (it.first < box->score[0].first) break;
genes += " " + box->rep->label(it.second);
}
clone->add_warning("W69", "Several genes with equal probability:" + genes, LEVEL_WARN);
clone->add_warning("W69", "Several genes with equal probability:" + genes, LEVEL_WARN, phony);
}
}
}
......
......@@ -405,7 +405,7 @@ class FineSegmenter : public Segmenter
*/
void findCDR3();
void checkWarnings(CloneOutput *clone);
void checkWarnings(CloneOutput *clone, bool phony=true);
void toOutput(CloneOutput *clone);
};
......
......@@ -47,6 +47,7 @@ typedef string junction ;
#include "../lib/gzstream.h"
#include "kmeraffect.h"
#include "../lib/json_fwd.hpp"
#include "warnings.h"
using json = nlohmann::json;
using namespace std;
......
// Warning codes
// The reference for such warnings is `doc/warnings.md`
#define W09_INTERRUPTED "W09" // Program interrupted, output data may be not complete
#define W20_VERY_FEW_RECOMBINATIONS "W20" // Very few V(D)J recombinations found
#define W50_WINDOW "W50" // Short or shifted window
#define W51_LOW_COVERAGE "W51" // Low coverage
#define W53_SIMILAR_TO_ANOTHER_CLONE "W53" // Similar to another clone
#define W61_NON_RECOMBINED_D7_27_J1 "W61" // Non-recombined D7-27/J1 sequence
#define W67_EQUIPROBABLE_GENES "W67" // Several V/J candidate genes with equal probability
\ No newline at end of file
......@@ -36,8 +36,7 @@ WindowsStorage *WindowExtractor::extract(OnlineBioReader *reads,
if (global_interrupted)
{
string msg = "Interrupted after processing " + string_of_int(nb_reads) + " reads" ;
if (output) output->add_warning("W09", msg, LEVEL_WARN);
cout << WARNING_STRING << msg << endl ;
if (output) output->add_warning(W09_INTERRUPTED, msg, LEVEL_WARN);
break;
}
......
......@@ -281,7 +281,7 @@ void WindowsStorage::sortedWindowsToOutput(SampleOutput *output, int max_output,
CloneOutput *clone = output->getClone(it->first);
if (status_by_window[it->first][SEG_CHANGED_WINDOW])
clone->add_warning("W50", "Short or shifted window", LEVEL_WARN);
clone->add_warning(W50_WINDOW, "Short or shifted window", LEVEL_WARN);
clone->set("id", it->first);
clone->set("reads", {it->second});
......
!LAUNCH: $VIDJIL_DIR/$EXEC -c designations -g $VIDJIL_DIR/germline/homo-sapiens.g $VIDJIL_DATA/3344-bad-filtering.fa
$ Check that proper filtering is used
1: IGHV4-31.02
: IGHV4-31.02
$ Warning W69
:\[warning\] .W69. Several genes with equal probability
......@@ -12,4 +12,4 @@ $ Correct (non-)recombination
$ Warning
1: "code": "W61"
1: "msg": "Non-recombined D7-27/J1 sequence"
1: .warning. .W61.
......@@ -15,6 +15,8 @@ $ There is a warning on multiple candidate assignations
1:"code": "W69"
1:equal probability: TRBV7-2.0[12] TRBV7-2.0[12]"
$ The warning is also found on stdout
1:\[warning\] \(W69\) Several genes with equal probability
!LAUNCH: $VIDJIL_DIR/$EXEC -c designations -g $VIDJIL_DIR/germline/homo-sapiens.g:TRB $VIDJIL_DATA/trb-only-VJ.fa
!OUTPUT_FILE: out/trb-only-VJ.vidjil
......
......@@ -4,4 +4,4 @@ $ No clustering due to -w all
1: considering all analyzed reads as windows
$ Warning on similar clones in json ('warn' because this is a clone in the first 10 clones)
1: "code": "W53", "level": "warn", "msg": "Similar to another clone IGHV3-48.01 .* IGHJ4.02"
1: "code": "W53", "level": "warn", "msg": "Similar to clone #1 .* IGHV3-48.01 .* IGHJ4.02"
......@@ -1161,7 +1161,7 @@ int main (int argc, char **argv)
// warn if there are too few segmented sequences
if (ratio_segmented < WARN_PERCENT_SEGMENTED)
{
output.add_warning("W20", "Very few V(D)J recombinations found: " + fixed_string_of_float(ratio_segmented, 2) + "%", LEVEL_WARN);
output.add_warning(W20_VERY_FEW_RECOMBINATIONS, "Very few V(D)J recombinations found: " + fixed_string_of_float(ratio_segmented, 2) + "%", LEVEL_WARN);
stream_segmentation_info << " ! There are not so many CDR3 windows found in this set of reads." << endl ;
stream_segmentation_info << " ! Please check the causes below and refer to " DOCUMENTATION "." << endl ;
}
......@@ -1319,8 +1319,7 @@ int main (int argc, char **argv)
if (global_interrupted)
{
string msg = "Interrupted after analyzing " + string_of_int(num_clone) + " clones" ;
output.add_warning("W09", msg, LEVEL_WARN);
cout << WARNING_STRING << msg << endl ;
output.add_warning(W09_INTERRUPTED, msg, LEVEL_WARN);
break;
}
......@@ -1452,7 +1451,7 @@ int main (int argc, char **argv)
});
if (repComp.getCoverage() < WARN_COVERAGE)
clone->add_warning("W51", "Low coverage: " + fixed_string_of_float(repComp.getCoverage(), 3), LEVEL_WARN);
clone->add_warning(W51_LOW_COVERAGE, "Low coverage: " + fixed_string_of_float(repComp.getCoverage(), 3), LEVEL_WARN, clone_on_stdout);
if (label.length())
clone->set("label", label) ;
......@@ -1504,10 +1503,8 @@ int main (int argc, char **argv)
if (cc)
{
if (clone_on_stdout)
cout << " (similar to Clone #" << setfill('0') << setw(WIDTH_NB_CLONES) << cc << setfill(' ') << ")";
clone->add_warning("W53", "Similar to another clone " + code,
num_clone <= WARN_NUM_CLONES_SIMILAR ? LEVEL_WARN : LEVEL_INFO);
clone->add_warning(W53_SIMILAR_TO_ANOTHER_CLONE, "Similar to clone #" + string_of_int(cc) + " - " + code,
num_clone <= WARN_NUM_CLONES_SIMILAR ? LEVEL_WARN : LEVEL_INFO, clone_on_stdout);
nb_edges++ ;
out_edges << clones_map_windows[code] + " " + it->first + " " ;
......@@ -1531,7 +1528,7 @@ int main (int argc, char **argv)
out_clone << endl;
} // end if (seg.isSegmented())
seg.checkWarnings(clone);
seg.checkWarnings(clone, clone_on_stdout);
if (output_sequences_by_cluster) // -a option, output all sequences
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment