Class to handle Format Handlers .
It serves as a proxy to the handlers, so the code outside the FormatManager is format-agnostic.
More...
#include <FormatManager.h>
Public Member Functions | |
FormatManager () | |
~FormatManager () | |
Alignment * | loadAlignment (const std::string &inFile) |
Function that loads an alignment given a file path. It automatically detects the format of the file. More... | |
std::string | replaceINtag (const Alignment &alignment, const std::string &outPattern) |
bool | saveAlignment (const std::string &outPattern, const std::vector< std::string > &outFormats, Alignment &alignment) |
Function to save an alignment to a file. It searches among the available_states one that can write the alignment in the specified format. More... | |
bool | saveAlignments (const std::string &outPattern, const std::vector< std::string > &outFormats, const std::vector< Alignment *> &alignmentVector) |
Function to save an alignment to a file. It searches among the available_states one that can write the alignment in the specified format. More... | |
void | loadAndSaveMultipleAlignments (const std::vector< std::string > &inFiles, const std::string &outPattern, const std::vector< std::string > &outFormats) |
Function that takes multiple files, loads them and saves in a cumulus of formats, using an outPattern. More... | |
std::string | getFileFormatName (const std::string &inFile) |
Function to obtain the format name of a given file. More... | |
std::string | getInputFormatsAvailable () |
Function to obtain all format names available by this object that can load an alignment. More... | |
std::string | getOutputFormatsAvailable () |
Function to obtain all format names available by this object that can save an alignment. More... | |
std::vector< Alignment * > | splitAlignmentKeeping (const Alignment &alignment) |
Function to divide an alignment into different alignments, each one with a sequence from the original. This function does a deep copy of each sequence, so the original alignment can be deleted after being splitted. More... | |
FormatHandling::BaseFormatHandler * | getFormatFromToken (const std::string &token) |
std::ifstream * | getNonEmptyFile (const std::string &filename) |
FormatHandling::BaseFormatHandler * | getFormatFromFile (const std::string &filename) |
Public Attributes | |
bool | hasOutputFile = true |
Tag to know if the machine has an output file or it has to output to console. More... | |
bool | keepHeader = false |
Tag to know if the machine should keep original headers. More... | |
bool | reverse = false |
Tag to know if sequences should be reversed before saving them. More... | |
bool | format = false |
Tag to know if the machine should output the format information about the alignment. More... | |
bool | type = false |
Tag to know if the machine should output the type of the alignment. More... | |
bool | info = false |
Tag to know if the machine should output the information of the alignment. More... | |
std::ios_base::openmode | openmode = std::ofstream::out |
Private Member Functions | |
void | addState (BaseFormatHandler *newState) |
Function that adds a newState to the FormatManager::available_states vector. This should be called on the constructor function foreach format existent. More... | |
Private Attributes | |
std::vector< FormatHandling::BaseFormatHandler * > | available_states |
Vector that contains the available formats to load/save from. They are loaded into the format in the constructor function. More... | |
Class to handle Format Handlers .
It serves as a proxy to the handlers, so the code outside the FormatManager is format-agnostic.
Definition at line 64 of file FormatManager.h.
FormatHandling::FormatManager::FormatManager | ( | ) |
Definition at line 29 of file formats_header.h.
References addState().
Referenced by main(), and menu().
FormatHandling::FormatManager::~FormatManager | ( | ) |
Definition at line 43 of file BaseFormatHandler.cpp.
References available_states.
|
private |
Function that adds a newState to the FormatManager::available_states vector.
This should be called on the constructor function foreach format existent.
newState | Pointer to the newState we want to instantiate. |
Definition at line 50 of file BaseFormatHandler.cpp.
References available_states.
Referenced by FormatManager().
std::string FormatHandling::FormatManager::getFileFormatName | ( | const std::string & | inFile | ) |
Function to obtain the format name of a given file.
inFile | File path of the file which we want to obtain it's format. |
Definition at line 239 of file BaseFormatHandler.cpp.
References getFormatFromFile(), and FormatHandling::BaseFormatHandler::name.
Referenced by trimAlManager::check_output_format(), main(), and statistics::Consistency::perform().
FormatHandling::BaseFormatHandler * FormatHandling::FormatManager::getFormatFromFile | ( | const std::string & | filename | ) |
Definition at line 302 of file BaseFormatHandler.cpp.
References AlignmentFormatNotRecognized, available_states, FormatHandling::BaseFormatHandler::CheckAlignment(), debug, getNonEmptyFile(), and reporting::reportManager::report().
Referenced by getFileFormatName(), and loadAlignment().
FormatHandling::BaseFormatHandler * FormatHandling::FormatManager::getFormatFromToken | ( | const std::string & | token | ) |
Definition at line 291 of file BaseFormatHandler.cpp.
References available_states, and FormatHandling::BaseFormatHandler::RecognizeOutputFormat().
Referenced by trimAlManager::out_format_arguments(), trimAlManager::perform(), and saveAlignments().
std::string FormatHandling::FormatManager::getInputFormatsAvailable | ( | ) |
Function to obtain all format names available by this object that can load an alignment.
Definition at line 245 of file BaseFormatHandler.cpp.
References available_states, FormatHandling::BaseFormatHandler::canLoad, and FormatHandling::BaseFormatHandler::name.
Referenced by trimAlManager::help_arguments(), menu(), and trimAlManager::menu().
std::ifstream * FormatHandling::FormatManager::getNonEmptyFile | ( | const std::string & | filename | ) |
Definition at line 349 of file BaseFormatHandler.cpp.
References CantOpenFile, debug, FileIsEmpty, and reporting::reportManager::report().
Referenced by getFormatFromFile().
std::string FormatHandling::FormatManager::getOutputFormatsAvailable | ( | ) |
Function to obtain all format names available by this object that can save an alignment.
Definition at line 256 of file BaseFormatHandler.cpp.
References available_states, FormatHandling::BaseFormatHandler::canSave, and FormatHandling::BaseFormatHandler::name.
Referenced by trimAlManager::help_arguments(), menu(), and trimAlManager::menu().
Alignment * FormatHandling::FormatManager::loadAlignment | ( | const std::string & | inFile | ) |
Function that loads an alignment given a file path. It automatically detects the format of the file.
inFile | File path of the alignment to load. |
Definition at line 55 of file BaseFormatHandler.cpp.
References AlignmentFormatNotRecognized, debug, getFormatFromFile(), FormatHandling::BaseFormatHandler::LoadAlignment(), and reporting::reportManager::report().
Referenced by trimAlManager::back_trans_argument(), trimAlManager::force_select_argument(), trimAlManager::in_argument(), loadAndSaveMultipleAlignments(), main(), and statistics::Consistency::perform().
void FormatHandling::FormatManager::loadAndSaveMultipleAlignments | ( | const std::vector< std::string > & | inFiles, |
const std::string & | outPattern, | ||
const std::vector< std::string > & | outFormats | ||
) |
Function that takes multiple files, loads them and saves in a cumulus of formats, using an outPattern.
inFiles | Vector of files to load, reformat and save. |
outPattern | Path and name of the new files. The function changes some optional tokens on the original string to obtain multiple versions:
|
outFormats | Output formats that original files should reformat to. |
Definition at line 215 of file BaseFormatHandler.cpp.
References loadAlignment(), and saveAlignments().
Referenced by main().
std::string FormatHandling::FormatManager::replaceINtag | ( | const Alignment & | alignment, |
const std::string & | outPattern | ||
) |
Definition at line 68 of file BaseFormatHandler.cpp.
References Alignment::filename, and utils::ReplaceString().
Referenced by trimAlManager::perform(), and saveAlignments().
bool FormatHandling::FormatManager::saveAlignment | ( | const std::string & | outPattern, |
const std::vector< std::string > & | outFormats, | ||
Alignment & | alignment | ||
) |
Function to save an alignment to a file. It searches among the available_states one that can write the alignment in the specified format.
outPattern | File path to save the alignment. |
outFormats | Format in which save the alignment. |
alignment | Alignment |
Definition at line 90 of file BaseFormatHandler.cpp.
References saveAlignments().
Referenced by main(), and trimAlManager::save_alignment().
bool FormatHandling::FormatManager::saveAlignments | ( | const std::string & | outPattern, |
const std::vector< std::string > & | outFormats, | ||
const std::vector< Alignment *> & | alignmentVector | ||
) |
Function to save an alignment to a file. It searches among the available_states one that can write the alignment in the specified format.
outPattern | File path to save the alignment. |
outFormats | Format in which save the alignment. |
alignmentVector | Alignment |
Definition at line 99 of file BaseFormatHandler.cpp.
References AlignmentIsEmpty, AlignmentNotSaved, debug, FormatHandling::BaseFormatHandler::extension, utils::fileExists(), getFormatFromToken(), FormatHandling::BaseFormatHandler::name, Alignment::numberOfResidues, Alignment::numberOfSequences, OnlyOneFormatOnConsoleOutput, OutputFormatNotRecognized, RenamingOutputPreventOverride, replaceINtag(), utils::ReplaceString(), utils::ReplaceStringInPlace(), reporting::reportManager::report(), FormatHandling::BaseFormatHandler::SaveAlignment(), and TriedRenamingOutputPreventOverride.
Referenced by loadAndSaveMultipleAlignments(), and saveAlignment().
std::vector< Alignment * > FormatHandling::FormatManager::splitAlignmentKeeping | ( | const Alignment & | alignment | ) |
Function to divide an alignment into different alignments, each one with a sequence from the original.
This function does a deep copy of each sequence, so the original alignment can be deleted after being splitted.
Definition at line 267 of file BaseFormatHandler.cpp.
References Alignment::Alignment(), Alignment::filename, Alignment::numberOfResidues, Alignment::numberOfSequences, Alignment::originalNumberOfResidues, Alignment::originalNumberOfSequences, Alignment::seqsName, and Alignment::sequences.
Referenced by trimAlManager::perform().
|
private |
Vector that contains the available formats to load/save from.
They are loaded into the format in the constructor function.
Definition at line 86 of file FormatManager.h.
Referenced by addState(), getFormatFromFile(), getFormatFromToken(), getInputFormatsAvailable(), getOutputFormatsAvailable(), and ~FormatManager().
bool FormatHandling::FormatManager::format = false |
Tag to know if the machine should output the format information about the alignment.
Definition at line 108 of file FormatManager.h.
Referenced by checkArguments(), main(), and parseArguments().
bool FormatHandling::FormatManager::hasOutputFile = true |
Tag to know if the machine has an output file or it has to output to console.
Definition at line 99 of file FormatManager.h.
Referenced by checkArguments().
bool FormatHandling::FormatManager::info = false |
Tag to know if the machine should output the information of the alignment.
Definition at line 114 of file FormatManager.h.
Referenced by checkArguments(), main(), and parseArguments().
bool FormatHandling::FormatManager::keepHeader = false |
Tag to know if the machine should keep original headers.
Definition at line 101 of file FormatManager.h.
Referenced by trimAlManager::keep_header_argument(), and parseArguments().
std::ios_base::openmode FormatHandling::FormatManager::openmode = std::ofstream::out |
Definition at line 212 of file FormatManager.h.
bool FormatHandling::FormatManager::reverse = false |
Tag to know if sequences should be reversed before saving them.
Definition at line 103 of file FormatManager.h.
Referenced by main(), and parseArguments().
bool FormatHandling::FormatManager::type = false |
Tag to know if the machine should output the type of the alignment.
Definition at line 111 of file FormatManager.h.
Referenced by checkArguments(), main(), and parseArguments().