bpp-seq3  3.0.0
Site.cpp
Go to the documentation of this file.
1 //
2 // File: Site.cpp
3 // Authors:
4 // Julien Dutheil
5 // Guillaume Deuchst
6 // Created: 2003-08-07 00:00:00
7 //
8 
9 /*
10  Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
11 
12  This software is a computer program whose purpose is to provide classes
13  for sequences analysis.
14 
15  This software is governed by the CeCILL license under French law and
16  abiding by the rules of distribution of free software. You can use,
17  modify and/ or redistribute the software under the terms of the CeCILL
18  license as circulated by CEA, CNRS and INRIA at the following URL
19  "http://www.cecill.info".
20 
21  As a counterpart to the access to the source code and rights to copy,
22  modify and redistribute granted by the license, users are provided only
23  with a limited warranty and the software's author, the holder of the
24  economic rights, and the successive licensors have only limited
25  liability.
26 
27  In this respect, the user's attention is drawn to the risks associated
28  with loading, using, modifying and/or developing or reproducing the
29  software by the user in light of its specific status of free software,
30  that may mean that it is complicated to manipulate, and that also
31  therefore means that it is reserved for developers and experienced
32  professionals having in-depth computer knowledge. Users are therefore
33  encouraged to load and test the software's suitability as regards their
34  requirements in conditions enabling the security of their systems and/or
35  data to be ensured and, more generally, to use and operate it in the
36  same conditions as regards security.
37 
38  The fact that you are presently reading this means that you have had
39  knowledge of the CeCILL license and that you accept its terms.
40 */
41 
42 
43 #include "Site.h"
44 #include "StringSequenceTools.h"
45 
46 using namespace bpp;
47 
48 // From the STL:
49 #include <iostream>
50 
51 using namespace std;
52 
53 /****************************************************************************************/
54 
55 Site::Site(const Alphabet* alpha) : SymbolList<int>(alpha), AbstractCoreSite(), BasicIntSymbolList(alpha) {}
56 
57 Site::Site(const Alphabet* alpha, int position) : SymbolList<int>(alpha), AbstractCoreSite(position), BasicIntSymbolList(alpha) {}
58 
59 Site::Site(const vector<string>& site, const Alphabet* alpha) : SymbolList<int>(alpha), AbstractCoreSite(), BasicIntSymbolList(site, alpha) {}
60 
61 Site::Site(const vector<string>& site, const Alphabet* alpha, int position) : SymbolList<int>(alpha), AbstractCoreSite(position), BasicIntSymbolList(site, alpha) {}
62 
63 Site::Site(const vector<int>& site, const Alphabet* alpha) : SymbolList<int>(site, alpha), AbstractCoreSite(), BasicIntSymbolList(site, alpha) {}
64 
65 Site::Site(const vector<int>& site, const Alphabet* alpha, int position) : SymbolList<int>(alpha), AbstractCoreSite(position), BasicIntSymbolList(site, alpha) {}
66 
67 /****************************************************************************************/
68 
69 Site::Site(const Site& site) : SymbolList<int>(site.getContent(), site.getAlphabet()), AbstractCoreSite(site.getPosition()), BasicIntSymbolList(site) {}
70 
72 {
75  return *this;
76 }
77 
78 /****************************************************************************************/
79 
80 bool operator==(const Site& site1, const Site& site2)
81 {
82  // Verify that site's size, position and content are equals
83  if (site1.size() != site2.size())
84  return false;
85  if (site1.getPosition() != site2.getPosition())
86  return false;
87  else
88  {
89  for (unsigned int i = 0; i < site1.size(); i++)
90  {
91  if (site1[i] != site2[i])
92  return false;
93  }
94  return true;
95  }
96 }
97 
98 /****************************************************************************************/
99 
100 bool operator<(const Site& site1, const Site& site2)
101 {
102  return site1.getPosition() < site2.getPosition();
103 }
104 
105 /****************************************************************************************/
An implementation of the CoreSite interface.
Definition: CoreSite.h:108
virtual int getPosition() const
Get the position of this site.
Definition: CoreSite.h:183
AbstractCoreSite & operator=(const CoreSite &site)
Definition: CoreSite.h:152
The Alphabet interface.
Definition: Alphabet.h:133
A basic IntSymbolList object.
BasicIntSymbolList & operator=(const IntSymbolList &list)
The generic assignment operator.
virtual size_t size() const =0
Get the number of elements in the list.
The Site class.
Definition: Site.h:68
Site(const Alphabet *alpha)
Build a new void Site object with the specified alphabet.
Definition: Site.cpp:55
Site & operator=(const Site &s)
The assignment operator.
Definition: Site.cpp:71
A SymbolList object.
Definition: SymbolList.h:72
This alphabet is used to deal NumericAlphabet.
bool operator==(const Matrix< Scalar > &m1, const Matrix< Scalar > &m2)
bool operator<(const Site &site1, const Site &site2)