utils.h File Reference
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <map>
#include <sys/stat.h>

Go to the source code of this file.

Namespaces

 utils
 Utilities class. This class contains shared methods to be used in multiple parts of the code.
 
 utils::TerminalColors
 

Enumerations

enum  utils::TerminalColors::terminalColor {
  utils::TerminalColors::RESET,
  utils::TerminalColors::BLACK,
  utils::TerminalColors::RED,
  utils::TerminalColors::GREEN,
  utils::TerminalColors::YELLOW,
  utils::TerminalColors::BLUE,
  utils::TerminalColors::MAGENTA,
  utils::TerminalColors::CYAN,
  utils::TerminalColors::WHITE,
  utils::TerminalColors::BOLD,
  utils::TerminalColors::UNDERLINE
}
 

Functions

void utils::initlVect (int *vector, int tam, int valor)
 Vector initialization. More...
 
void utils::initlVect (float *vector, int tam, float valor)
 Vector initialization. More...
 
void utils::copyVect (int *vect1, int *vect2, int tam)
 Integer vector copying. More...
 
void utils::copyVect (float *vect1, float *vect2, int tam)
 Float vector copying. More...
 
int utils::roundToInf (double number)
 Round double to inferior integer method. More...
 
int utils::roundInt (double number)
 Round double to integer method. More...
 
int utils::roundToSup (double number)
 Round double to greater integer method. More...
 
int utils::max (int x, int y)
 Maximum of two numbers method. More...
 
float utils::max (float x, float y)
 Maximum of two numbers method. More...
 
double utils::max (double x, double y)
 Maximum of two numbers method. More...
 
int utils::min (int x, int y)
 Minimum of two numbers method. More...
 
float utils::min (float x, float y)
 Minimum of two numbers method. More...
 
double utils::min (double x, double y)
 Minimum of two numbers method. More...
 
bool utils::isNumber (char *num)
 String-is-number checking. More...
 
bool utils::compare (char *a, char *b)
 String comparing method. More...
 
void utils::removeSpaces (char *in, char *out)
 Removing spaces method. More...
 
void utils::quicksort (float *list, int ini, int fin)
 Quicksort sorting method. More...
 
void utils::swap (float *a, float *b)
 Swapping elements method. More...
 
void utils::quicksort (int *list, int ini, int fin)
 Quicksort sorting method. More...
 
void utils::swap (int *a, int *b)
 Swapping elements method. More...
 
bool utils::checkFile (std::ifstream &file)
 Check if a given file exists and its size is greater than 0. More...
 
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.
. More...
 
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.
. More...
 
char * utils::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 utils::getReverse (const std::string &toReverse)
 Reverses a string. More...
 
std::string utils::removeCharacter (char c, std::string line)
 Removes a determined char from the string. More...
 
int utils::checkAlignmentType (int seqNumber, int residNumber, std::string *sequences)
 Checks an alignment type. More...
 
int * utils::readNumbers (const std::string &line)
 Reads a line and converts it to an array of number. More...
 
void utils::quicksort (int **vect, int ini, int fin)
 Quicksort sorting method. More...
 
void utils::swap (int **a, int **b)
 Swaps double pointers. More...
 
char utils::determineColor (char res, const std::string &column)
 Checks the color that has to be used on the output report. More...
 
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. More...
 
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. More...
 
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. More...
 
int utils::GetGapStep (int *gapValue, int sequenNumber)
 Function that gives the gap classification of a column of values. More...
 
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. More...
 
int utils::GetSimStep (float *simValue)
 Function that gives the similarity classification of a column of values. More...
 
int utils::GetConsStep (float *consValue)
 Function that gives the consistency classification of a column of values. More...
 
bool utils::fileExists (std::string &path)
 Method to check the existance of a file. More...
 
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. More...
 
char utils::toUpper (char c)
 

Variables

std::map< terminalColor, const std::string > utils::TerminalColors::colors