16 CompressedVectorSiteContainer::CompressedVectorSiteContainer(
17 std::vector< unique_ptr<Site>>& vs,
18 std::shared_ptr<const Alphabet>& alphabet) :
27 throw Exception(
"CompressedVectorSiteContainer::CompressedVectorSiteContainer. Empty site set.");
29 size_t nbSeq = vs[0]->size();
30 for (
size_t i = 0; i < nbSeq; ++i)
47 std::shared_ptr<const Alphabet>& alphabet) :
56 for (
size_t i = 0; i < size; ++i)
66 const std::vector<std::string>& sequenceKeys,
67 std::shared_ptr<const Alphabet>& alphabet) :
76 for (
auto key : sequenceKeys)
100 sequenceContainer_(),
101 sequenceNames_(vsc.sequenceNames_),
102 sequenceComments_(vsc.sequenceComments_),
113 auto sitePtr = std::shared_ptr<Site>(vsc.
siteContainer_.getObject(i)->clone());
123 sequenceContainer_(),
124 sequenceNames_(sc.getSequenceNames()),
125 sequenceComments_(sc.getSequenceComments()),
136 auto sitePtr = std::unique_ptr<Site>(sc.
site(i).
clone());
157 auto sitePtr = std::shared_ptr<Site>(vsc.
siteContainer_.getObject(i)->clone());
177 auto sitePtr = std::unique_ptr<Site>(sc.
site(i).
clone());
196 throw SiteException(
"AlignedSequenceContainer::setSite. Site does not have the appropriate length",
site.get());
202 size_t current =
index_[sitePosition];
204 if (siteIndex == current)
211 index_[sitePosition] = siteIndex;
215 for (
size_t i = 0; test && i <
index_.size(); ++i)
228 for (
size_t i = 0; i <
index_.size(); ++i)
241 for (
size_t i = 0; test && i <
index_.size(); ++i)
243 if (i != sitePosition &&
index_[i] == current)
258 index_[sitePosition] = siteIndex;
275 std::get_deleter< SwitchDeleter<Site>>(sitePtr)->off();
277 size_t current =
index_[siteIndex];
279 for (
size_t j = 0; test && j <
index_.size(); ++j)
281 if (j != siteIndex &&
index_[j] == current)
293 for (
size_t j = 0; j <
index_.size(); ++j)
299 index_.erase(
index_.begin() +
static_cast<ptrdiff_t
>(siteIndex));
304 return std::unique_ptr<Site>(sitePtr.get());
323 for (
size_t i = 0; i < length; ++i)
335 throw SiteException(
"CompressedVectorSiteContainer::addSite. Site does not have the appropriate length",
site.get());
353 index_.push_back(siteIndex);
360 for (
size_t i = 0; i < n; ++i)
381 throw SiteException(
"CompressedVectorSiteContainer::addSite. Site does not have the appropriate length",
site.get());
399 index_.insert(
index_.begin() +
static_cast<ptrdiff_t
>(siteIndex), index);
406 for (
size_t i = 0; i < n; ++i)
435 for (
size_t i = 0; i < vCoordinates.size(); ++i)
447 for (
size_t i = 0; i < n; i++)
469 for (
size_t j = 0; j < n; ++j)
475 auto ns = std::make_shared<Sequence>(
497 for (
size_t j = 0; test && j <
site.
size(); ++j)
499 if (
site[j] != siteI[j])
void setCoordinate(int coordinate) override
Set the position of this site.
Partial implementation of the SequenceContainer interface.
AbstractTemplateSequenceContainer & operator=(const AbstractTemplateSequenceContainer< SequenceType, HashType > &sc)
std::shared_ptr< const Alphabet > getAlphabet() const override
std::shared_ptr< const Alphabet > getAlphabet() const override
Get the alphabet associated to the list.
size_t size() const override
Get the number of elements in the list.
Exception thrown when two alphabets do not match.
A low memory, yet restricted, version of the VectorSiteContainer class.
std::vector< size_t > index_
size_t getNumberOfSites() const override
Get the number of aligned positions in the container.
std::vector< std::string > sequenceNames_
std::unique_ptr< Site > removeSite(size_t sitePosition) override
Remove a site from the container.
size_t getNumberOfUniqueSites() const
size_t getNumberOfSequences() const override
Get the number of sequences in the container.
const std::string & sequenceKey(size_t sequencePosition) const override
Get the key associated to a given sequence.
const Site & site(size_t sitePosition) const override
Get a site from the container.
size_t getSiteIndex_(const Site &site)
void setSiteCoordinates(const Vint &coordinates) override
Set all coordinates of sites.
void reindexSites() override
Set all coordinate attributes.
VectorMappedContainer< Sequence > sequenceContainer_
const Sequence & sequence(size_t sequenceIndex) const override
Retrieve a sequence object from the container.
CompressedVectorSiteContainer(std::vector< std::unique_ptr< Site >> &vs, std::shared_ptr< const Alphabet > &alphabet)
Build a new container from a set of sites.
Site & getSite_(size_t sitePosition)
Vint getSiteCoordinates() const override
Get all coordinates of sites.
std::vector< Comments > sequenceComments_
void clear() override
Delete all data in the container.
VectorPositionedContainer< Site > siteContainer_
std::vector< std::string > getSequenceNames() const override
CompressedVectorSiteContainer & operator=(const CompressedVectorSiteContainer &vsc)
void addSite(std::unique_ptr< Site > &site, bool checkCoordinate=false) override
Add a site in the container.
void deleteSites(size_t sitePosition, size_t length) override
Remove a continuous range of sites in the container.
void deleteSite(size_t sitePosition) override
Delete a site from the container.
void setSite(size_t sitePosition, std::unique_ptr< Site > &site, bool checkCoordinate=true) override
Set a site in the container.
A basic implementation of the Sequence interface.
The site exception base class.
virtual std::vector< Comments > getSequenceComments() const =0
virtual std::vector< std::string > getSequenceNames() const =0
virtual const SiteType & site(size_t sitePosition) const override=0
Get a site from the container.
virtual size_t getNumberOfSites() const override=0
Get the number of aligned positions in the container.
std::string toString(T t)
This alphabet is used to deal NumericAlphabet.