60 const std::vector<const CruxSymbolListSite*>& vs,
62 bool checkPositions) :
69 throw Exception(
"VectorProbabilisticSiteContainer::VectorProbabilisticSiteContainer(vector). Empty site set.");
71 size_t nbSeq = vs[0]->size();
74 for (
size_t i = 0; i < nbSeq; i++)
78 for (
size_t i = 0; i < vs.size(); i++)
81 throw Exception(
"VectorProbabilisticSiteContainer::VectorProbabilisticSiteContainer : Not a ProbabilisticSite in position " +
TextTools::toString(i));
89 const std::vector<std::string>& names,
const Alphabet* alpha) :
109 throw Exception(
"VectorProbabilisticSiteContainer::VectorProbabilisticSiteContainer(AlignedValuesContainer). Empty site set.");
157 addSite(shared_ptr<ProbabilisticSite>(vpsc.
getSite(i)->clone()),
false);
160 for (
const auto& name:vnames)
175 if (site->getAlphabet()->getAlphabetType() !=
getAlphabet()->getAlphabetType())
178 int position = site->getPosition();
186 if (
getSite(i) !=
nullptr &&
getSite(i)->getPosition() == position)
187 throw Exception(
"VectorProbabilisticSiteContainer::addSite. Site position: " +
TextTools::toString(position) +
", already used in container.");
192 for (
size_t i = 0; i < site->size(); i++)
214 throw Exception(
"VectorProbabilisticSiteContainer::addSequence. Name: " + sequence.
getName() +
", already exists in the container.");
221 for (
size_t i = 0; i < (size_t)sequence.
size(); i++)
254 throw Exception(
"VectorProbabilisticSiteContainer::addSequence. Name: " + sequence.
getName() +
", already exists in the container.");
261 for (
size_t i = 0; i < (size_t)sequence.
size(); i++)
275 vector<double> vd(size, 0.);
277 for (
size_t i = 0; i < sequence.
size(); i++)
279 for (
size_t s = 0; s < size; s++)
302 auto s = std::make_shared<ProbabilisticSite>(
getAlphabet());
304 for (
size_t i = 0; i < n; i++)
316 getSite(i)->setPosition((
int)i + 1);
327 positions[i] =
getSite(i)->getPosition();
342 getSite(i)->setPosition(vPositions[i]);
370 for (
size_t j = 0; j < n; j++)
416 const string& sname = sequence.
getName();
431 throw Exception(
"VectorProbabilisticSiteContainer::setSequence. Name already exists in another sequence in container " + sname);
Partial implementation of the OrderedSequenceContainer interface.
void setGeneralComments(const Comments &comments)
Set the comments of this container.
const Comments & getGeneralComments() const
Get the comments of this container.
AbstractProbabilisticSequenceContainer & operator=(const AbstractProbabilisticSequenceContainer &sc)
Partial implementation of the OrderedSequenceContainer interface.
const Alphabet * getAlphabet() const
Get container's alphabet.
The Container of Aligned Values interface.
virtual const CruxSymbolListSite & getSymbolListSite(size_t siteIndex) const =0
Get a CruxSymbolListSite from a given position.
virtual size_t getNumberOfSites() const =0
Get the number of aligned positions in the container.
Exception thrown when two alphabets do not match.
virtual std::string getAlphabetType() const =0
Identification method.
virtual unsigned int getSize() const =0
Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet)....
A basic implementation of the ProbabilisticSequence interface.
virtual const std::string & getName() const =0
Get the name of this sequence.
virtual const Comments & getComments() const =0
Get the comments.
virtual const T & getValue(size_t pos) const =0
checked access to a character in list.
virtual const Alphabet * getAlphabet() const =0
Get the alphabet associated to the list.
virtual double getStateValueAt(size_t siteIndex, int state) const
virtual size_t size() const =0
Get the number of elements in the list.
void changeName(const std::string &okey, const std::string &nkey)
change the key of an object.
bool isAvailableName(std::string objectName) const
Return if the name is in the map keys and the mapped object is nullptr or empty.
The OrderedSequenceContainer interface.
virtual const Sequence & getSequence(size_t sequenceIndex) const =0
Retrieve a sequence object from the container.
The probabilistic sequence interface.
virtual const std::vector< std::vector< double > > & getContent() const =0
The ProbabilisticSite interface.
virtual size_t getNumberOfSequences() const =0
Get the number of sequences in the container.
virtual std::vector< std::string > getSequenceNames() const =0
Get all the names of the sequences in the container.
void addColumn(const std::vector< T > &newColumn, int pos=-1)
The template VectorMappedContainer class.
const std::shared_ptr< T > getObject(size_t objectIndex) const
Retrieve an object from the container. Set as protected since they will be public under T specific na...
void appendObject(std::shared_ptr< T > object, const std::string &name, bool check=true)
void addObject_(std::shared_ptr< T > object, size_t objectIndex, const std::string &name, bool check=false) const
void clear()
Delete all objects in the container.
std::string getObjectName(size_t objectIndex) const
bool hasObject(const std::string &name) const
The template VectorPositionedContainer class.
void appendObject(std::shared_ptr< T > object)
void nullify()
Nullify all elements.
void setSize(size_t size)
void clear()
Destroys the vector.
The VectorProbabilisticSiteContainer class.
Vint getSitePositions() const
Get all position attributes of sites.
VectorProbabilisticSiteContainer & operator=(const VectorProbabilisticSiteContainer &vpsc)
void setSequence(const std::string &name, const ProbabilisticSequence &sequence, bool checkName)
Replace a probabilistic sequence in the container.
VectorProbabilisticSiteContainer(const Alphabet *alpha)
Build a new emtpy container.
const ProbabilisticSequence & getSequence(std::size_t i) const
Get Sequence from a position in the container.
void addSite(std::shared_ptr< ProbabilisticSite > site, bool checkPosition=false)
Add a site at the end of the container.
size_t getNumberOfSites() const
Get the number of aligned positions in the container.
void reindexSites()
Set all positions attributes.
void setSequenceNames(const std::vector< std::string > &names, bool checkNames=true)
Set all sequence names.
void clear()
Delete all objects in the container.
size_t getNumberOfSequences() const
Get the number of sequences in the container.
std::vector< std::string > getSequenceNames() const
Get all the names of the sequences in the container.
const std::shared_ptr< ProbabilisticSite > getSite(size_t i) const
Get a site from the container.
void addSequence(const ProbabilisticSequence &sequence, bool checkName=true)
Add a probabilistic sequence to the container.
VectorProbabilisticSiteContainer * clone() const
size_t getSequencePosition(const std::string &name) const
Get the position of a sequence in sequence container from its name.
VectorProbabilisticSiteContainer * createEmptyContainer() const
Return a copy of this container, but with no data inside.
void setSitePositions(Vint vPositions)
Set all position attributes of sites.
std::string toString(T t)
This alphabet is used to deal NumericAlphabet.