reporting::reportManager Class Reference

Class that allows us to centralize all the reporting messages that should be used to inform the user of Errors, Warnings and Info.
The object can also be used as a substitute to cout for temporal messages using the << overloaded operator or the log method, and the messages will be behind the IsDebug variable, which should be set to false in Release.
This allows us to protect the user from receiving Debug/Developing messages that shouldn't bother them, in case any of them is not removed by error. More...

#include <reportsystem.h>

Public Member Functions

void PrintCodesAndMessages ()
 Method to print all Info, Warning and Error codes and their respective message.
This method is useful to check whether all codes have a message linked to them. It will use the current VerboseLevel of the object, which defaults to ERROR level. More...
 
void report (ErrorCode message, std::string *vars=nullptr)
 Method to report an Error.
It will be displayed if Level is equal or higher to VerboseLevel::ERROR. More...
 
void report (ErrorCode message, const char *vars)
 Method to report an Error.
It will be displayed if Level is equal or higher to VerboseLevel::ERROR. More...
 
void report (WarningCode message, std::string *vars=nullptr)
 Method to report a Warning.
It will be displayed if Level is equal or higher to VerboseLevel::WARNING. More...
 
void report (WarningCode message, const char *vars)
 Method to report a Warning.
It will be displayed if Level is equal or higher to VerboseLevel::WARNING. More...
 
void report (InfoCode message, std::string *vars=nullptr)
 Method to report an Info message.
It will be displayed if Level is equal or higher to VerboseLevel::INFO. More...
 
void report (InfoCode message, const char *vars)
 Method to report an Info message.
It will be displayed if Level is equal or higher to VerboseLevel::WARNING. More...
 
reportWrapper log (VerboseLevel level)
 Method to output a message behind two checks: IsDebug and VerboseLevel passed.
If IsDebug is false, it will ignore the message returning the cantReport , otherwise, VerboseLevel level will be checked. More...
 
template<typename T >
reportManageroperator<< (const T &a)
 Overloaded operator that allows us to debug some messages behind IsDebug . More...
 
reportManageroperator<< (std::ostream &(*pf)(std::ostream &))
 Overloaded operator that allows us to debug some messages behind IsDebug . More...
 

Public Attributes

VerboseLevel Level = VerboseLevel::INFO
 Level of Verbosity.
The report system won't output messages that are lower than the current level. More...
 
bool IsDebug = false
 Protection variable. This variable should be set to true while in development, and false on Release. More...
 

Private Attributes

reportWrapper canReport = reportWrapper(true)
 Object that will be returned by log if it allows to output the message. More...
 
reportWrapper cantReport = reportWrapper(false)
 Object that will be returned by log if it doesn't allow to output the message. More...
 

Static Private Attributes

static const std::map< InfoCode, const char * > InfoMessages
 
static const std::map< WarningCode, const char * > WarningMessages
 
static const std::map< ErrorCode, const char * > ErrorMessages
 

Related Functions

(Note that these are not member functions.)

reporting::reportManager debug
  This instance is the one that should be used
It's use is similar to a singleton, without the need to obtain the instance every time it's needed.
Instead, it's a global instance of the reporting::reportManager
This allows us to have the '<<' operator overloaded, as it can't be statically overloaded. More...
 

Detailed Description

Class that allows us to centralize all the reporting messages that should be used to inform the user of Errors, Warnings and Info.
The object can also be used as a substitute to cout for temporal messages using the << overloaded operator or the log method, and the messages will be behind the IsDebug variable, which should be set to false in Release.
This allows us to protect the user from receiving Debug/Developing messages that shouldn't bother them, in case any of them is not removed by error.

Warning
THIS CLASS SHOULDN'T BE USED DIRECTLY
Use instanced global variable debug instead.

Definition at line 354 of file reportsystem.h.

Member Function Documentation

◆ log()

reportWrapper reporting::reportManager::log ( VerboseLevel  level)
inline

Method to output a message behind two checks: IsDebug and VerboseLevel passed.
If IsDebug is false, it will ignore the message returning the cantReport , otherwise, VerboseLevel level will be checked.

Parameters
levelLevel to use for this message.
If Level is higher than this argument, message will be ignored, otherwise, message will be outputted to cout.

Definition at line 494 of file reportsystem.h.

References canReport, cantReport, IsDebug, and Level.

◆ operator<<() [1/2]

template<typename T >
reportManager& reporting::reportManager::operator<< ( const T &  a)
inline

Overloaded operator that allows us to debug some messages behind IsDebug .

Parameters
aMessage to be outputed if IsDebug

Definition at line 512 of file reportsystem.h.

References IsDebug.

◆ operator<<() [2/2]

reportManager& reporting::reportManager::operator<< ( std::ostream &(*)(std::ostream &)  pf)
inline

Overloaded operator that allows us to debug some messages behind IsDebug .

Parameters
pfObject that overloads the '<<' operator

Definition at line 524 of file reportsystem.h.

References IsDebug.

◆ PrintCodesAndMessages()

void reporting::reportManager::PrintCodesAndMessages ( )

Method to print all Info, Warning and Error codes and their respective message.
This method is useful to check whether all codes have a message linked to them. It will use the current VerboseLevel of the object, which defaults to ERROR level.

Definition at line 35 of file reportsystem.cpp.

References __MAXERROR, __MAXINFO, __MAXWARNING, ERROR, INFO, Level, NONE, report(), and WARNING.

+ Here is the call graph for this function:

◆ report() [1/6]

void reporting::reportManager::report ( ErrorCode  message,
std::string *  vars = nullptr 
)

Method to report an Error.
It will be displayed if Level is equal or higher to VerboseLevel::ERROR.

Parameters
messageCode to report.
varsArray of strings that will replace the '[tags]' in the message.
The number of elements in the array must be the same as [tag] occurrences on the message.
The method will take care of destroying the array

Definition at line 67 of file reportsystem.cpp.

References ERROR, ErrorMessages, and Level.

Referenced by Alignment::alignmentSummaryHTML(), Alignment::alignmentSummarySVG(), statistics::Gaps::applyWindow(), statistics::Mold::applyWindow(), statistics::Consistency::applyWindow(), statistics::Similarity::applyWindow(), trimAlManager::block_argument(), trimAlManager::check_absolute_gap_theshold(), trimAlManager::check_automated_manual_incompatibilities(), trimAlManager::check_automated_methods_incompatibilities(), trimAlManager::check_backtranslations(), trimAlManager::check_block_size(), trimAlManager::check_clusters_incompatibilities(), trimAlManager::check_coding_sequences_type(), trimAlManager::check_codon_behaviour_incompatibility(), trimAlManager::check_col_numbering(), trimAlManager::check_combinations_among_thresholds_incompatibility(), trimAlManager::check_file_aligned(), trimAlManager::check_force_selection(), trimAlManager::check_inFile_incompatibilities(), trimAlManager::check_input_file_with_coding_sequences_argument(), trimAlManager::check_max_identity_incompatibilities(), trimAlManager::check_output_file_with_statistics(), trimAlManager::check_output_relevance(), trimAlManager::check_outputs_coincidence(), trimAlManager::check_residue_and_sequence_overlap(), trimAlManager::check_select_cols_and_seqs_incompatibilities(), trimAlManager::check_similarity_matrix(), trimAlManager::check_stats_incompatibilities(), trimAlManager::check_thresholds_incompatibilities(), trimAlManager::check_windows_incompatibilities(), Alignment::checkCorrespondence(), trimAlManager::CleanResiduesNonAuto(), trimAlManager::clusters_argument(), statistics::Consistency::compareAndChoose(), trimAlManager::conservation_threshold_argument(), trimAlManager::consistency_threshold_argument(), trimAlManager::consistency_window_argument(), trimAlManager::create_or_use_similarity_matrix(), Alignment::fillMatrices(), trimAlManager::force_select_argument(), statistics::Consistency::forceComparison(), trimAlManager::gap_threshold_argument(), trimAlManager::gap_window_argument(), statistics::similarityMatrix::getDistance(), trimAlManager::in_argument(), trimAlManager::max_identity_argument(), trimAlManager::min_coverage_argument(), trimAlManager::min_quality_argument(), trimAlManager::out_format_arguments(), trimAlManager::output_reports(), trimAlManager::parseArguments(), statistics::Consistency::perform(), trimAlManager::performCompareset(), Alignment::prepareCodingSequence(), PrintCodesAndMessages(), Cleaner::removeOnlyTerminal(), trimAlManager::residue_overlap_argument(), FormatHandling::FormatManager::saveAlignments(), trimAlManager::select_cols_argument(), trimAlManager::seqs_select_argument(), trimAlManager::sequence_overlap_argument(), trimAlManager::similarity_threshold_argument(), trimAlManager::similarity_window_argument(), utils::trimLine(), trimAlManager::verbosity_argument(), and trimAlManager::window_argument().

◆ report() [2/6]

void reporting::reportManager::report ( ErrorCode  message,
const char *  vars 
)

Method to report an Error.
It will be displayed if Level is equal or higher to VerboseLevel::ERROR.

Parameters
messageCode to report.
varsArray of chars that will replace the first occurrence of '[tags]' in the message.
The method wont take care of destroying the array
This allows to reuse the parameter passed.

Definition at line 95 of file reportsystem.cpp.

References ERROR, ErrorMessages, and Level.

Referenced by trimAlManager::back_trans_argument(), trimAlManager::check_vcf_incompatibility(), trimAlManager::clean_alignment(), trimAlManager::compareset_argument(), trimAlManager::force_select_argument(), FormatHandling::FormatManager::getFormatFromFile(), FormatHandling::FormatManager::getNonEmptyFile(), FormatHandling::FormatManager::loadAlignment(), trimAlManager::matrix_argument(), trimAlManager::out_format_arguments(), trimAlManager::parseArguments(), trimAlManager::save_alignment(), and FormatHandling::FormatManager::saveAlignments().

+ Here is the caller graph for this function:

◆ report() [3/6]

void reporting::reportManager::report ( WarningCode  message,
std::string *  vars = nullptr 
)

Method to report a Warning.
It will be displayed if Level is equal or higher to VerboseLevel::WARNING.

Parameters
messageCode to report.
varsArray of strings that will replace the '[tags]' in the message.
The number of elements in the array must be the same as [tag] occurrences on the message.
The method will take care of destroying the array

Definition at line 120 of file reportsystem.cpp.

References Level, WARNING, and WarningMessages.

Referenced by Alignment::checkCorrespondence(), PrintCodesAndMessages(), Cleaner::removeAllGapsSeqsAndCols(), and FormatHandling::FormatManager::saveAlignments().

+ Here is the caller graph for this function:

◆ report() [4/6]

void reporting::reportManager::report ( WarningCode  message,
const char *  vars 
)

Method to report a Warning.
It will be displayed if Level is equal or higher to VerboseLevel::WARNING.

Parameters
messageCode to report.
varsArray of chars that will replace the first occurrence of '[tags]' in the message.
The method wont take care of destroying the array
This allows to reuse the parameter passed.

Definition at line 148 of file reportsystem.cpp.

References Level, WARNING, and WarningMessages.

◆ report() [5/6]

void reporting::reportManager::report ( InfoCode  message,
std::string *  vars = nullptr 
)

Method to report an Info message.
It will be displayed if Level is equal or higher to VerboseLevel::INFO.

Parameters
messageCode to report.
varsArray of strings that will replace the '[tags]' in the message.
The number of elements in the array must be the same as [tag] occurrences on the message.
The method will take care of destroying the array

Definition at line 173 of file reportsystem.cpp.

References INFO, InfoMessages, and Level.

Referenced by trimAlManager::check_compareset_window_argument(), Alignment::prepareCodingSequence(), PrintCodesAndMessages(), and Cleaner::removeDuplicates().

+ Here is the caller graph for this function:

◆ report() [6/6]

void reporting::reportManager::report ( InfoCode  message,
const char *  vars 
)

Method to report an Info message.
It will be displayed if Level is equal or higher to VerboseLevel::WARNING.

Parameters
messageCode to report.
varsArray of chars that will replace the first occurrence of '[tags]' in the message.
The method wont take care of destroying the array
This allows to reuse the parameter passed.

Definition at line 201 of file reportsystem.cpp.

References INFO, InfoMessages, and Level.

Friends And Related Function Documentation

◆ debug

reporting::reportManager debug
related

This instance is the one that should be used
It's use is similar to a singleton, without the need to obtain the instance every time it's needed.
Instead, it's a global instance of the reporting::reportManager
This allows us to have the '<<' operator overloaded, as it can't be statically overloaded.

Definition at line 540 of file reportsystem.h.

Member Data Documentation

◆ canReport

reportWrapper reporting::reportManager::canReport = reportWrapper(true)
private

Object that will be returned by log if it allows to output the message.

Definition at line 362 of file reportsystem.h.

Referenced by log().

◆ cantReport

reportWrapper reporting::reportManager::cantReport = reportWrapper(false)
private

Object that will be returned by log if it doesn't allow to output the message.

Definition at line 367 of file reportsystem.h.

Referenced by log().

◆ ErrorMessages

const std::map< ErrorCode, const char * > reporting::reportManager::ErrorMessages
staticprivate
Initial value:
=
{
"Alignment not loaded: \" [tag] \" Check the file's content"},
"You must specify at least one format after the '-formats' argument"},
"Alternative matrix \" [tag] \" not recognized"},
"Reference file \" [tag] \" not loaded"},
"The gap threshold value should be between 0 and 1"},
"The gap threshold value should be a positive real number between 0 and 1"},
"The similarity threshold value should be between 0 and 1"},
"The similarity threshold value should be a positive real number between 0 and 1"},
"The consistency threshold value should be between 0 and 1"},
"The consistency threshold value should be a positive real number between 0 and 1"},
"The similarity threshold value should be between 0 and 100"},
"The similarity threshold value should be a positive real number between 0 and 100"},
"The residue overlap value should be between 0 and 1"},
"The residue overlap value should be a positive real number between 0 and 100"},
"The sequences overlap value should be between 0 and 100"},
"The sequences overlap value should be a positive real number between 0 and 100"},
"The max identity value should be between 0 and 1"},
"The max identity value should be a positive real number between 0 and 1"},
"The clusters value should be greater than 0"},
"The clusters value should be a positive integer number greater than 0"},
"The window value should be greater than 0"},
"The window value should be a positive integer number greater than 0"},
"Could not parse the -selectseqs ranges"},
"Could not parse the -selectres ranges"},
"The gap window value should be greater than 0"},
"The gap window value should be a positive integer number grater than 0"},
"The similarity window value should be greater than 0"},
"The similarity window value should be a positive integer number grater than 0"},
"The consistency window value should be greater than 0"},
"The consistency window value should be a positive integer number grater than 0"},
"The consistency window value should be greater than 0"},
"The consistency window value should be a positive integer number grater than 0"},
"Option -in not valid in combination with file comparision options: -sft || -sfc || -ct"},
"Argument [tag] is not compatible with argument [tag]"},
"Options -selectCols and -selectSeqs are not allowed in combination with threshold options: (-gt || -st || -ct || -cons)"},
"Options -selectCols and -selectSeqs are not allowed in combination with automated trimming options: (-nogaps || -noallgaps || -gappyout || -strict || -strictplus || -automated1)."},
"Options -selectCols and -selectSeqs are not allowed in combination with window options: (-w || -sw || -gw || -wc)"},
"Options -selectCols and -selectSeqs are not allowed in combination of overlap options (-resoverlap || -seqoverlap)"},
"Only one method to chose sequences can be applied: (-selectseqs || -clusters || -maxIdentity"},
"Only one trimming method can be used at the same time, either automatic or manual. Manual argument: \"[tag]\" + \"[tag]\""},
"Combination between automatic methods and -block options is not allowed"},
"Combination between general and specific windows is not allowed"},
"Combination of -ct + -cons + either -gt or -st is not allowed"},
"General window (-w) is not compatible with specific window options: (-cw, -gw, -sw)"},
"Parameter [tag] is not valid when statistics' parameters are defined"},
"Parameter [tag] can only be used with either an automatic or a manual method"},
"You can not force the alignment selection without setting an alignment dataset to compare against"},
"You need to specify an input alignment (-in or -forcefile) to use a Coding Sequence File (-backtranslation) to apply the back translation method"},
"The sequences in the input alignment [tag] should be aligned in order to use any trimming method or statistics"},
"The Similarity Matrix can only be used with methods that use this matrix"},
"The [tag] and [tag] files can't be the same"},
"Sequence and residues overlap values are mutually needed. You only specified [tag]"},
"Out file must be specified in order to print any statistics"},
"The alignments' datatypes are different. Check your dataset"},
"The block size value is too big. Please, choose another one smaller than residues number / 4. In this case, the limit is: [tag]"},
"The [tag] parameter can be only set up with backtranslation functionality"},
"The input protein file has to be aligned to carry out the backtranslation process"},
"Check your Coding sequences file. It has been detected other kind of biological sequences"},
"Impossible to generate [tag]"},
"It's impossible to process the Similarity Matrix"},
"Option [tag] only accepts ranges from 0 to number of [tag] - 1"},
"The number of clusters from the Alignment can not be larger than the number of sequences from that alignment"},
"Check your manually set left '[tag]' and right '[tag]' boundaries'"},
"The files to compare do not have the same number of sequences"},
"Sequences names differ in compareset files"},
"Check input CDS file. It seems to content protein residues."},
"Sequence \"[tag]\" has, at least, one gap"},
"Sequence length \"[tag]\" is not multiple of 3 (length: [tag])"},
"Sequence \"[tag]\" has stop codon \"[tag]\" (residue \"[tag]\") at position [tag] (length: [tag])"},
"Sequence \"[tag]\" is not in CDS file"},
"The sequence \"[tag]\" has an unknown ([tag]) character"},
"The sequence \"[tag]\" ([tag]) does not have the same number of residues fixed by the alignment ([tag])"},
"the symbol '[tag]' is incorrect"},
"the symbol '[tag]' accesing the matrix is not defined in this object"},
"Parameter \"[tag]\" not valid or repeated"},
"The Similarity Matrix can only be used with general/similarity windows size"},
"Possible (\") mismatch for comments"},
"Brackets (]) mismatch found"},
"Sequences are not aligned. Format ([tag]) not compatible with unaligned sequences."},
"File [tag] not found or impossible to open"},
"File [tag] is empty"},
"Alignment not loaded: \"[tag]\". Format couldn't be recognized."},
"Output format [tag] not recognized"},
"You must specify only one output format if you don't provide an output file pattern"},
"Alignment couldn't be saved on [tag] format"},
"Verbose Level specified ([tag]) wasn't recognized. Current level is: [tag]"},
"Verbose Level has to be specified after the [tag] argument. Acceptable values are: 'error', 'warning', 'info', 'none' and their numerical equivalents '3', '2', '1' and '0'. Current level is [tag]"},
"No reference sequence found for contig \"[tag]\""},
"SNP at positon \"[tag]\" in file \"[tag]\" cannot be applied as sequence has a length of \"[tag]\""},
"An MSA input file has to be provided"},
"Compareset couldn't be performed as some alignments are missing"},
"Gap window size (-gw) provided is too big, please specify a window lesser than 1/4 of residues"},
"Similarity window size (-sw) provided is too big, please specify a window lesser than 1/4 of residues"},
"Consistency window size (-cw) provided is too big, please specify a window lesser than 1/4 of residues"},
"Window size (-w) provided is too big, please specify a window lesser than 1/4 of residues"},
"Couldn't output any alignment as it doesn't contain any sequence."},
"Couldn't perform the trimming step, alignment type unkwnown. "},
"Multiple formats have been requested, but output pattern does not contain tags \"[extension]\" or \"[format]\".\n"
" Output files will be overwritten. Please, provide an output pattern containing tags to prevent overwritting."},
"Multiple input files have been provided (Ej: \"-in X Y\"). This is not supported."},
"Something went wrong. Please, report to the developer with this message: \"[tag]\""},
"Failed to apply SNP to \"[tag]\":\"[tag]\" at position \"[tag]\".\n"
"\tCharacter expected at reference: \"[tag]\"\n"
"\tCharacter at reference: \"[tag]\""},
"Overwriting SNP to \"[tag]\":\"[tag]\" at position \"[tag]\".\n"
"\tCharacter found at reference: \"[tag]\"\n"
"\tCharacter found at destination: \"[tag]\"\n"
"\tCharacter applied to destination: \"[tag]\""},
"There are more donors on the line than present on header. Please check your VCF: \"[tag]\""},
"Min Quality should be equal or greater than 0."},
"Min Quality provided not recognized"},
"Min Coverage should be equal or greater than 0."},
"Min Coverage provided not recognized"},
"[tag] only valid in combination with -vcf argument."},
"[[tag]] Tried to prevent overriding file [tag] but found no luck adding suffixes.\n"
"Overwritting file [tag]"
"You should check your output folder."},
"Combination among absolute (-gat) and relative (-gt) gap thresholds is not allowed."},
"The absolute gap window value should be greater or equal to 0"},
"The absolute gap window value should be lesser than the number of sequences.\n"
"\tNumber of sequences: \"[tag]\".\n"
"\tAbsolute Gap Threshold provided: \"[tag]\"."},
"Absolute gap (-gat) not recognized"},
"More than one automated method has been requested."},
"Arguments -in <x> and -forceselect <x> are incompatible"},
"Arguments -in <x> and -compareset <x> are incompatible"},
}

Definition at line 371 of file reportsystem.h.

Referenced by report().

◆ InfoMessages

const std::map< InfoCode, const char * > reporting::reportManager::InfoMessages
staticprivate
Initial value:
=
{
"Cutting sequence \"[tag]\" at first appearance of stop codon \"[tag]\""
" (residue \"[tag]\") at position [tag] (length: [tag] \")"},
"Window size (-w) is provided. "
"It's recommended to use specific consistency window size (-cw)"
" when using -compareset option"},
"Applying SNP to \"[tag]\":\"[tag]\" at position [tag] \"[tag]\"->\"[tag]\""
},
"Removing sequence \"[tag]\" as it is a duplicate of \"[tag]\"."}
}

Definition at line 369 of file reportsystem.h.

Referenced by report().

◆ IsDebug

bool reporting::reportManager::IsDebug = false

Protection variable. This variable should be set to true while in development, and false on Release.

Definition at line 382 of file reportsystem.h.

Referenced by log(), main(), and operator<<().

◆ Level

VerboseLevel reporting::reportManager::Level = VerboseLevel::INFO

Level of Verbosity.
The report system won't output messages that are lower than the current level.

Definition at line 377 of file reportsystem.h.

Referenced by log(), PrintCodesAndMessages(), report(), and trimAlManager::verbosity_argument().

◆ WarningMessages

const std::map< WarningCode, const char * > reporting::reportManager::WarningMessages
staticprivate
Initial value:
=
{
"Removing sequence '[tag]' composed only by gaps after trimming"},
"Keeping sequence '[tag]' composed only by gaps after trimming"},
"Sequence \"[tag]\" will be cut at position [tag] (length:[tag])"},
"Sequence \"[tag]\" has some indetermination symbols 'X' "
"at the end of sequence. They will be included in the final Alignment."},
"Sequence \"[tag]\" has less nucleotides ([tag]) than expected ([tag])."
" It will be added N's to complete the sequence"},
"Original sequence header will be cut by 10 characters on format [tag]"},
"The donor \"[tag]\" is present on more than one VCF. "
"Overlaping SNPs will be overwritten."},
"SNP already applied to \"[tag]\":\"[tag]\" at position [tag] \"[tag]\"->\"[tag]\""},
"[[tag]] Overwritting file [tag]."},
"[[tag]] -> To prevent overriding file [tag] a suffix has been added. Final filename: [tag]"}
}

Definition at line 370 of file reportsystem.h.

Referenced by report().


The documentation for this class was generated from the following files: