40 #ifndef _MAFSTATISTICS_H_ 41 #define _MAFSTATISTICS_H_ 46 #include <Bpp/Utils/MapTools.h> 47 #include <Bpp/Numeric/VectorTools.h> 48 #include <Bpp/Numeric/Number.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();
81 virtual const BppNumberI&
getValue(
const std::string& tag)
const throw (Exception) {
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)
throw (Exception) {
99 values_[tag] =
new BppDouble(value);
108 virtual void setValue(
const std::string& tag,
int value)
throw (Exception) {
112 values_[tag] =
new BppInteger(value);
121 virtual void setValue(
const std::string& tag,
unsigned int value)
throw (Exception) {
125 values_[tag] =
new BppUnsignedInteger(value);
132 virtual bool hasValue(
const std::string& tag)
const {
162 virtual void setValue(
const std::string& tag,
double value)
throw (Exception) {
166 throw Exception(
"SimpleMafStatisticsResult::setValue(). Unvalid tag name: " + tag +
".");
169 virtual void setValue(
const std::string& tag,
int value)
throw (Exception) {
173 throw Exception(
"SimpleMafStatisticsResult::setValue(). Unvalid tag name: " + tag +
".");
176 virtual void setValue(
const std::string& tag,
unsigned int value)
throw (Exception) {
180 throw Exception(
"SimpleMafStatisticsResult::setValue(). Unvalid tag name: " + tag +
".");
295 std::string
getFullName()
const {
return "Number of sequences."; }
340 if (seqs.size() == 0)
342 else if (seqs.size() == 1)
343 result_.
setValue(static_cast<double>(SequenceTools::getNumberOfSites(*seqs[0])));
345 throw Exception(
"SequenceLengthMafStatistics::compute. More than one sequence found for species " +
species_ +
" in current block.");
391 AbstractMafStatistics::operator=(stats);
472 size_t getCategory(
double value)
const throw (OutOfRangeException) {
474 throw OutOfRangeException(
"SiteFrequencySpectrumMafStatistics::Categorizer::getCategory.", value, *
bounds_.begin(), *
bounds_.rbegin());
475 for (
size_t i = 1; i <
bounds_.size(); ++i) {
479 throw OutOfRangeException(
"SiteFrequencySpectrumMafStatistics::Categorizer::getCategory.", value, *
bounds_.begin(), *
bounds_.rbegin());
509 AbstractMafStatistics::operator=(stats);
510 AbstractSpeciesSelectionMafStatistics::operator=(stats);
522 std::string
getFullName()
const {
return "Site frequency spectrum."; }
548 const Alphabet* alphabet,
549 const std::vector<std::string>& species):
555 if (species.size() != 4)
556 throw Exception(
"FourSpeciesPatternCountsMafStatistics, constructor: 4 species should be provided.");
557 if (VectorTools::unique(species).size() != 4)
558 throw Exception(
"FourSpeciesPatternCountsMafStatistics, constructor: duplicated species name!");
569 AbstractMafStatistics::operator=(stats);
570 AbstractSpeciesSelectionMafStatistics::operator=(stats);
579 std::string
getShortName()
const {
return "FourSpeciesPatternCounts"; }
580 std::string
getFullName()
const {
return "FourSpecies pattern counts."; }
636 if (species.size() != 2)
637 throw Exception(
"PolymorphismStatistics: exactly two species selection should be provided.");
644 std::string
getFullName()
const {
return "Polymorphism statistics."; }
649 static std::vector<int>
getPatterns_(
const SiteContainer& sites);
675 std::string
getShortName()
const {
return "SequenceDiversityStatistics"; }
676 std::string
getFullName()
const {
return "Sequence diversity statistics."; }
681 static std::vector<int>
getPatterns_(
const SiteContainer& sites);
687 #endif //_MAFSTATISTICS_H_
std::string getFullName() const
Counts number of polymorphic / fixed sites in two populations.
virtual const BppNumberI & getValue(const std::string &tag) const
CharacterCountsMafStatistics(const CharacterCountsMafStatistics &stats)
MafStatisticsResult(const MafStatisticsResult &msr)
std::vector< std::string > getSupportedTags() const
std::string getShortName() const
std::map< std::string, BppNumberI * > values_
PolymorphismMafStatistics(const std::vector< std::vector< std::string > > &species)
void compute(const MafBlock &block)
virtual ~SiteMafStatistics()
std::string getShortName() const
virtual ~CharacterCountsMafStatistics()
Provide estimates of sequence diversity.
void compute(const MafBlock &block)
const MafStatisticsResult & getResult() const
General interface for storing statistical results.
FourSpeciesPatternCountsMafStatistics(const FourSpeciesPatternCountsMafStatistics &stats)
BlockLengthMafStatistics()
std::string getFullName() const
SiteMafStatistics(const std::vector< std::string > &species)
virtual void setValue(int value)
virtual bool hasValue(const std::string &tag) const
virtual ~SequenceDiversityMafStatistics()
std::vector< const MafSequence * > getSequencesForSpecies(const std::string &species) const
Partial implementation of MafStatistics, for convenience.
~PairwiseDivergenceMafStatistics()
SimpleMafStatisticsResult result_
void compute(const MafBlock &block)
std::vector< std::string > getSupportedTags() const
Retrieve the sequence length (number of nucleotides) for a given species in a maf block...
virtual ~MafStatisticsResult()
std::vector< unsigned int > counts_
Retrieves the alignment score of a maf block.
General interface for computing statistics based on a Maf block.
void compute(const MafBlock &block)
virtual void setValue(const std::string &tag, unsigned int value)
Associate a value to a certain tag. Any existing tag will be overwritten.
size_t getNumberOfSites() const
std::string getShortName() const
std::string getShortName() const
std::vector< std::string > getSupportedTags() const
~BlockSizeMafStatistics()
SiteFrequencySpectrumMafStatistics & operator=(const SiteFrequencySpectrumMafStatistics &stats)
virtual ~AbstractMafStatisticsSimple()
Computes the number of columns in a maf block.
virtual std::string getShortName() const =0
void compute(const MafBlock &block)
Compute the frequency of site patterns for a quadruplet of species.
FourSpeciesPatternCountsMafStatistics(const Alphabet *alphabet, const std::vector< std::string > &species)
CharacterCountsMafStatistics & operator=(const CharacterCountsMafStatistics &stats)
std::string getFullName() const
std::string getShortName() const
void compute(const MafBlock &block)
std::vector< std::string > getSupportedTags() const
AbstractMafStatisticsSimple(const std::string &name)
std::string getShortName() const
virtual void setValue(const std::string &tag, unsigned int value)
Associate a value to a certain tag. Any existing tag will be overwritten.
A synteny block data structure, the basic unit of a MAF alignement file.
std::string getShortName() const
std::vector< std::string > getAvailableTags() const
std::string getShortName() const
const Alphabet * alphabet_
Compute the Site Frequency Spectrum of a maf block.
void compute(const MafBlock &block)
std::vector< std::string > getSupportedTags() const
SiteContainer * getSiteContainer_(const MafBlock &block)
Partial implementation of MafStatistics, for convenience.
virtual std::string getFullName() const =0
std::string getFullName() const
SiteFrequencySpectrumMafStatistics(const Alphabet *alphabet, const std::vector< double > &bounds, const std::vector< std::string > &ingroup, const std::string outgroup="")
SiteFrequencySpectrumMafStatistics(const SiteFrequencySpectrumMafStatistics &stats)
virtual std::vector< std::string > getSupportedTags() const =0
AlignmentScoreMafStatistics()
void compute(const MafBlock &block)
void compute(const MafBlock &block)
const SimpleMafStatisticsResult & getResult() const
virtual const MafStatisticsResult & getResult() const =0
std::vector< std::vector< std::string > > species_
virtual const BppNumberI & getValue(const std::string &tag) const
const Alphabet * alphabet_
virtual void compute(const MafBlock &block)=0
Compute the base frequencies of a maf block.
virtual ~FourSpeciesPatternCountsMafStatistics()
~SequenceLengthMafStatistics()
std::vector< SiteContainer * > getSiteContainers_(const MafBlock &block)
~AlignmentScoreMafStatistics()
std::vector< unsigned int > counts_
size_t getCategory(double value) const
virtual void setValue(const std::string &tag, int value)
Associate a value to a certain tag. Any existing tag will be overwritten.
virtual ~SiteFrequencySpectrumMafStatistics()
virtual ~SimpleMafStatisticsResult()
std::string getFullName() const
void compute(const MafBlock &block)
std::vector< std::string > getSupportedTags() const
std::string getFullName() const
virtual const BppNumberI & getValue() const
PairwiseDivergenceMafStatistics(const std::string &species1, const std::string &species2)
static std::vector< int > getPatterns_(const SiteContainer &sites)
Partial implementation of MafStatistics for method working on a subset of species, in a site-wise manner.
virtual void setValue(const std::string &tag, double value)
Associate a value to a certain tag. Any existing tag will be overwritten.
static std::vector< int > getPatterns_(const SiteContainer &sites)
AbstractSpeciesSelectionMafStatistics(const std::vector< std::string > &species)
FourSpeciesPatternCountsMafStatistics & operator=(const FourSpeciesPatternCountsMafStatistics &stats)
std::string getFullName() const
virtual void setValue(const std::string &tag, double value)
Associate a value to a certain tag. Any existing tag will be overwritten.
std::string getFullName() const
AbstractSpeciesMultipleSelectionMafStatistics(const std::vector< std::vector< std::string > > &species)
Partial implementation of MafStatistics for method working on multiple distinct subsets of species...
std::string getShortName() const
const Alphabet * alphabet_
void compute(const MafBlock &block)
std::string getShortName() const
std::string getFullName() const
virtual ~PolymorphismMafStatistics()
Computes the pairwise divergence for a pair of sequences in a maf block.
std::string getFullName() const
Computes the number of sequences in a maf block.
virtual ~AbstractMafStatistics()
size_t getNumberOfSequences() const
std::string getShortName() const
Compute a few site statistics in a maf block.
std::vector< double > bounds_
MafStatisticsResult result_
std::vector< std::string > species_
~BlockLengthMafStatistics()
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
SequenceDiversityMafStatistics(const std::vector< std::string > &ingroup)
A simple maf statistics result, with only one value.
Categorizer(const std::vector< double > &bounds)
SequenceLengthMafStatistics(const std::string &species)
CharacterCountsMafStatistics(const Alphabet *alphabet)
SimpleMafStatisticsResult(const std::string &name)
std::string getFullName() const
virtual void setValue(double value)
virtual void setValue(unsigned int value)
std::vector< std::string > getSupportedTags() const