bpp-phyl3  3.0.0
ProbabilisticSubstitutionMapping.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
6 
7 using namespace bpp;
8 using namespace std;
9 
11 {
12  if (numberOfSites != getNumberOfSites() || (usePatterns_ && numberOfSites != numberOfDistinctSites_))
13  {
15 
16  numberOfDistinctSites_ = numberOfSites;
17  usePatterns_ = false;
18 
19  unique_ptr<mapTree::EdgeIterator> nIT = allEdgesIterator();
20 
21  for ( ; !nIT->end(); nIT->next())
22  {
23  (**nIT)->setNumberOfSites(numberOfSites);
24  }
25  }
26 }
27 
28 void ProbabilisticSubstitutionMapping::setNumberOfSitesAndTypes(size_t numberOfSites, size_t numberOfTypes)
29 {
30  if (numberOfSites != getNumberOfSites() || (usePatterns_ && numberOfSites != numberOfDistinctSites_))
31  {
32  numberOfDistinctSites_ = numberOfSites;
33  usePatterns_ = false;
34 
37 
38  unique_ptr<mapTree::EdgeIterator> nIT = allEdgesIterator();
39  for ( ; !nIT->end(); nIT->next())
40  {
41  (**nIT)->setNumberOfSitesAndTypes(numberOfDistinctSites_, numberOfTypes);
42  }
43  }
44 }
45 
46 
48 {
50 
51  unique_ptr<mapTree::EdgeIterator> nIT = allEdgesIterator();
52  for ( ; !nIT->end(); nIT->next())
53  {
54  (**nIT)->setNumberOfTypes(numberOfTypes);
55  }
56 }
57 
58 
60 {
61  unique_ptr<mapTree::EdgeIterator> nIT = allEdgesIterator();
62  size_t nT = (**nIT)->getNumberOfTypes();
63  VectorTools::resize2(counts, getNumberOfBranches(), nT);
64 
65  auto count_i = counts.begin();
66  for ( ; !nIT->end(); nIT->next())
67  {
68  for (size_t t = 0; t < nT; t++)
69  {
70  (*count_i)[t] = (***nIT)(siteIndex, t);
71  }
72  count_i++;
73  }
74 }
virtual void setNumberOfSites(size_t numberOfSites)
Definition: Mapping.h:113
virtual void setNumberOfSubstitutionTypes(size_t numberOfTypes)
void setNumberOfSites(size_t numberOfSites) override
void setNumberOfSitesAndTypes(size_t numberOfSites, size_t numberOfTypes)
void setNumberOfSubstitutionTypes(size_t numberOfTypes) override
void fillMappingVectorForSite(size_t siteIndex, VVdouble &counts) const
Fill a VVdouble with the counts at a given site. The 1st coordinate of this VVdouble correspond to ed...
static void resize2(VVdouble &vv, size_t n1, size_t n2)
Defines the basic types of data flow nodes.
std::vector< Vdouble > VVdouble