bpp-seq3  3.0.0
bpp::SequenceApplicationTools Class Reference

This class provides some common tools for applications. More...

#include <Bpp/Seq/App/SequenceApplicationTools.h>

Public Member Functions

 SequenceApplicationTools ()
 
virtual ~SequenceApplicationTools ()
 

Static Public Member Functions

static std::unique_ptr< AlphabetgetAlphabet (const std::map< std::string, std::string > &params, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, bool allowGeneric=false, int warn=1)
 Build an Alphabet object according to options. More...
 
static std::unique_ptr< GeneticCodegetGeneticCode (std::shared_ptr< const NucleicAlphabet > alphabet, const std::string &description)
 Build a GeneticCode object according to options. More...
 
static std::unique_ptr< AlphabetIndex1getAlphabetIndex1 (std::shared_ptr< const Alphabet > alphabet, const std::string &description, const std::string &message="Alphabet measure:", bool verbose=true)
 Build a AlphabetIndex1 object for a given alphabet. More...
 
static std::unique_ptr< AlphabetIndex1getAlphabetIndex1 (std::shared_ptr< const CodonAlphabet > alphabet, std::shared_ptr< const GeneticCode > gencode, const std::string &description, const std::string &message="Alphabet measure:", bool verbose=true)
 
static std::unique_ptr< AlphabetIndex2getAlphabetIndex2 (std::shared_ptr< const Alphabet > alphabet, const std::string &description, const std::string &message="Alphabet distance:", bool verbose=true)
 Build a AlphabetIndex2 object for a given alphabet. More...
 
static std::unique_ptr< AlphabetIndex2getAlphabetIndex2 (std::shared_ptr< const CodonAlphabet > alphabet, std::shared_ptr< const GeneticCode > gencode, const std::string &description, const std::string &message="Alphabet distance:", bool verbose=true)
 
static std::unique_ptr< SequenceContainerInterfacegetSequenceContainer (std::shared_ptr< const Alphabet > alpha, const std::map< std::string, std::string > &params, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
 Build a SequenceContainer object according to options. More...
 
static std::unique_ptr< VectorSiteContainergetSiteContainer (std::shared_ptr< const Alphabet > alpha, const std::map< std::string, std::string > &params, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
 Build a SiteContainer object according to the BppO syntax. More...
 
static std::unique_ptr< ProbabilisticVectorSiteContainergetProbabilisticSiteContainer (std::shared_ptr< const Alphabet > alpha, const std::map< std::string, std::string > &params, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
 Build a ProbabilisticSiteContainer object according to the BppO syntax. More...
 
static std::map< size_t, std::unique_ptr< VectorSiteContainer > > getSiteContainers (std::shared_ptr< const Alphabet > alpha, const std::map< std::string, std::string > &params, const std::string &prefix="input.", const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
 Build multiple SiteContainer objects according to the BppO syntax. More...
 
static std::map< size_t, std::unique_ptr< ProbabilisticVectorSiteContainer > > getProbabilisticSiteContainers (std::shared_ptr< const Alphabet > alpha, const std::map< std::string, std::string > &params, const std::string &prefix="input.", const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
 Build multiple ProbabilisticSiteContainer objects according to the BppO syntax. More...
 
static void restrictSelectedSequencesByName (SequenceContainerInterface &allSequences, const std::map< std::string, std::string > &params, std::string suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1)
 Retrieves selected sequences (by name). More...
 
template<class SiteType , class SequenceType >
static std::unique_ptr< TemplateVectorSiteContainer< SiteType, SequenceType > > getSitesToAnalyse (const TemplateSiteContainerInterface< SiteType, SequenceType, std::string > &allSites, const std::map< std::string, std::string > &params, std::string suffix="", bool suffixIsOptional=true, bool gapAsUnknown=true, bool verbose=true, int warn=1)
 Retrieves sites suitable for the analysis. More...
 
static void writeSequenceFile (const SequenceContainerInterface &sequences, const std::map< std::string, std::string > &params, const std::string &suffix="", bool verbose=true, int warn=1)
 Write a sequence file according to options. More...
 
static void writeAlignmentFile (const SiteContainerInterface &sequences, const std::map< std::string, std::string > &params, const std::string &suffix="", bool verbose=true, int warn=1)
 Write a sequence alignment file according to options. More...
 

Detailed Description

This class provides some common tools for applications.

The functions parse some option file, create corresponding objects and send a pointer toward it.

The option files are supposed to follow this simple format:

parameterName = parameterContent

with one parameter per line.

See also
ApplicationTools

Definition at line 37 of file SequenceApplicationTools.h.

Constructor & Destructor Documentation

◆ SequenceApplicationTools()

bpp::SequenceApplicationTools::SequenceApplicationTools ( )
inline

Definition at line 40 of file SequenceApplicationTools.h.

◆ ~SequenceApplicationTools()

virtual bpp::SequenceApplicationTools::~SequenceApplicationTools ( )
inlinevirtual

Definition at line 41 of file SequenceApplicationTools.h.

Member Function Documentation

◆ getAlphabet()

unique_ptr< Alphabet > SequenceApplicationTools::getAlphabet ( const std::map< std::string, std::string > &  params,
const std::string &  suffix = "",
bool  suffixIsOptional = true,
bool  verbose = true,
bool  allowGeneric = false,
int  warn = 1 
)
static

Build an Alphabet object according to options.

Options used are:

  - alphabet = [DNA|RNA|Protein], the alphabet type to use.
            = [DNA|RNA|Protein](length=n) a word-alphabet of
                 words with length n
            = [EchinodermMitochondrialCodonAlphabet
| InvertebrateMitochondrialCodonAlphabet
| InvertebrateMitochondrialCodonAlphabet
| StandardCodonAlphabet
| VertebrateMitochondrialCodonAlphabet]([alphn=NA|RNA])
                  a codon-alphabet
Parameters
paramsThe attribute map where options may be found.
suffixA suffix to be applied to each attribute name.
suffixIsOptionalTell if the suffix is absolutely required.
verbosePrint some info to the 'message' output stream.
allowGenericTell if generic alphabets can be used.
warnSet the warning level (0: always display warnings, >0 display warnings on demand).
Returns
A new Alphabet object according to options specified.

Definition at line 43 of file SequenceApplicationTools.cpp.

References bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::getBooleanParameter(), bpp::ApplicationTools::getStringParameter(), bpp::AlphabetTools::isNucleicAlphabet(), bpp::KeyvalTools::parseProcedure(), and bpp::TextTools::toString().

◆ getAlphabetIndex1() [1/2]

unique_ptr< AlphabetIndex1 > SequenceApplicationTools::getAlphabetIndex1 ( std::shared_ptr< const Alphabet alphabet,
const std::string &  description,
const std::string &  message = "Alphabet measure:",
bool  verbose = true 
)
static

Build a AlphabetIndex1 object for a given alphabet.

Parameters
alphabetThe alphabet to use. This is currently only used for assessing the type of distance allowed.
descriptionWhich distance to use. See the Bio++ Program Suite reference manual for a description of the syntax.
messageTo be displayed when parsing.
verboseTell if some info should be displayed while parsing.
Returns
A new AlphabetIndex1 object.
Exceptions
Exceptionin case of bad description.

Definition at line 228 of file SequenceApplicationTools.cpp.

References bpp::BppOAlphabetIndex1Format::read().

◆ getAlphabetIndex1() [2/2]

unique_ptr< AlphabetIndex1 > SequenceApplicationTools::getAlphabetIndex1 ( std::shared_ptr< const CodonAlphabet alphabet,
std::shared_ptr< const GeneticCode gencode,
const std::string &  description,
const std::string &  message = "Alphabet measure:",
bool  verbose = true 
)
static

◆ getAlphabetIndex2() [1/2]

unique_ptr< AlphabetIndex2 > SequenceApplicationTools::getAlphabetIndex2 ( std::shared_ptr< const Alphabet alphabet,
const std::string &  description,
const std::string &  message = "Alphabet distance:",
bool  verbose = true 
)
static

Build a AlphabetIndex2 object for a given alphabet.

Parameters
alphabetThe alphabet to use. This is currently only used for assessing the type of distance allowed.
descriptionWhich distance to use. See the Bio++ Program Suite reference manual for a description of the syntax.
messageTo be displayed when parsing.
Returns
A new AlphabetIndex2 object.
Parameters
verboseTell if some info should be displayed while parsing.
Exceptions
Exceptionin case of bad description.

Definition at line 238 of file SequenceApplicationTools.cpp.

References bpp::BppOAlphabetIndex2Format::read().

◆ getAlphabetIndex2() [2/2]

unique_ptr< AlphabetIndex2 > SequenceApplicationTools::getAlphabetIndex2 ( std::shared_ptr< const CodonAlphabet alphabet,
std::shared_ptr< const GeneticCode gencode,
const std::string &  description,
const std::string &  message = "Alphabet distance:",
bool  verbose = true 
)
static

◆ getGeneticCode()

std::unique_ptr< GeneticCode > SequenceApplicationTools::getGeneticCode ( std::shared_ptr< const NucleicAlphabet alphabet,
const std::string &  description 
)
static

Build a GeneticCode object according to options.

Parameters
alphabetpointer to the NucleicAlphabet. !!! the pointer will be owned by the genetic code!!!
descriptionfor the name of the GeneticCode: [EchinodermMitochondrialGeneticCode | InvertebrateMitochondrialGeneticCode | InvertebrateMitochondrialGeneticCode | StandardGeneticCode | VertebrateMitochondrialGeneticCode]
Returns
A new GeneticCode object
Exceptions
Exceptionin case of bad description.

Definition at line 200 of file SequenceApplicationTools.cpp.

Referenced by getSitesToAnalyse().

◆ getProbabilisticSiteContainer()

unique_ptr< ProbabilisticVectorSiteContainer > SequenceApplicationTools::getProbabilisticSiteContainer ( std::shared_ptr< const Alphabet alpha,
const std::map< std::string, std::string > &  params,
const std::string &  suffix = "",
bool  suffixIsOptional = true,
bool  verbose = true,
int  warn = 1 
)
static

Build a ProbabilisticSiteContainer object according to the BppO syntax.

Sequences in file must be aligned. The supported sequence formats are Fasta, DCSE, Clustal, Mase and Phylip.

See the Bio++ program suite manual for a full description of the syntax.

Parameters
alphaThe alphabet to use in the container.
paramsThe attribute map where options may be found.
suffixA suffix to be applied to each attribute name.
suffixIsOptionalTell if the suffix is absolutely required.
verbosePrint some info to the 'message' output stream.
warnSet the warning level (0: always display warnings, >0 display warnings on demand).
Returns
A new ProbabilisticVectorSiteContainer object according to the description.

Look for RNY translation

Look for Allelic translation

Definition at line 631 of file SequenceApplicationTools.cpp.

References bpp::ApplicationTools::displayMessage(), bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::getAFilePath(), bpp::ApplicationTools::getBooleanParameter(), bpp::RandomTools::getSample(), bpp::SiteContainerTools::getSelectedSites(), bpp::MaseTools::getSelectedSites(), bpp::ApplicationTools::getStringParameter(), bpp::BppOAlignmentReaderFormat::getUnparsedArguments(), bpp::AlphabetTools::isAllelicAlphabet(), bpp::AlphabetTools::isRNYAlphabet(), bpp::KeyvalTools::parseProcedure(), bpp::BppOAlignmentReaderFormat::read(), bpp::BppOAlignmentReaderFormat::readProbabilistic(), bpp::SequenceTools::RNYslice(), bpp::NumCalcApplicationTools::seqFromString(), bpp::Table< class >::setColumn(), bpp::Table< class >::setRowNames(), and bpp::TextTools::toString().

◆ getProbabilisticSiteContainers()

map< size_t, unique_ptr< ProbabilisticVectorSiteContainer > > SequenceApplicationTools::getProbabilisticSiteContainers ( std::shared_ptr< const Alphabet alpha,
const std::map< std::string, std::string > &  params,
const std::string &  prefix = "input.",
const std::string &  suffix = "",
bool  suffixIsOptional = true,
bool  verbose = true,
int  warn = 1 
)
static

Build multiple ProbabilisticSiteContainer objects according to the BppO syntax.

Sequences in file must be aligned. The supported sequence format is Pasta.

See the Bio++ program suite manual for a full description of the syntax.

Parameters
alphaThe alphabet to use in the container.
paramsThe attribute map where options may be found.
prefixA prefix to be applied to each attribute name.
suffixA suffix to be applied to each attribute name.
suffixIsOptionalTell if the suffix is absolutely required.
verbosePrint some info to the 'message' output stream.
warnSet the warning level (0: always display warnings, >0 display warnings on demand).
Returns
A map of ProbabilisticVectorSiteContainer objects according to the description.

Definition at line 389 of file SequenceApplicationTools.cpp.

References bpp::ApplicationTools::displayMessage(), bpp::ApplicationTools::displayWarning(), bpp::ApplicationTools::getStringParameter(), bpp::AlphabetTools::isCodonAlphabet(), bpp::TextTools::isDecimalInteger(), bpp::ApplicationTools::matchingParameters(), bpp::KeyvalTools::parseProcedure(), and bpp::TextTools::toString().

◆ getSequenceContainer()

std::unique_ptr< SequenceContainerInterface > SequenceApplicationTools::getSequenceContainer ( std::shared_ptr< const Alphabet alpha,
const std::map< std::string, std::string > &  params,
const std::string &  suffix = "",
bool  suffixIsOptional = true,
bool  verbose = true,
int  warn = 1 
)
static

Build a SequenceContainer object according to options.

The sequences do not have to be aligned. The supported sequence formats are Fasta, DCSE, Clustal, Mase, Phylip and GenBank.

See the Bio++ program suite manual for a full description of the syntax.

Parameters
alphaThe alphabet to use in the container.
paramsThe attribute map where options may be found.
suffixA suffix to be applied to each attribute name.
suffixIsOptionalTell if the suffix is absolutely required.
verbosePrint some info to the 'message' output stream.
warnSet the warning level (0: always display warnings, >0 display warnings on demand).
Returns
A new VectorSequenceContainer object according to options specified.
See also
getSiteContainer to read an alignment.

Definition at line 272 of file SequenceApplicationTools.cpp.

References bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::getAFilePath(), bpp::ApplicationTools::getStringParameter(), and bpp::BppOSequenceReaderFormat::read().

◆ getSiteContainer()

std::unique_ptr< VectorSiteContainer > SequenceApplicationTools::getSiteContainer ( std::shared_ptr< const Alphabet alpha,
const std::map< std::string, std::string > &  params,
const std::string &  suffix = "",
bool  suffixIsOptional = true,
bool  verbose = true,
int  warn = 1 
)
static

Build a SiteContainer object according to the BppO syntax.

Sequences in file must be aligned. The supported sequence formats are Fasta, DCSE, Clustal, Mase and Phylip.

See the Bio++ program suite manual for a full description of the syntax.

Parameters
alphaThe alphabet to use in the container.
paramsThe attribute map where options may be found.
suffixA suffix to be applied to each attribute name.
suffixIsOptionalTell if the suffix is absolutely required.
verbosePrint some info to the 'message' output stream.
warnSet the warning level (0: always display warnings, >0 display warnings on demand).
Returns
A new VectorSiteContainer object according to the description.

Look for RNY translation

Definition at line 477 of file SequenceApplicationTools.cpp.

References bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::getAFilePath(), bpp::ApplicationTools::getBooleanParameter(), bpp::RandomTools::getSample(), bpp::SiteContainerTools::getSelectedSites(), bpp::MaseTools::getSelectedSites(), bpp::ApplicationTools::getStringParameter(), bpp::BppOAlignmentReaderFormat::getUnparsedArguments(), bpp::AlphabetTools::isRNYAlphabet(), bpp::KeyvalTools::parseProcedure(), bpp::BppOAlignmentReaderFormat::read(), bpp::SequenceTools::RNYslice(), bpp::NumCalcApplicationTools::seqFromString(), and bpp::TextTools::toString().

◆ getSiteContainers()

map< size_t, unique_ptr< VectorSiteContainer > > SequenceApplicationTools::getSiteContainers ( std::shared_ptr< const Alphabet alpha,
const std::map< std::string, std::string > &  params,
const std::string &  prefix = "input.",
const std::string &  suffix = "",
bool  suffixIsOptional = true,
bool  verbose = true,
int  warn = 1 
)
static

Build multiple SiteContainer objects according to the BppO syntax.

Sequences in file must be aligned. The supported sequence formats are Fasta, DCSE, Clustal, Mase and Phylip.

See the Bio++ program suite manual for a full description of the syntax.

Parameters
alphaThe alphabet to use in the container.
paramsThe attribute map where options may be found.
prefixA prefix to be applied to each attribute name.
suffixA suffix to be applied to each attribute name.
suffixIsOptionalTell if the suffix is absolutely required.
verbosePrint some info to the 'message' output stream.
warnSet the warning level (0: always display warnings, >0 display warnings on demand).
Returns
A map of VectorSiteContainer objects according to the description.

Definition at line 301 of file SequenceApplicationTools.cpp.

References bpp::ApplicationTools::displayMessage(), bpp::ApplicationTools::displayWarning(), bpp::ApplicationTools::getStringParameter(), bpp::AlphabetTools::isCodonAlphabet(), bpp::TextTools::isDecimalInteger(), bpp::ApplicationTools::matchingParameters(), bpp::KeyvalTools::parseProcedure(), and bpp::TextTools::toString().

◆ getSitesToAnalyse()

template<class SiteType , class SequenceType >
static std::unique_ptr< TemplateVectorSiteContainer<SiteType, SequenceType> > bpp::SequenceApplicationTools::getSitesToAnalyse ( const TemplateSiteContainerInterface< SiteType, SequenceType, std::string > &  allSites,
const std::map< std::string, std::string > &  params,
std::string  suffix = "",
bool  suffixIsOptional = true,
bool  gapAsUnknown = true,
bool  verbose = true,
int  warn = 1 
)
inlinestatic

Retrieves sites suitable for the analysis.

Options used are:

  • sequence.sites_to_use = [all|complete|nogap].

If the 'complete' option is used, only fully resolve site will be taken into account. If the 'nogap' option is used, only sites without gap will be taken into account. If 'gapAsUnknown' is set to true and the all option is selected, gaps will be changed to 'unknown' character is sequences.

  • sequence.max_gap_allowed = [57%|30] If a % sign follows the number, it is taken to be a frequence (in percent). This specify the maximum amount of gaps allowed for each site. Sites not satisfying this amount will be removed. A value of 100% will remove all gap-only sites, a value >100% will keep all sites.
Parameters
allSitesThe site container from which sites must be retrieved.
paramsThe attribute map where options may be found.
suffixA suffix to be applied to each attribute name.
suffixIsOptionalTell if the suffix is absolutely required.
gapAsUnknownConvert gaps to unknown characters.
verbosePrint some info to the 'message' output stream.
warnSet the warning level (0: always display warnings, >0 display warnings on demand).
Returns
A new VectorSiteContainer object containing sites of interest.

Definition at line 326 of file SequenceApplicationTools.h.

References bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::SiteContainerTools::getCompleteSites(), getGeneticCode(), bpp::TemplateSequenceDataInterface< HashType >::getNumberOfSequences(), bpp::SiteContainerTools::getSitesWithoutGaps(), bpp::ApplicationTools::getStringParameter(), bpp::SymbolListTools::numberOfGaps(), bpp::SymbolListTools::numberOfUnresolved(), bpp::SiteContainerTools::removeSitesWithStopCodon(), bpp::NumConstants::TINY(), bpp::TextTools::toDouble(), and bpp::TextTools::toString().

◆ restrictSelectedSequencesByName()

void SequenceApplicationTools::restrictSelectedSequencesByName ( SequenceContainerInterface allSequences,
const std::map< std::string, std::string > &  params,
std::string  suffix = "",
bool  suffixIsOptional = true,
bool  verbose = true,
int  warn = 1 
)
static

Retrieves selected sequences (by name).

This method works on the input container and discard sequences not present in the selection.

Recognized options are:

  • sequence.keep_names = [ all | name1,...,nameN ].
  • sequence.remove_names = [ none | name1,...,nameN ].
Parameters
allSequencesThe sequence container from which sequences should be filtered.
paramsThe attribute map where options may be found.
suffixA suffix to be applied to each attribute name.
suffixIsOptionalTell if the suffix is absolutely required.
verbosePrint some info to the 'message' output stream.
warnSet the warning level (0: always display warnings, >0 display warnings on demand).

Definition at line 867 of file SequenceApplicationTools.cpp.

References bpp::ApplicationTools::displayResult(), bpp::TemplateSequenceDataInterface< HashType >::getSequenceNames(), bpp::ApplicationTools::getStringParameter(), and bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::removeSequence().

◆ writeAlignmentFile()

void SequenceApplicationTools::writeAlignmentFile ( const SiteContainerInterface sequences,
const std::map< std::string, std::string > &  params,
const std::string &  suffix = "",
bool  verbose = true,
int  warn = 1 
)
static

Write a sequence alignment file according to options.

The supported sequence formats are Fasta, Mase and Phylip.

See the Bio++ program suite manual for a full description of the syntax.

Parameters
sequencesThe aligned sequences to write.
paramsThe attribute map where options may be found.
suffixA suffix to be applied to each attribute name.
verbosePrint some info to the 'message' output stream.
warnSet the warning level (0: always display warnings, >0 display warnings on demand).

Definition at line 941 of file SequenceApplicationTools.cpp.

References bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::getAFilePath(), bpp::ApplicationTools::getStringParameter(), and bpp::BppOAlignmentWriterFormat::read().

◆ writeSequenceFile()

void SequenceApplicationTools::writeSequenceFile ( const SequenceContainerInterface sequences,
const std::map< std::string, std::string > &  params,
const std::string &  suffix = "",
bool  verbose = true,
int  warn = 1 
)
static

Write a sequence file according to options.

The supported sequence formats are Fasta and Mase.

See the Bio++ program suite manual for a full description of the syntax.

See also
writeSequenceFile(SiteContainer) for writing alignments, with more output formats.
Parameters
sequencesThe sequences to write.
paramsThe attribute map where options may be found.
suffixA suffix to be applied to each attribute name.
verbosePrint some info to the 'message' output stream.
warnSet the warning level (0: always display warnings, >0 display warnings on demand).

Definition at line 918 of file SequenceApplicationTools.cpp.

References bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::getAFilePath(), bpp::ApplicationTools::getStringParameter(), and bpp::BppOSequenceWriterFormat::read().


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