FormatHandling::BaseFormatHandler Class Referenceabstract

Abstract class that serves as template for Format Handlers. Formats must inherit from this class and will be handled by FormatManager. More...

#include <BaseFormatHandler.h>

Public Member Functions

virtual int CheckAlignment (std::istream *origin)=0
 Function to check if a file is in the implemented format. More...
 
virtual AlignmentLoadAlignment (const std::string &filename)=0
 Function to load a file in the current format and return an alignment object. More...
 
virtual bool SaveAlignment (const Alignment &alignment, std::ostream *output)=0
 Function to save a Alignment to a file. More...
 
virtual bool RecognizeOutputFormat (const std::string &FormatName)
 Function that recognizes acronyms of the format. More...
 
virtual ~BaseFormatHandler ()=default
 Class Destructor. More...
 

Public Attributes

bool canLoad = false
 Bool tag that indicates whether or not this state can load an alignment in the corresponding format. More...
 
bool canSave = false
 Bool tag that indicates whether or not this state can save an alignment in the corresponding format. More...
 
std::string name
 String that contains a well known acronym to the format. More...
 
std::string extension
 String that contains the main extension of the format. More...
 

Protected Attributes

FormatHandling::FormatManagerMachine
 Pointer to the FormatManager that contains and manages this state. More...
 

Detailed Description

Abstract class that serves as template for Format Handlers. Formats must inherit from this class and will be handled by FormatManager.

Each class should know how to:

  • Recognize if a file is in its format
  • Load a file in its format and return an alignment object
  • Save an alignment to a file in this format
  • Recognize its format acronyms.

Definition at line 52 of file BaseFormatHandler.h.

Constructor & Destructor Documentation

◆ ~BaseFormatHandler()

virtual FormatHandling::BaseFormatHandler::~BaseFormatHandler ( )
virtualdefault

Class Destructor.

Member Function Documentation

◆ CheckAlignment()

virtual int FormatHandling::BaseFormatHandler::CheckAlignment ( std::istream *  origin)
pure virtual

Function to check if a file is in the implemented format.

Parameters
originFile Handler to the file.
Returns
A number that represents the confidence recognizing this format.
Attention
Take in mind incompatibilities with other formats when you implement this function:

Fasta may recognize a file if it starts with '>', returning a 1.
Pir files also begin with '>', but they also recognize the ';' after the '>' and 2 letter symbol.
When the Pir recognizes its format, it returns a 2.
So, when the Pir format is recognized, it's preferred over the Fasta Format, when both of them can load the alignment bur pir extracts more information.

Referenced by FormatHandling::FormatManager::getFormatFromFile().

+ Here is the caller graph for this function:

◆ LoadAlignment()

virtual Alignment* FormatHandling::BaseFormatHandler::LoadAlignment ( const std::string &  filename)
pure virtual

Function to load a file in the current format and return an alignment object.

Parameters
filenameFilename of the file to load.
Returns
Alignment loaded with the information of the file.
nullptr if there was any error.

Referenced by FormatHandling::FormatManager::loadAlignment().

+ Here is the caller graph for this function:

◆ RecognizeOutputFormat()

virtual bool FormatHandling::BaseFormatHandler::RecognizeOutputFormat ( const std::string &  FormatName)
inlinevirtual

Function that recognizes acronyms of the format.

Parameters
FormatNameacronym to recognize
Returns
True if recognized
False otherwise.

Definition at line 110 of file BaseFormatHandler.h.

References name.

Referenced by FormatHandling::FormatManager::getFormatFromToken().

+ Here is the caller graph for this function:

◆ SaveAlignment()

virtual bool FormatHandling::BaseFormatHandler::SaveAlignment ( const Alignment alignment,
std::ostream *  output 
)
pure virtual

Function to save a Alignment to a file.

Parameters
alignmentAlignment to save.
outputFile Handler where to save the formatted alignment;
Returns
True if file could be saved.
False otherwise.

Referenced by FormatHandling::FormatManager::saveAlignments().

+ Here is the caller graph for this function:

Member Data Documentation

◆ canLoad

bool FormatHandling::BaseFormatHandler::canLoad = false

Bool tag that indicates whether or not this state can load an alignment in the corresponding format.

Definition at line 57 of file BaseFormatHandler.h.

Referenced by FormatHandling::FormatManager::getInputFormatsAvailable().

◆ canSave

bool FormatHandling::BaseFormatHandler::canSave = false

Bool tag that indicates whether or not this state can save an alignment in the corresponding format.

Definition at line 61 of file BaseFormatHandler.h.

Referenced by FormatHandling::FormatManager::getOutputFormatsAvailable().

◆ extension

std::string FormatHandling::BaseFormatHandler::extension

String that contains the main extension of the format.

Definition at line 71 of file BaseFormatHandler.h.

Referenced by trimAlManager::perform(), and FormatHandling::FormatManager::saveAlignments().

◆ Machine

FormatHandling::FormatManager* FormatHandling::BaseFormatHandler::Machine
protected

Pointer to the FormatManager that contains and manages this state.

Definition at line 124 of file BaseFormatHandler.h.

◆ name


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