40 #ifndef _MAFSTATISTICS_H_
41 #define _MAFSTATISTICS_H_
65 mutable std::map<std::string, BppNumberI*>
values_;
73 for (std::map<std::string, BppNumberI*>::const_iterator it = msr.
values_.begin();
76 values_[it->first] = it->second->clone();
82 std::map<std::string, BppNumberI*>::iterator it =
values_.find(tag);
86 throw Exception(
"MafStatisticsResult::getValue(). No value found for tag: " + tag +
".");
95 virtual void setValue(
const std::string& tag,
double value) {
108 virtual void setValue(
const std::string& tag,
int value) {
121 virtual void setValue(
const std::string& tag,
unsigned int value) {
132 virtual bool hasValue(
const std::string& tag)
const {
164 virtual void setValue(
const std::string& tag,
double value) {
168 throw Exception(
"SimpleMafStatisticsResult::setValue(). Unvalid tag name: " + tag +
".");
171 virtual void setValue(
const std::string& tag,
int value) {
175 throw Exception(
"SimpleMafStatisticsResult::setValue(). Unvalid tag name: " + tag +
".");
178 virtual void setValue(
const std::string& tag,
unsigned int value) {
182 throw Exception(
"SimpleMafStatisticsResult::setValue(). Unvalid tag name: " + tag +
".");
297 std::string
getFullName()
const {
return "Number of sequences."; }
342 if (seqs.size() == 0)
344 else if (seqs.size() == 1)
347 throw Exception(
"SequenceLengthMafStatistics::compute. More than one sequence found for species " +
species_ +
" in current block.");
389 const std::vector<std::string>& species,
390 bool noSpeciesMeansAllSpecies =
false,
391 const std::string& suffix =
""):
455 AbstractMafStatistics::operator=(stats);
456 AbstractSpeciesSelectionMafStatistics::operator=(stats);
500 for (
size_t i = 1; i <
bounds_.size(); ++i) {
534 AbstractMafStatistics::operator=(stats);
535 AbstractSpeciesSelectionMafStatistics::operator=(stats);
547 std::string
getFullName()
const {
return "Site frequency spectrum."; }
574 const std::vector<std::string>& species):
580 if (species.size() != 4)
581 throw Exception(
"FourSpeciesPatternCountsMafStatistics, constructor: 4 species should be provided.");
583 throw Exception(
"FourSpeciesPatternCountsMafStatistics, constructor: duplicated species name!");
594 AbstractMafStatistics::operator=(stats);
595 AbstractSpeciesSelectionMafStatistics::operator=(stats);
604 std::string
getShortName()
const {
return "FourSpeciesPatternCounts"; }
605 std::string
getFullName()
const {
return "FourSpecies pattern counts."; }
665 if (species.size() != 2)
666 throw Exception(
"PolymorphismStatistics: exactly two species selection should be provided.");
673 std::string
getFullName()
const {
return "Polymorphism statistics."; }
706 std::string
getShortName()
const {
return "SequenceDiversityStatistics"; }
707 std::string
getFullName()
const {
return "Sequence diversity statistics."; }
Partial implementation of MafStatistics, for convenience.
const SimpleMafStatisticsResult & getResult() const
virtual ~AbstractMafStatisticsSimple()
AbstractMafStatisticsSimple(const std::string &name)
SimpleMafStatisticsResult result_
std::vector< std::string > getSupportedTags() const
Partial implementation of MafStatistics, for convenience.
virtual ~AbstractMafStatistics()
const MafStatisticsResult & getResult() const
MafStatisticsResult result_
Partial implementation of MafStatistics for method working on multiple distinct subsets of species,...
std::vector< SiteContainer * > getSiteContainers_(const MafBlock &block)
AbstractSpeciesMultipleSelectionMafStatistics(const std::vector< std::vector< std::string > > &species)
std::vector< std::vector< std::string > > species_
Partial implementation of MafStatistics for method working on a subset of species,...
SiteContainer * getSiteContainer_(const MafBlock &block)
AbstractSpeciesSelectionMafStatistics(const std::vector< std::string > &species, bool noSpeciesMeansAllSpecies=false, const std::string &suffix="")
std::vector< std::string > species_
bool noSpeciesMeansAllSpecies_
Retrieves the alignment score of a maf block.
~AlignmentScoreMafStatistics()
std::string getFullName() const
std::string getShortName() const
AlignmentScoreMafStatistics()
void compute(const MafBlock &block)
Computes the number of columns in a maf block.
~BlockLengthMafStatistics()
void compute(const MafBlock &block)
std::string getShortName() const
BlockLengthMafStatistics()
std::string getFullName() const
Computes the number of sequences in a maf block.
void compute(const MafBlock &block)
std::string getShortName() const
std::string getFullName() const
~BlockSizeMafStatistics()
Compute the base frequencies of a maf block.
std::string getFullName() const
virtual ~CharacterCountsMafStatistics()
std::string getShortName() const
std::vector< std::string > getSupportedTags() const
CharacterCountsMafStatistics(const CharacterCountsMafStatistics &stats)
void compute(const MafBlock &block)
const Alphabet * alphabet_
CharacterCountsMafStatistics(const Alphabet *alphabet, const std::vector< std::string > &species, const std::string suffix)
CharacterCountsMafStatistics & operator=(const CharacterCountsMafStatistics &stats)
Compute the frequency of site patterns for a quadruplet of species.
std::vector< unsigned int > counts_
std::string getShortName() const
const Alphabet * alphabet_
std::string getFullName() const
FourSpeciesPatternCountsMafStatistics(const FourSpeciesPatternCountsMafStatistics &stats)
void compute(const MafBlock &block)
FourSpeciesPatternCountsMafStatistics & operator=(const FourSpeciesPatternCountsMafStatistics &stats)
std::vector< std::string > getSupportedTags() const
FourSpeciesPatternCountsMafStatistics(const Alphabet *alphabet, const std::vector< std::string > &species)
virtual ~FourSpeciesPatternCountsMafStatistics()
A synteny block data structure, the basic unit of a MAF alignement file.
size_t getNumberOfSequences() const
std::vector< const MafSequence * > getSequencesForSpecies(const std::string &species) const
size_t getNumberOfSites() const
General interface for storing statistical results.
virtual void setValue(const std::string &tag, unsigned int value)
Associate a value to a certain tag. Any existing tag will be overwritten.
virtual void setValue(const std::string &tag, int value)
Associate a value to a certain tag. Any existing tag will be overwritten.
std::map< std::string, BppNumberI * > values_
std::vector< std::string > getAvailableTags() const
virtual void setValue(const std::string &tag, double value)
Associate a value to a certain tag. Any existing tag will be overwritten.
MafStatisticsResult(const MafStatisticsResult &msr)
virtual const BppNumberI & getValue(const std::string &tag) const
virtual ~MafStatisticsResult()
virtual bool hasValue(const std::string &tag) const
General interface for computing statistics based on a Maf block.
virtual void compute(const MafBlock &block)=0
virtual const MafStatisticsResult & getResult() const =0
virtual std::vector< std::string > getSupportedTags() const =0
virtual std::string getFullName() const =0
virtual std::string getShortName() const =0
Computes the pairwise divergence for a pair of sequences in a maf block.
void compute(const MafBlock &block)
std::string getShortName() const
std::string getFullName() const
PairwiseDivergenceMafStatistics(const std::string &species1, const std::string &species2)
~PairwiseDivergenceMafStatistics()
Counts number of polymorphic / fixed sites in two populations.
static std::vector< int > getPatterns_(const SiteContainer &sites)
PolymorphismMafStatistics(const std::vector< std::vector< std::string > > &species)
std::string getFullName() const
std::string getShortName() const
virtual ~PolymorphismMafStatistics()
void compute(const MafBlock &block)
std::vector< std::string > getSupportedTags() const
Provide estimates of sequence diversity.
std::vector< std::string > getSupportedTags() const
static std::vector< int > getPatterns_(const SiteContainer &sites)
void compute(const MafBlock &block)
virtual ~SequenceDiversityMafStatistics()
std::string getShortName() const
SequenceDiversityMafStatistics(const std::vector< std::string > &ingroup)
std::string getFullName() const
Retrieve the sequence length (number of nucleotides) for a given species in a maf block.
std::string getFullName() const
void compute(const MafBlock &block)
std::string getShortName() const
SequenceLengthMafStatistics(const std::string &species)
~SequenceLengthMafStatistics()
A simple maf statistics result, with only one value.
virtual const BppNumberI & getValue(const std::string &tag) const
SimpleMafStatisticsResult(const std::string &name)
virtual void setValue(int value)
virtual ~SimpleMafStatisticsResult()
virtual void setValue(const std::string &tag, double value)
Associate a value to a certain tag. Any existing tag will be overwritten.
virtual void setValue(double value)
virtual void setValue(const std::string &tag, unsigned int value)
Associate a value to a certain tag. Any existing tag will be overwritten.
virtual const BppNumberI & getValue() const
virtual void setValue(unsigned int value)
virtual void setValue(const std::string &tag, int value)
Associate a value to a certain tag. Any existing tag will be overwritten.
size_t getNumberOfCategories() const
size_t getCategory(double value) const
Categorizer(const std::vector< double > &bounds)
std::vector< double > bounds_
Compute the Site Frequency Spectrum of a maf block.
std::vector< std::string > getSupportedTags() const
virtual ~SiteFrequencySpectrumMafStatistics()
std::string getShortName() const
std::string getFullName() const
std::vector< unsigned int > counts_
SiteFrequencySpectrumMafStatistics(const SiteFrequencySpectrumMafStatistics &stats)
const Alphabet * alphabet_
SiteFrequencySpectrumMafStatistics & operator=(const SiteFrequencySpectrumMafStatistics &stats)
void compute(const MafBlock &block)
SiteFrequencySpectrumMafStatistics(const Alphabet *alphabet, const std::vector< double > &bounds, const std::vector< std::string > &ingroup, const std::string outgroup="")
Compute a few site statistics in a maf block.
std::string getShortName() const
void compute(const MafBlock &block)
std::vector< std::string > getSupportedTags() const
virtual ~SiteMafStatistics()
SiteMafStatistics(const std::vector< std::string > &species)
std::string getFullName() const