~ubuntu-branches/ubuntu/raring/libbpp-phyl/raring

« back to all changes in this revision

Viewing changes to src/Bpp/Phyl/BipartitionTools.h

  • Committer: Bazaar Package Importer
  • Author(s): Julien Dutheil
  • Date: 2011-06-09 11:00:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110609110000-yvx78svv6w7xxgph
Tags: upstream-2.0.2
Import upstream version 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// File: BipartitionTools.h
 
3
// Created by: Nicolas Galtier & Julien Dutheil
 
4
// Created on: Tue Apr 13 15:09 2007
 
5
//
 
6
 
 
7
/*
 
8
Copyright or © or Copr. CNRS, (November 16, 2004)
 
9
 
 
10
This software is a computer program whose purpose is to provide classes
 
11
for phylogenetic data analysis.
 
12
 
 
13
This software is governed by the CeCILL  license under French law and
 
14
abiding by the rules of distribution of free software.  You can  use,
 
15
modify and/ or redistribute the software under the terms of the CeCILL
 
16
license as circulated by CEA, CNRS and INRIA at the following URL
 
17
"http://www.cecill.info".
 
18
 
 
19
As a counterpart to the access to the source code and  rights to copy,
 
20
modify and redistribute granted by the license, users are provided only
 
21
with a limited warranty  and the software's author,  the holder of the
 
22
economic rights,  and the successive licensors  have only  limited
 
23
liability.
 
24
 
 
25
In this respect, the user's attention is drawn to the risks associated
 
26
with loading,  using,  modifying and/or developing or reproducing the
 
27
software by the user in light of its specific status of free software,
 
28
that may mean  that it is complicated to manipulate,  and  that  also
 
29
therefore means  that it is reserved for developers  and  experienced
 
30
professionals having in-depth computer knowledge. Users are therefore
 
31
encouraged to load and test the software's suitability as regards their
 
32
requirements in conditions enabling the security of their systems and/or
 
33
data to be ensured and,  more generally, to use and operate it in the
 
34
same conditions as regards security.
 
35
 
 
36
The fact that you are presently reading this means that you have had
 
37
knowledge of the CeCILL license and that you accept its terms.
 
38
*/
 
39
 
 
40
#ifndef _BIPARTITIONTOOLS_H_
 
41
#define _BIPARTITIONTOOLS_H_
 
42
 
 
43
#include "BipartitionList.h"
 
44
 
 
45
// From SeqLib:
 
46
#include <Bpp/Seq/Container/VectorSiteContainer.h>
 
47
 
 
48
namespace bpp
 
49
{
 
50
 
 
51
/**
 
52
 * @brief This class provides tools related to the BipartitionList class
 
53
 *
 
54
 * BipartitionTools includes functions dealing with dynamic arrays of bits
 
55
 * and tools for dealing with bipartitions from distinct lists.
 
56
 *
 
57
 * @see Tree
 
58
 * @see BipartitionList
 
59
 * @see TreeTools
 
60
 */
 
61
class BipartitionTools
 
62
{
 
63
  public:
 
64
 
 
65
    /**
 
66
     * @brief
 
67
     *
 
68
     * Unit length (in bits) of arrays of bits. Must be a multiple of CHAR_BIT*sizeof(int).
 
69
     * Default value is 64.
 
70
     */
 
71
    static unsigned int LWORD;
 
72
 
 
73
  public:
 
74
    BipartitionTools() {}
 
75
    virtual ~BipartitionTools() {}
 
76
 
 
77
  public:
 
78
 
 
79
    /**
 
80
     * @brief Sets bit number num of bit array list to one
 
81
     *
 
82
     * Note that no control of memory allocation is made
 
83
     */
 
84
    static void bit1(int *list, int num);
 
85
 
 
86
    /**
 
87
     * @brief Sets bit number num of bit array plist to zero
 
88
     *
 
89
     * Note that no control of memory allocation is made
 
90
     */
 
91
    static void bit0(int *list, int num);
 
92
 
 
93
    /**
 
94
     * @brief bit-wise logical AND between two arrays of bits
 
95
     *
 
96
     * (1 AND 1 = 1; 1 AND 0 = 0 AND 1 = 0 AND 0 = 0)
 
97
     *
 
98
     * Note that no control of memory allocation is made
 
99
     *
 
100
     * param list1 first array of bit
 
101
     * param list2 second array of bit
 
102
     * param listet resulting array of bit
 
103
     * param len number of int over which the operation is performed
 
104
     */
 
105
    static void bitAnd(int *listet, int *list1, int *list2, unsigned int len);
 
106
 
 
107
    /**
 
108
     * @brief bit-wise logical OR between two arrays of bits
 
109
     *
 
110
     * (1 OR 1 = 1 OR 0 = 0 OR 1 = 1; 0 OR 0 = 0)
 
111
     *
 
112
     * Note that no control of memory allocation is made
 
113
     *
 
114
     * param list1 first array of bit
 
115
     * param list2 second array of bit
 
116
     * param listou resulting array of bit
 
117
     * param len number of int over which the operation is performed
 
118
     */
 
119
    static void bitOr(int *listou, int *list1, int *list2, unsigned int len);
 
120
 
 
121
    /**
 
122
     * @brief bit-wise logical NOT
 
123
     *
 
124
     * (NOT 1 = 0; NOT 0 = 1)
 
125
     *
 
126
     * Note that no control of memory allocation is made
 
127
     *
 
128
     * param list input array of bit
 
129
     * param listnot resulting array of bit
 
130
     * param len number of int over which the operation is performed
 
131
     */
 
132
    static void bitNot(int *listnon, int *list, unsigned int len);
 
133
 
 
134
    /**
 
135
     * @brief Tells whether bit number num in bit array list is one
 
136
     */
 
137
    static bool testBit(int *list, int num);
 
138
 
 
139
    /**
 
140
     * @brief Makes one BipartitionList out of several
 
141
     *
 
142
     * The input BipartitionList objects must share the same set of elements. This will be checked or not
 
143
     * depending on checkElements
 
144
     */
 
145
    static BipartitionList* mergeBipartitionLists(const std::vector<BipartitionList*>& vecBipartL, bool checkElements = true) throw (Exception);
 
146
 
 
147
    /**
 
148
     * @brief Construct a BipartitionList containing two bipartitions taken from distinct input lists
 
149
     */
 
150
    static BipartitionList* buildBipartitionPair(const BipartitionList& bipartL1, unsigned int i1, const BipartitionList& bipartL2, unsigned int i2, bool checkElements = true) throw (Exception);
 
151
 
 
152
    /**
 
153
     * @brief Tells whether two bipartitions from distinct lists are identical
 
154
     */
 
155
    static bool areIdentical(const BipartitionList& bipart1, unsigned int i1, const BipartitionList& bipart2, unsigned int i2, bool checkElements = true);
 
156
 
 
157
    /**
 
158
     * @brief Tells whether two bipartitions from distinct lists are compatible
 
159
     */
 
160
    static bool areCompatible(const BipartitionList& bipart1, unsigned int i1, const BipartitionList& bipart2, unsigned int i2, bool checkElements = true);
 
161
 
 
162
    /**
 
163
     * @brief Create a sequence data set corresponding to the Matrix Representation of the input BipartitionList objects
 
164
     *
 
165
     * The input BipartitionList objects can have distinct sets of elements - missing data will be represented as 'N'.
 
166
     * The output alignment (DNA sequences including only A, C and N)) is ready for maximum parsimony analysis
 
167
     * according to the MRP supertree method.
 
168
     */
 
169
   static VectorSiteContainer* MRPEncode(const std::vector<BipartitionList*>& vecBipartL) throw (Exception);
 
170
 
 
171
};
 
172
 
 
173
} //end of namespace bpp.
 
174
 
 
175
#endif //_BIPARTITIONTOOLS_H_
 
176