53 VectorSiteContainer::VectorSiteContainer(
54 const std::vector<const CruxSymbolListSite*>& vs,
56 bool checkPositions) :
62 throw Exception(
"VectorSiteContainer::VectorSiteContainer. Empty site set.");
64 size_t nbSeq = vs[0]->size();
68 for (
size_t i = 0; i < nbSeq; i++)
72 for (
size_t i = 0; i < vs.size(); i++)
74 if (!
dynamic_cast<const Site*
>(vs[i]))
77 addSite(
dynamic_cast<const Site&
>(*vs[i]), checkPositions);
82 const std::vector<const Site*>& vs,
84 bool checkPositions) :
90 throw Exception(
"VectorSiteContainer::VectorSiteContainer. Empty site set.");
92 size_t nbSeq = vs[0]->size();
96 for (
size_t i = 0; i < nbSeq; i++)
100 for (
size_t i = 0; i < vs.size(); i++)
102 addSite(*vs[i], checkPositions);
114 for (
size_t i = 0; i < size; i++)
202 throw Exception(
"VectorSiteContainer::VectorSiteContainer(AlignedValuesContainer): Empty site set.");
258 for (
size_t i = 0; i < nbSeq; i++)
290 throw SiteException(
"AlignedSequenceContainer::setSite. Site does not have the appropriate length", &site);
304 throw SiteException(
"VectorSiteContainer::setSite: Site position already exists in container", &site);
324 throw SiteException(
"VectorSiteContainer::addSite. Site does not have the appropriate length", &site);
338 throw SiteException(
"VectorSiteContainer::addSite(site, bool): Site position already exists in container", &site);
345 for (
size_t i = 0; i < site.
size(); i++)
365 throw SiteException(
"VectorSiteContainer::addSite. Site does not have the appropriate length", &site);
378 throw SiteException(
"VectorSiteContainer::addSite. Site position already exists in container", &site);
382 shared_ptr<Site> nsite(shared_ptr<Site>(site.
clone()));
383 nsite->setPosition(position);
387 for (
size_t i = 0; i < site.
size(); i++)
402 throw SiteException(
"VectorSiteContainer::addSite. Site does not have the appropriate length", &site);
416 throw SiteException(
"VectorSiteContainer::addSite. Site position already exists in container", &site);
423 for (
size_t i = 0; i < site.
size(); i++)
444 throw SiteException(
"VectorSiteContainer::addSite. Site does not have the appropriate length", &site);
459 throw SiteException(
"VectorSiteContainer::addSite. Site position already exists in container", &site);
463 shared_ptr<Site> nsite(shared_ptr<Site>(site.
clone()));
464 nsite->setPosition(position);
468 for (
size_t i = 0; i < site.
size(); i++)
530 vector<int> sequence(n);
531 for (
size_t j = 0; j < n; j++)
574 const string& sname = sequence.
getName();
584 throw SequenceException(
"VectorSiteContainer::setSequence. Sequence has not the appropriate length.", &sequence);
589 throw SequenceException(
"VectorSiteContainer::setSequence. Name already exists in another sequence in container.", &sequence);
646 const string& sname = sequence.
getName();
649 throw SequenceException(
"VectorSiteContainer::addSequence. Name already exists in container.", &sequence);
673 const string& sname = sequence.
getName();
676 throw SequenceException(
"VectorSiteContainer::addSequence. Name already exists in container.", &sequence);
701 for (
size_t i = 0; i < n; i++)
virtual int getPosition() const
Get the position of this site.
virtual void setPosition(int position)
Set the position of this site.
Partial implementation of the OrderedSequenceContainer interface.
AbstractSequenceContainer & operator=(const AbstractSequenceContainer &sc)
void setGeneralComments(const Comments &comments)
Set the comments of this container.
const Alphabet * getAlphabet() const
Get container's alphabet.
const Comments & getGeneralComments() const
Get the comments of this container.
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 void setElement(size_t pos, const std::string &c)
A basic implementation of the Sequence 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 void deleteElement(size_t pos)=0
Remove the element at position 'pos'.
virtual const Alphabet * getAlphabet() const =0
Get the alphabet associated to the list.
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(const std::string &name) const=0
Retrieve a sequence object from the container.
virtual const Sequence & getSequence(size_t sequenceIndex) const =0
Retrieve a sequence object from the container.
virtual std::shared_ptr< Sequence > removeSequence(const std::string &name)=0
Extract (and remove) a sequence from the container.
virtual const Comments & getComments(size_t sequenceIndex) const=0
virtual void setSequence(const std::string &name, const Sequence &sequence, bool checkName)=0
Replace a sequence in the container.
virtual const std::string & getName(size_t sequenceIndex) const =0
Get the name of a particular row of the alignement (aka sequence).
The SequenceContainer interface.
virtual const Sequence & getSequence(const std::string &name) const =0
Retrieve a sequence object from the container.
The sequence exception base class.
Exception thrown when a sequence is not align with others.
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.
The SiteContainer interface.
virtual const Site & getSite(size_t siteIndex) const =0
Get a site from the container.
The site exception base class.
virtual void addElement(const std::string &c)
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
std::shared_ptr< T > removeObject(size_t objectIndex)
Extract and remove a object from the container.
void insertObject(std::shared_ptr< T > object, size_t objectIndex, const std::string &name)
VectorMappedContainer< T > & operator=(const VectorMappedContainer &vsc)
The template VectorPositionedContainer class.
void appendObject(std::shared_ptr< T > object)
void nullify()
Nullify all elements.
void addObject(std::shared_ptr< T > object, size_t objectIndex, bool checkPosition=false)
Add an object.
void insertObject(std::shared_ptr< T > object, size_t objectIndex)
Insert an object.
void clear()
Destroys the vector.
The VectorSiteContainer class.
void reindexSites()
Set all positions attributes.
void addSite(const Site &site, bool checkPosition=true)
Add a site in the container.
void addSequence(const Sequence &sequence, bool checkName=true)
Add a sequence to the container.
virtual void setComments(size_t sequenceIndex, const Comments &comments)=0
void setSite(size_t siteIndex, const Site &site, bool checkPosition=true)
Set a site in the container.
VectorSiteContainer & operator=(const VectorSiteContainer &vsc)
const Site & getSite(size_t siteIndex) const
Get a site from the container.
size_t getNumberOfSites() const
Get the number of aligned positions in the container.
Vint getSitePositions() const
Get all position attributes of sites.
VectorSiteContainer * createEmptyContainer() const
Return a copy of this container, but with no data inside.
VectorSiteContainer(const std::vector< const CruxSymbolListSite * > &vs, const Alphabet *alpha, bool checkPositions=true)
Build a new container from a set of sites.
void clear()
Delete all objects in the container.
size_t getSequencePosition(const std::string &name) const
Get the position of a sequence in sequence container from its name.
size_t getNumberOfSequences() const
Get the number of sequences in the container.
void setSitePositions(Vint vPositions)
Set all position attributes of sites.
std::string toString(T t)
This alphabet is used to deal NumericAlphabet.
std::vector< std::string > Comments
Declaration of Comments type.