Utilities class. This class contains shared methods to be used in multiple parts of the code. More...
Namespaces | |
TerminalColors | |
Functions | |
void | initlVect (int *vector, int tam, int valor) |
Vector initialization. More... | |
void | initlVect (float *vector, int tam, float valor) |
Vector initialization. More... | |
void | copyVect (int *vect1, int *vect2, int tam) |
Integer vector copying. More... | |
void | copyVect (float *vect1, float *vect2, int tam) |
Float vector copying. More... | |
int | roundToInf (double number) |
Round double to inferior integer method. More... | |
int | roundInt (double number) |
Round double to integer method. More... | |
int | roundToSup (double number) |
Round double to greater integer method. More... | |
int | max (int x, int y) |
Maximum of two numbers method. More... | |
float | max (float x, float y) |
Maximum of two numbers method. More... | |
double | max (double x, double y) |
Maximum of two numbers method. More... | |
int | min (int x, int y) |
Minimum of two numbers method. More... | |
float | min (float x, float y) |
Minimum of two numbers method. More... | |
double | min (double x, double y) |
Minimum of two numbers method. More... | |
bool | isNumber (char *num) |
String-is-number checking. More... | |
bool | compare (char *a, char *b) |
String comparing method. More... | |
void | removeSpaces (char *in, char *out) |
Removing spaces method. More... | |
void | quicksort (float *list, int ini, int fin) |
Quicksort sorting method. More... | |
void | swap (float *a, float *b) |
Swapping elements method. More... | |
void | quicksort (int *list, int ini, int fin) |
Quicksort sorting method. More... | |
void | swap (int *a, int *b) |
Swapping elements method. More... | |
bool | checkFile (std::ifstream &file) |
Check if a given file exists and its size is greater than 0. More... | |
char * | readLine (std::ifstream &file) |
Read a new line from current input stream. This function is better than standard one since cares of operative system compatibility. It is useful as well because removes tabs and blank spaces at lines at beginning/ending. . More... | |
char * | readLine (std::istream &file) |
Read a new line from current input stream. This function is better than standard one since cares of operative system compatibility. It is useful as well because removes tabs and blank spaces at lines at beginning/ending. . More... | |
char * | trimLine (std::string nline) |
Remove all content surrounded by ("") or ([]). It warns as well when a mismatch for these flags is found. . More... | |
std::string | getReverse (const std::string &toReverse) |
Reverses a string. More... | |
std::string | removeCharacter (char c, std::string line) |
Removes a determined char from the string. More... | |
int | checkAlignmentType (int seqNumber, int residNumber, std::string *sequences) |
Checks an alignment type. More... | |
int * | readNumbers (const std::string &line) |
Reads a line and converts it to an array of number. More... | |
void | quicksort (int **vect, int ini, int fin) |
Quicksort sorting method. More... | |
void | swap (int **a, int **b) |
Swaps double pointers. More... | |
char | determineColor (char res, const std::string &column) |
Checks the color that has to be used on the output report. More... | |
bool | lookForPattern (const std::string &data, const std::string &pattern, const float threshold) |
Method to check for a pattern in a string. The method will check, character by character of the first string if there is some equality for each character in the pattern. When done, it will calculate the fraction of characters present in the pattern and compare to the threshold argument. More... | |
void | ReplaceStringInPlace (std::string &subject, const std::string &search, const std::string &replace) |
Function that replaces a substring with another substring in a string. It does not make a copy of the original string, but modifies it. More... | |
std::string | ReplaceString (std::string subject, const std::string &search, const std::string &replace) |
Function that replaces a substring with another substring in a string. It makes a copy of the original string. More... | |
int | GetGapStep (int *gapValue, int sequenNumber) |
Function that gives the gap classification of a column of values. More... | |
int | GetGapStep (int *gapValue, float inverseSequenNumber) |
Function that gives the gap classification of a column of values. This function should work faster than it's sister utils::GetGapStep(int * gapValue, int sequenNumber), as it uses a precomputed (by the user) inverseSequenNumber (1F / Alignment::sequenNumber), instead of calculating it over again each time the function is called (which is equal to number of residues). This comes with a precision cost that shouldn't be a problem. More... | |
int | GetSimStep (float *simValue) |
Function that gives the similarity classification of a column of values. More... | |
int | GetConsStep (float *consValue) |
Function that gives the consistency classification of a column of values. More... | |
bool | fileExists (std::string &path) |
Method to check the existance of a file. More... | |
bool | fileExists (std::string &&path) |
Method to check the existance of a file. Works exactly as fileExists(std::string & path), but accepts r-value reference. More... | |
char | toUpper (char c) |
Utilities class. This class contains shared methods to be used in multiple parts of the code.
int utils::checkAlignmentType | ( | int | seqNumber, |
int | residNumber, | ||
std::string * | sequences | ||
) |
Checks an alignment type.
seqNumber | Number of sequences to check it's type. |
residNumber | Number of residues of the alignment. |
sequences | Sequences pointer |
Definition at line 499 of file utils.cpp.
References AA, DEG, DNA, NotDefined, RNA, and toUpper().
Referenced by Alignment::getAlignmentType().
bool utils::checkFile | ( | std::ifstream & | file | ) |
bool utils::compare | ( | char * | a, |
char * | b | ||
) |
String comparing method.
a | The first string that will be compared. |
b | The second string that will be compared. |
This method compares the two strings given, and returns true if the two strings are equal.
void utils::copyVect | ( | int * | vect1, |
int * | vect2, | ||
int | tam | ||
) |
Integer vector copying.
vect1 | Vector that we want to copy. | |
[out] | vect2 | Destination vector of the copy. |
tam | Vectors size. |
This method copies integer vector 1 to integer vector 2.
Definition at line 51 of file utils.cpp.
Referenced by statistics::Gaps::printGapsColumns().
void utils::copyVect | ( | float * | vect1, |
float * | vect2, | ||
int | tam | ||
) |
Float vector copying.
vect1 | Vector that we want to copy. | |
[out] | vect2 | Destination vector of the copy. |
tam | Vectors size. |
This method copies float vector 1 to float vector 2.
Definition at line 57 of file utils.cpp.
Referenced by statistics::Similarity::calcCutPoint(), Cleaner::cleanCompareFile(), statistics::Mold::printAccumulative(), statistics::Similarity::printConservationAcl(), and statistics::Consistency::printStatisticsFileAcl().
char utils::determineColor | ( | char | res, |
const std::string & | column | ||
) |
Checks the color that has to be used on the output report.
res | Resiude to check its color |
column | Column to which this residue belongs. |
Definition at line 675 of file utils.cpp.
References lookForPattern().
Referenced by Alignment::alignmentSummaryHTML(), and Alignment::alignmentSummarySVG().
bool utils::fileExists | ( | std::string & | path | ) |
bool utils::fileExists | ( | std::string && | path | ) |
Method to check the existance of a file. Works exactly as fileExists(std::string & path), but accepts r-value reference.
path | Path to the file to check |
Definition at line 953 of file utils.cpp.
Referenced by FormatHandling::FormatManager::saveAlignments().
int utils::GetConsStep | ( | float * | consValue | ) |
int utils::GetGapStep | ( | int * | gapValue, |
int | sequenNumber | ||
) |
int utils::GetGapStep | ( | int * | gapValue, |
float | inverseSequenNumber | ||
) |
Function that gives the gap classification of a column of values.
This function should work faster than it's sister utils::GetGapStep(int * gapValue, int sequenNumber), as it uses a precomputed (by the user) inverseSequenNumber (1F / Alignment::sequenNumber), instead of calculating it over again each time the function is called (which is equal to number of residues).
This comes with a precision cost that shouldn't be a problem.
gapValue | Number of gaps present in the column. |
inverseSequenNumber | Inverse of number of sequences. (1F / sequenNumber) |
std::string utils::getReverse | ( | const std::string & | toReverse | ) |
int utils::GetSimStep | ( | float * | simValue | ) |
void utils::initlVect | ( | int * | vector, |
int | tam, | ||
int | valor | ||
) |
Vector initialization.
[out] | vector | The vector that will be initialized. |
tam | The size of the vector. | |
valor | The initialization value that will of all positions of the vector. |
This method is used to initialize all positions of a vector with a given value.
Definition at line 40 of file utils.cpp.
Referenced by statistics::Gaps::applyWindow(), Cleaner::cleanCombMethods(), statistics::Consistency::forceComparison(), statistics::Gaps::Gaps(), statistics::similarityMatrix::loadSimMatrix(), and Alignment::sequencesMatrix::sequencesMatrix().
void utils::initlVect | ( | float * | vector, |
int | tam, | ||
float | valor | ||
) |
Vector initialization.
[out] | vector | The vector that will be initialized. |
tam | The size of the vector. | |
valor | The initialization value of all positions of the vector. |
This method is used to initialize all positions of a vector with a given value.
Definition at line 46 of file utils.cpp.
Referenced by statistics::Gaps::calcCutPoint2ndSlope(), statistics::Gaps::calcCutPointMixSlope(), statistics::Consistency::compareAndChoose(), statistics::Consistency::forceComparison(), and statistics::Similarity::Similarity().
bool utils::isNumber | ( | char * | num | ) |
String-is-number checking.
num | The string we want to check. |
This method checks if the given string is a number (taking in mind the possibility of floating numbers and scientific notation)
Definition at line 116 of file utils.cpp.
Referenced by trimAlManager::block_argument(), trimAlManager::clusters_argument(), trimAlManager::conservation_threshold_argument(), trimAlManager::consistency_threshold_argument(), trimAlManager::consistency_window_argument(), trimAlManager::gap_threshold_argument(), trimAlManager::gap_window_argument(), main(), trimAlManager::max_identity_argument(), trimAlManager::min_coverage_argument(), trimAlManager::min_quality_argument(), trimAlManager::residue_overlap_argument(), trimAlManager::sequence_overlap_argument(), trimAlManager::similarity_threshold_argument(), trimAlManager::similarity_window_argument(), and trimAlManager::window_argument().
bool utils::lookForPattern | ( | const std::string & | data, |
const std::string & | pattern, | ||
const float | threshold | ||
) |
Method to check for a pattern in a string.
The method will check, character by character of the first string if there is some equality for each character in the pattern.
When done, it will calculate the fraction of characters present in the pattern and compare to the threshold argument.
data | string that will be compared against a pattern |
pattern | string that contains the pattern. |
threshold | minimum ratio of hits to consider the pattern valid |
Definition at line 793 of file utils.cpp.
References toUpper().
Referenced by determineColor().
int utils::max | ( | int | x, |
int | y | ||
) |
Maximum of two numbers method.
x | The first number. |
y | The second number. |
This method returns the maximum between the two numbers given as parameters.
Definition at line 80 of file utils.cpp.
Referenced by Alignment::alignmentSummaryHTML(), Alignment::alignmentSummarySVG(), Alignment::printSeqIdentity(), and Alignment::printSeqOverlap().
float utils::max | ( | float | x, |
float | y | ||
) |
double utils::max | ( | double | x, |
double | y | ||
) |
Maximum of two numbers method.
x | The first number. |
y | The second number. |
This method returns the maximum between the two numbers given as parameters.
Definition at line 92 of file utils.cpp.
Referenced by statistics::Gaps::calcCutPoint().
int utils::min | ( | int | x, |
int | y | ||
) |
Minimum of two numbers method.
x | The first number. |
y | The second number. |
This method returns the minimum between the two numbers given as parameters.
Definition at line 98 of file utils.cpp.
Referenced by Alignment::checkCorrespondence().
float utils::min | ( | float | x, |
float | y | ||
) |
Minimum of two numbers method.
x | The first number. |
y | The second number. |
This method returns the minimum between the two numbers given as parameters.
Definition at line 104 of file utils.cpp.
Referenced by Cleaner::cleanCompareFile().
double utils::min | ( | double | x, |
double | y | ||
) |
void utils::quicksort | ( | float * | list, |
int | ini, | ||
int | fin | ||
) |
Quicksort sorting method.
list | The vector that we want to sort. |
ini | The first element of the vector. |
fin | The last element of the vector. |
This method sorts the vector using the quicksort method.
Definition at line 159 of file utils.cpp.
References quicksort(), and swap().
Referenced by statistics::Similarity::calcCutPoint(), Cleaner::cleanByCutValueOverpassOrEquals(), Cleaner::cleanCombMethods(), Cleaner::cleanCompareFile(), statistics::Mold::printAccumulative(), statistics::Similarity::printConservationAcl(), statistics::Consistency::printStatisticsFileAcl(), quicksort(), and Alignment::statSVG().
void utils::quicksort | ( | int * | list, |
int | ini, | ||
int | fin | ||
) |
Quicksort sorting method.
list | The vector that we want to sort. |
ini | The first element of the vector. |
fin | The last element of the vector. |
This method sorts the vector using the quicksort method.
Definition at line 204 of file utils.cpp.
References quicksort(), and swap().
Referenced by Cleaner::cleanByCutValueOverpass(), Cleaner::cleanByCutValueOverpassOrEquals(), and quicksort().
void utils::quicksort | ( | int ** | vect, |
int | ini, | ||
int | fin | ||
) |
Quicksort sorting method.
vect | The vector that we want to sort. |
ini | The first element of the vector. |
fin | The last element of the vector. |
Definition at line 246 of file utils.cpp.
References quicksort(), and swap().
Referenced by Cleaner::calculateRepresentativeSeq(), Cleaner::getCutPointClusters(), and quicksort().
char * utils::readLine | ( | std::ifstream & | file | ) |
Read a new line from current input stream.
This function is better than standard one since cares of operative system compatibility.
It is useful as well because removes tabs and blank spaces at lines at beginning/ending.
.
file | ifstream to read line from. |
char * utils::readLine | ( | std::istream & | file | ) |
Read a new line from current input stream.
This function is better than standard one since cares of operative system compatibility.
It is useful as well because removes tabs and blank spaces at lines at beginning/ending.
.
file | ifstream to read line from. |
int * utils::readNumbers | ( | const std::string & | line | ) |
Reads a line and converts it to an array of number.
line | Line to convert to array of ints |
Definition at line 624 of file utils.cpp.
Referenced by trimAlManager::select_cols_argument(), and trimAlManager::seqs_select_argument().
std::string utils::removeCharacter | ( | char | c, |
std::string | line | ||
) |
Removes a determined char from the string.
c | Character to remove from line |
line | String to remove c from. |
Definition at line 485 of file utils.cpp.
Referenced by Cleaner::calculateRepresentativeSeq(), Alignment::checkCorrespondence(), Cleaner::getCutPointClusters(), and Alignment::getSequences().
void utils::removeSpaces | ( | char * | in, |
char * | out | ||
) |
Removing spaces method.
in | The string that we want to clean. | |
[out] | out | The destination of the clean string. |
This method removes spaces in the input string and put the result in the output string.
Definition at line 144 of file utils.cpp.
Referenced by statistics::similarityMatrix::loadSimMatrix().
std::string utils::ReplaceString | ( | std::string | subject, |
const std::string & | search, | ||
const std::string & | replace | ||
) |
Function that replaces a substring with another substring in a string. It makes a copy of the original string.
[in] | subject | String to be modified |
search | Substring to search and change | |
replace | Substring to put in place of search |
Definition at line 820 of file utils.cpp.
Referenced by trimAlManager::output_reports(), trimAlManager::perform(), FormatHandling::FormatManager::replaceINtag(), and FormatHandling::FormatManager::saveAlignments().
void utils::ReplaceStringInPlace | ( | std::string & | subject, |
const std::string & | search, | ||
const std::string & | replace | ||
) |
Function that replaces a substring with another substring in a string. It does not make a copy of the original string, but modifies it.
[in,out] | subject | String to be modified |
search | Substring to search and change | |
replace | Substring to put in place of search |
Definition at line 810 of file utils.cpp.
Referenced by trimAlManager::examples(), trimAlManager::menu(), trimAlManager::output_reports(), trimAlManager::perform(), and FormatHandling::FormatManager::saveAlignments().
int utils::roundInt | ( | double | number | ) |
Round double to integer method.
number | The number that will be rounded. |
This method rounds a double number to a integer.
Definition at line 68 of file utils.cpp.
Referenced by statistics::Gaps::applyWindow(), statistics::Gaps::calcCutPoint(), Cleaner::cleanByCutValueFallBehind(), Cleaner::cleanByCutValueOverpass(), Cleaner::cleanByCutValueOverpassOrEquals(), and Cleaner::cleanStrict().
int utils::roundToInf | ( | double | number | ) |
int utils::roundToSup | ( | double | number | ) |
void utils::swap | ( | float * | a, |
float * | b | ||
) |
Swapping elements method.
a | One element to swap. |
b | Other element to swap. |
This method swaps the values in a and b.
Definition at line 193 of file utils.cpp.
Referenced by quicksort().
void utils::swap | ( | int * | a, |
int * | b | ||
) |
Swapping elements method.
a | One element to swap. |
b | Other element to swap. |
This method swaps the values in a and b.
Definition at line 237 of file utils.cpp.
Referenced by quicksort().
void utils::swap | ( | int ** | a, |
int ** | b | ||
) |
Swaps double pointers.
a | Double pointer A |
b | Double pointer B |
Definition at line 275 of file utils.cpp.
Referenced by quicksort().
char utils::toUpper | ( | char | c | ) |
Definition at line 958 of file utils.cpp.
Referenced by statistics::Similarity::calculateVectors(), checkAlignmentType(), and lookForPattern().
char * utils::trimLine | ( | std::string | nline | ) |
Remove all content surrounded by ("") or ([]).
It warns as well when a mismatch for these flags is found.
.
nline | Line to be trimmed. |
Definition at line 392 of file utils.cpp.
References BracketsMissmatchFound, debug, PossibleMissmatch, and reporting::reportManager::report().