19 std::vector<std::string> names) :
24 alpha_(sequences.getAlphabet())
27 if (names.size() != 0)
34 std::vector<std::string> names)
37 std::vector<size_t> posseq;
38 for (
const auto& n : names)
44 std::vector<size_t> posnseq;
46 std::stable_sort(posseq.begin(), posseq.end());
47 for (
int i = nbSeq - 1; i >= 0; i--)
49 if (!std::binary_search(posseq.begin(), posseq.end(), i))
50 posnseq.push_back(
static_cast<size_t>(i));
56 vector<SortableSite> ss(nbSites);
57 for (
size_t i = 0; i < nbSites; i++)
60 for (
auto pos : posnseq)
67 ssi->
siteP = currentSite;
74 sort(ss.begin(), ss.end());
78 auto previousSite = ss0->
siteP;
79 indices_.resize(Eigen::Index(nbSites));
81 sites_.push_back(shared_ptr<const CoreSiteInterface>(previousSite));
84 size_t currentPos = 0;
85 for (
size_t i = 1; i < nbSites; ++i)
88 auto currentSite = ssi->
siteP;
98 sites_.push_back(shared_ptr<const CoreSiteInterface>(currentSite));
101 previousSite = currentSite;
113 throw Exception(
"SitePatterns::getSites : empty set.");
115 unique_ptr<AlignmentDataInterface> sites;
117 if (dynamic_pointer_cast<const Site>(
sites_[0]))
120 vector<unique_ptr<Site>> vSites;
123 auto ptr = unique_ptr<Site>(
dynamic_cast<Site*
>(s->clone()));
124 vSites.push_back(std::move(ptr));
127 sites->setSequenceNames(
names_,
true);
131 if (dynamic_pointer_cast<const ProbabilisticSite>(
sites_[0]))
134 vector<unique_ptr<ProbabilisticSite>> vSites;
137 vSites.push_back(unique_ptr<ProbabilisticSite>(
dynamic_cast<ProbabilisticSite*
>(s->clone())));
140 sites->setSequenceNames(
names_,
true);
144 throw Exception(
"SitePatterns::getSites(). Unsupported site type.");
CoreSiteInterface * clone() const override=0
virtual void deleteElement(size_t pos)=0
virtual std::string toString() const=0
Class used for site pattern sorting.
const CoreSiteInterface * siteP
void init_(const AlignmentDataInterface &sequences, std::vector< std::string > names={})
std::vector< std::shared_ptr< const CoreSiteInterface > > sites_
std::vector< unsigned int > weights_
std::vector< std::string > names_
std::shared_ptr< const Alphabet > alpha_
SitePatterns(const AlignmentDataInterface &sequences, std::vector< std::string > names={})
Build a new SitePattern object.
std::unique_ptr< AlignmentDataInterface > getSites() const
virtual const CoreSiteInterface & site(size_t siteIndex) const=0
virtual size_t getNumberOfSites() const=0
virtual std::vector< std::string > getSequenceNames() const =0
virtual size_t getNumberOfSequences() const =0
virtual size_t getSequencePosition(const std::string &sequenceKey) const =0
Defines the basic types of data flow nodes.
TemplateVectorSiteContainer< ProbabilisticSite, ProbabilisticSequence > ProbabilisticVectorSiteContainer
TemplateVectorSiteContainer< Site, Sequence > VectorSiteContainer