bpp-seq3  3.0.0
ProbabilisticSequence.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #include "ProbabilisticSequence.h" // class's header file
6 
7 using namespace bpp;
8 
9 // From the STL:
10 #include <iostream>
11 
12 using namespace std;
13 
14 /******************************************************************************/
15 
17 {
18  // Size verification
19  size_t seqSize = size();
20  if (newSize == seqSize)
21  return;
22 
23  if (newSize < seqSize)
24  {
25  deleteElements(newSize, seqSize - newSize);
26  return;
27  }
28 
29  // Add gaps up to specified size
30  auto gap = std::vector<double>(alphabet().getSize(), 0);
31 
32  for (size_t i = 0; i < (size_t)(newSize - seqSize); i++)
33  {
34  addElement(gap);
35  }
36 }
37 
38 /******************************************************************************/
39 
41 {
42  // Size verification
43  size_t seqSize = size();
44  if (newSize == seqSize)
45  return;
46 
47  if (newSize < seqSize)
48  {
49  deleteElements(0, seqSize - newSize);
50  return;
51  }
52 
53  // Add gaps up to specified size
54  auto gap = std::vector<double>(alphabet().getSize(), 0);
55 
56  for (size_t i = 0; i < (size_t)(newSize - seqSize); i++)
57  {
58  addElement(0, gap);
59  }
60 }
void setToSizeL(size_t newSize) override
Set up the size of a sequence from the left side.
void setToSizeR(size_t newSize) override
Set up the size of a sequence from the right side.
This alphabet is used to deal NumericAlphabet.