bpp-seq  2.2.0
bpp::SymbolListTools Class Reference

Utilitary functions dealing with both sites and sequences. More...

#include <Bpp/Seq/SymbolListTools.h>

+ Inheritance diagram for bpp::SymbolListTools:

Public Member Functions

 SymbolListTools ()
 
virtual ~SymbolListTools ()
 

Static Public Member Functions

static void getCounts (const SymbolList &list, std::map< int, size_t > &counts)
 Count all states in the list. More...
 
static void getCounts (const SymbolList &list1, const SymbolList &list2, std::map< int, std::map< int, size_t > > &counts) throw (DimensionException)
 Count all pair of states for two lists of the same size. More...
 
static void getCounts (const SymbolList &list, std::map< int, double > &counts, bool resolveUnknowns)
 Count all states in the list, optionaly resolving unknown characters. More...
 
static void getCounts (const SymbolList &list1, const SymbolList &list2, std::map< int, std::map< int, double > > &counts, bool resolveUnknowns) throw (DimensionException)
 Count all pair of states for two lists of the same size, optionaly resolving unknown characters. More...
 
static void getFrequencies (const SymbolList &list, std::map< int, double > &frequencies, bool resolveUnknowns=false)
 Get all states frequencies in the list. More...
 
static void getFrequencies (const SymbolList &list1, const SymbolList &list2, std::map< int, std::map< int, double > > &frequencies, bool resolveUnknowns=false) throw (DimensionException)
 Get all state pairs frequencies for two lists of the same size.. More...
 
static double getGCContent (const SymbolList &list, bool ignoreUnresolved=true, bool ignoreGap=true) throw (AlphabetException)
 Get the GC content of a symbol list. More...
 
static size_t getNumberOfDistinctPositions (const SymbolList &l1, const SymbolList &l2) throw (AlphabetMismatchException)
 Get the number of distinct positions. More...
 
static size_t getNumberOfPositionsWithoutGap (const SymbolList &l1, const SymbolList &l2) throw (AlphabetMismatchException)
 Get the number of positions without gap. More...
 
static void changeGapsToUnknownCharacters (SymbolList &l)
 Change all gap elements to unknown characters. More...
 
static void changeUnresolvedCharactersToGaps (SymbolList &l)
 Change all unknown characters to gap elements. More...
 

Detailed Description

Utilitary functions dealing with both sites and sequences.

Definition at line 56 of file SymbolListTools.h.

Constructor & Destructor Documentation

◆ SymbolListTools()

bpp::SymbolListTools::SymbolListTools ( )
inline

Definition at line 59 of file SymbolListTools.h.

◆ ~SymbolListTools()

virtual bpp::SymbolListTools::~SymbolListTools ( )
inlinevirtual

Definition at line 60 of file SymbolListTools.h.

Member Function Documentation

◆ changeGapsToUnknownCharacters()

void SymbolListTools::changeGapsToUnknownCharacters ( SymbolList l)
static

Change all gap elements to unknown characters.

Parameters
lThe input list of characters.

Definition at line 180 of file SymbolListTools.cpp.

References bpp::SymbolList::getAlphabet(), bpp::Alphabet::getUnknownCharacterCode(), bpp::Alphabet::isGap(), and bpp::SymbolList::size().

◆ changeUnresolvedCharactersToGaps()

void SymbolListTools::changeUnresolvedCharactersToGaps ( SymbolList l)
static

Change all unknown characters to gap elements.

Parameters
lThe input list of characters.

Definition at line 189 of file SymbolListTools.cpp.

References bpp::SymbolList::getAlphabet(), bpp::Alphabet::getGapCharacterCode(), bpp::Alphabet::isUnresolved(), and bpp::SymbolList::size().

◆ getCounts() [1/4]

static void bpp::SymbolListTools::getCounts ( const SymbolList list,
std::map< int, size_t > &  counts 
)
inlinestatic

Count all states in the list.

Author
J. Dutheil
Parameters
listThe list.
countsThe output map to store the counts (existing counts will be incremented).

Definition at line 70 of file SymbolListTools.h.

References bpp::SymbolList::getContent().

Referenced by bpp::SiteTools::getNumberOfDistinctCharacters(), bpp::SequenceApplicationTools::getSitesToAnalyse(), bpp::SiteTools::isParsimonyInformativeSite(), and bpp::CodonSiteTools::numberOfNonSynonymousSubstitutions().

◆ getCounts() [2/4]

static void bpp::SymbolListTools::getCounts ( const SymbolList list1,
const SymbolList list2,
std::map< int, std::map< int, size_t > > &  counts 
)
throw (DimensionException
)
inlinestatic

Count all pair of states for two lists of the same size.

NB: The two lists do node need to share the same alphabet! The states of the first list will be used as the first index in the output, and the ones from the second list as the second index.

Author
J. Dutheil
Parameters
list1The first list.
list2The second list.
countsThe output map to store the counts (existing counts will be incremented).

Definition at line 90 of file SymbolListTools.h.

◆ getCounts() [3/4]

void SymbolListTools::getCounts ( const SymbolList list,
std::map< int, double > &  counts,
bool  resolveUnknowns 
)
static

Count all states in the list, optionaly resolving unknown characters.

For instance, in DNA, N will be counted as A=1/4,T=1/4,C=1/4,G=1/4.

Author
J. Dutheil
Parameters
listThe list.
countsThe output map to store the counts (existing ocunts will be incremented).
resolveUnknownsTell is unknown characters must be resolved. For instance, in DNA, N will be counted as A=1/4,T=1/4,C=1/4,G=1/4.
Returns
A map with all states and corresponding counts.

Definition at line 51 of file SymbolListTools.cpp.

References bpp::Alphabet::getAlias(), bpp::SymbolList::getAlphabet(), and bpp::SymbolList::getContent().

◆ getCounts() [4/4]

void SymbolListTools::getCounts ( const SymbolList list1,
const SymbolList list2,
std::map< int, std::map< int, double > > &  counts,
bool  resolveUnknowns 
)
throw (DimensionException
)
static

Count all pair of states for two lists of the same size, optionaly resolving unknown characters.

For instance, in DNA, N will be counted as A=1/4,T=1/4,C=1/4,G=1/4.

NB: The two lists do node need to share the same alphabet! The states of the first list will be used as the first index in the output, and the ones from the second list as the second index.

Author
J. Dutheil
Parameters
list1The first list.
list2The second list.
countsThe output map to store the counts (existing ocunts will be incremented).
resolveUnknownsTell is unknown characters must be resolved. For instance, in DNA, N will be counted as A=1/4,T=1/4,C=1/4,G=1/4.
Returns
A map with all states and corresponding counts.

Definition at line 73 of file SymbolListTools.cpp.

◆ getFrequencies() [1/2]

void SymbolListTools::getFrequencies ( const SymbolList list,
std::map< int, double > &  frequencies,
bool  resolveUnknowns = false 
)
static

Get all states frequencies in the list.

Author
J. Dutheil
Parameters
listThe list.
resolveUnknownsTell is unknown characters must be resolved. For instance, in DNA, N will be counted as A=1/4,T=1/4,C=1/4,G=1/4.
frequenciesThe output map with all states and corresponding frequencies. Existing frequencies will be erased if any.

Definition at line 96 of file SymbolListTools.cpp.

References bpp::SymbolList::size().

Referenced by bpp::CodonSiteTools::generateCodonSiteWithoutRareVariant(), bpp::SiteContainerTools::getConsensus(), bpp::SequenceApplicationTools::getSitesToAnalyse(), bpp::CodonSiteTools::meanNumberOfSynonymousPositions(), bpp::CodonSiteTools::piNonSynonymous(), bpp::CodonSiteTools::piSynonymous(), and bpp::SiteContainerTools::removeGapSites().

◆ getFrequencies() [2/2]

void SymbolListTools::getFrequencies ( const SymbolList list1,
const SymbolList list2,
std::map< int, std::map< int, double > > &  frequencies,
bool  resolveUnknowns = false 
)
throw (DimensionException
)
static

Get all state pairs frequencies for two lists of the same size..

Author
J. Dutheil
Parameters
list1The first list.
list2The second list.
resolveUnknownsTell is unknown characters must be resolved. For instance, in DNA, N will be counted as A=1/4,T=1/4,C=1/4,G=1/4.
frequenciesThe output map with all state pairs and corresponding frequencies. Existing frequencies will be erased if any.

Definition at line 107 of file SymbolListTools.cpp.

◆ getGCContent()

double SymbolListTools::getGCContent ( const SymbolList list,
bool  ignoreUnresolved = true,
bool  ignoreGap = true 
)
throw (AlphabetException
)
static

Get the GC content of a symbol list.

Parameters
listThe list.
Returns
The proportion of G and C states in the list.
Parameters
ignoreUnresolvedDo not count unresolved states. Otherwise, weight by each state probability in case of ambiguity (e.g. the R state counts for 0.5).
ignoreGapDo not count gaps in total.
Exceptions
AlphabetExceptionIf the list is not made of nucleotide states.

Definition at line 119 of file SymbolListTools.cpp.

◆ getNumberOfDistinctPositions()

size_t SymbolListTools::getNumberOfDistinctPositions ( const SymbolList l1,
const SymbolList l2 
)
throw (AlphabetMismatchException
)
static

Get the number of distinct positions.

The comparison in achieved from position 0 to the minimum size of the two vectors.

Parameters
l1SymbolList 1.
l2SymbolList 2.
Returns
The number of distinct positions.
Exceptions
AlphabetMismatchExceptionif the two lists have not the same alphabet type.

Definition at line 158 of file SymbolListTools.cpp.

◆ getNumberOfPositionsWithoutGap()

size_t SymbolListTools::getNumberOfPositionsWithoutGap ( const SymbolList l1,
const SymbolList l2 
)
throw (AlphabetMismatchException
)
static

Get the number of positions without gap.

The comparison in achieved from position 0 to the minimum size of the two vectors.

Parameters
l1SymbolList 1.
l2SymbolList 2.
Returns
The number of positions without gap.
Exceptions
AlphabetMismatchExceptionif the two lists have not the same alphabet type.

Definition at line 169 of file SymbolListTools.cpp.


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