39 plist += (num / LWORD);
40 *plist |= (1 << (num % LWORD));
48 plist += (num / LWORD);
49 *plist &= ~(1 << (num % LWORD));
56 for (
size_t i = 0; i < len; i++)
58 listet[i] = list1[i] & list2[i];
66 for (
size_t i = 0; i < len; i++)
68 listou[i] = list1[i] | list2[i];
76 for (
size_t i = 0; i < len; i++)
78 listnon[i] = ~list[i];
86 plist += (num / LWORD);
87 return (*plist) & (1 << (num % LWORD));
97 vector<int*> bitBipL1, bitBipL2, twoBitBipL;
98 vector<string> elements;
101 throw Exception(
"Bipartition index exceeds BipartitionList size");
103 throw Exception(
"Bipartition index exceeds BipartitionList size");
106 throw Exception(
"Distinct bipartition element sets");
137 twoBitBipL.push_back(bitBipL1[i1]);
138 twoBitBipL.push_back(bitBipL2[i2]);
139 return make_unique<BipartitionList>(elements, twoBitBipL);
149 auto twoBipL = buildBipartitionPair(bipartL1, i1, bipartL2, i2, checkElements);
150 return twoBipL->areIdentical(0, 1);
160 auto twoBipL = buildBipartitionPair(bipartL1, i1, bipartL2, i2, checkElements);
161 return twoBipL->areCompatible(0, 1);
167 const vector<unique_ptr<BipartitionList>>& vecBipartL,
170 vector<string> elements;
171 vector<int*> mergedBitBipL;
173 unique_ptr<BipartitionList> mergedBipL;
175 if (vecBipartL.size() == 0)
180 for (
size_t i = 1; i < vecBipartL.size(); ++i)
183 throw Exception(
"BipartitionTools::mergeBipartitionLists. Distinct bipartition element sets");
188 size_t nbword = (vecBipartL[0]->getElementNames().size() + lword - 1) / lword;
189 size_t nbint = nbword * lword / (CHAR_BIT *
sizeof(int));
191 elements = vecBipartL[0]->getElementNames();
192 if (!vecBipartL[0]->isSorted())
193 std::sort(elements.begin(), elements.end());
195 for (
size_t i = 0; i < vecBipartL.size(); i++)
197 vector<int*> bitBipL;
198 if (vecBipartL[i]->isSorted())
200 bitBipL = vecBipartL[i]->getBitBipartitionList();
206 BipartitionList provBipartL(vecBipartL[i]->getElementNames(), vecBipartL[i]->getBitBipartitionList());
210 for (
size_t j = 0; j < bitBipL.size(); j++)
212 provBitBip =
new int[nbint];
213 for (
size_t k = 0; k < nbint; k++)
215 provBitBip[k] = bitBipL[j][k];
217 mergedBitBipL.push_back(provBitBip);
221 mergedBipL = make_unique<BipartitionList>(elements, mergedBitBipL);
228 const vector<unique_ptr<BipartitionList>>& vecBipartL)
230 vector<string> all_elements;
231 map<string, bool> bip;
232 vector<string> bip_elements;
234 vector<string> sequences;
236 if (vecBipartL.size() == 0)
239 vector< vector<string>> vecElementLists;
240 for (
auto& vi : vecBipartL)
242 vecElementLists.push_back(vi->getElementNames());
247 sequences.resize(all_elements.size());
249 for (
auto& vi : vecBipartL)
251 for (
size_t j = 0; j < vi->getNumberOfBipartitions(); j++)
253 bip = vi->getBipartition(j);
256 for (
size_t k = 0; k < all_elements.size(); k++)
260 if (bip[all_elements[k]])
261 sequences[k].push_back(
'C');
263 sequences[k].push_back(
'A');
266 sequences[k].push_back(
'N');
271 vector<unique_ptr<Sequence>> vec_sequences;
272 for (
size_t i = 0; i < all_elements.size(); i++)
274 vec_sequences.push_back(make_unique<Sequence>(all_elements[i], sequences[i], alpha));
279 auto vec_site_cont = make_unique<VectorSiteContainer>(vec_seq_cont);
281 return vec_site_cont;
287 const vector<unique_ptr<BipartitionList>>& vecBipartL)
289 vector<string> all_elements;
290 map<string, bool> bip;
291 vector<string> bip_elements;
293 vector<string> sequences;
295 if (vecBipartL.size() == 0)
298 vector< vector<string>> vecElementLists;
299 for (
auto& vi : vecBipartL)
301 vecElementLists.push_back(vi->getElementNames());
306 sequences.resize(all_elements.size());
308 for (
auto& vi : vecBipartL)
310 for (
size_t j = 0; j < vi->getNumberOfBipartitions(); j++)
312 bip = vi->getBipartition(j);
315 vector< string > zeroes;
316 vector< string > ones;
317 for (
auto&
element : all_elements)
328 if (inter.size() != 0)
330 for (
auto& sk : sequences)
337 for (
size_t k = 0; k < all_elements.size(); k++)
341 if (bip[all_elements[k]])
342 sequences[k].push_back(
'C');
344 sequences[k].push_back(
'A');
347 sequences[k].push_back(
'N');
353 vector<unique_ptr<Sequence>> vec_sequences;
354 for (
size_t i = 0; i < all_elements.size(); i++)
356 vec_sequences.push_back(make_unique<Sequence>(all_elements[i], sequences[i], alpha));
361 return make_unique<VectorSiteContainer>(vec_seq_cont);
This class deals with the bipartitions defined by trees.
size_t getNumberOfBipartitions() const
const std::vector< std::string > & getElementNames() const
const std::vector< int * > & getBitBipartitionList() const
Defines the basic types of data flow nodes.