5 #ifndef BPP_SEQ_SYMBOLLISTTOOLS_H
6 #define BPP_SEQ_SYMBOLLISTTOOLS_H
42 catch (std::bad_cast&) {}
47 catch (std::bad_cast&) {}
48 throw Exception(
"SymbolListTools::hasGap : unsupported CruxSymbolListInterface implementation.");
70 catch (std::bad_cast&) {}
75 catch (std::bad_cast&) {}
76 throw Exception(
"SymbolListTools::numberOfGaps : unsupported CruxSymbolListInterface implementation.");
92 catch (std::bad_cast&) {}
97 catch (std::bad_cast&) {}
98 throw Exception(
"SymbolListTools::numberOfGaps : unsupported CruxSymbolListInterface implementation.");
114 catch (std::bad_cast&) {}
119 catch (std::bad_cast&) {}
120 throw Exception(
"SymbolListTools::isGapOrUnresolvedOnly : unsupported CruxSymbolListInterface implementation.");
136 catch (std::bad_cast&) {}
141 catch (std::bad_cast&) {}
142 throw Exception(
"SymbolListTools::numberOfUnresolved : unsupported CruxSymbolListInterface implementation.");
158 catch (std::bad_cast&) {}
163 catch (std::bad_cast&) {}
164 throw Exception(
"SymbolListTools::hasUnknown : unsupported CruxSymbolListInterface implementation.");
180 catch (std::bad_cast&) {}
185 catch (std::bad_cast&) {}
186 throw Exception(
"SymbolListTools::isComplete : unsupported CruxSymbolListInterface implementation.");
201 bool ignoreUnknown =
false,
202 bool unresolvedRaisesException =
true);
206 bool unresolvedRaisesException =
true);
210 bool ignoreUnknown =
false,
211 bool unresolvedRaisesException =
true)
217 catch (std::bad_cast&) {}
222 catch (std::bad_cast&) {}
223 throw Exception(
"SymbolListTools::isConstant : unsupported CruxSymbolListInterface implementation.");
247 catch (std::bad_cast&) {}
252 catch (std::bad_cast&) {}
253 throw Exception(
"SymbolListTools::areSymbolListsIdentical : unsupported CruxSymbolListInterface implementation.");
264 template<
class count_type>
267 std::map<int, count_type>& counts)
269 for (
size_t i = 0; i < list.
size(); ++i)
284 std::map<int, double_t>& counts)
286 for (
size_t i = 0; i < list.
size(); ++i)
288 const std::vector<double>& c = list[i];
289 for (
size_t j = 0; j < c.size(); ++j)
291 counts[(int)j] += c.at(j);
308 std::map<int, double>& counts)
310 for (
size_t i = 0; i < list.
size(); ++i)
312 std::vector<int> alias = list.
getAlphabet()->getAlias(list[i]);
313 double n =
static_cast<double>(alias.size());
333 std::map<int, double>& counts)
335 for (
size_t i = 0; i < list.
size(); ++i)
337 const std::vector<double>& c = list[i];
341 for (
size_t j = 0; j < c.size(); j++)
343 counts[(int)j] += c.at(j) / s;
362 std::map<int, double>& counts,
363 bool resolveUnknowns =
false)
378 catch (std::bad_cast&) {}
393 catch (std::bad_cast&) {}
395 throw Exception(
"SymbolListTools::getCounts : unsupported CruxSymbolListInterface implementation (" + std::string(
typeid(list).name()) +
").");
411 template<
class count_type>
415 std::map<
int, std::map<int, count_type>>& counts)
418 for (
size_t i = 0; i < list1.
size(); ++i)
420 counts[list1[i]][list2[i]]++;
440 std::map<
int, std::map<int, double>>& counts)
443 for (
size_t i = 0; i < list1.
size(); ++i)
445 const std::vector<double>& c1(list1[i]), &c2(list2[i]);
446 for (
size_t j = 0; j < c1.size(); ++j)
448 for (
size_t k = 0; k < c2.size(); ++k)
450 counts[(int)j][(
int)k] += c1.at(j) * c2.at(k);
475 std::map<
int, std::map<int, double>>& counts);
495 std::map<
int, std::map<int, double>>& counts);
517 std::map<
int, std::map<int, double>>& counts,
518 bool resolveUnknowns)
533 catch (std::bad_cast&) {}
548 catch (std::bad_cast&) {}
550 throw Exception(
"SymbolListTools::getCounts : unsupported CruxSymbolListInterface implementation (" + std::string(
typeid(list1).name()) +
", " + std::string(
typeid(list2).name()) +
").");
565 std::map<int, double>& frequencies,
566 bool resolveUnknowns =
false);
584 std::map<
int, std::map<int, double>>& frequencies,
585 bool resolveUnknowns =
false);
601 bool ignoreUnresolved =
true,
602 bool ignoreGap =
true);
606 bool ignoreUnresolved =
true,
607 bool ignoreGap =
true);
611 bool ignoreUnresolved =
true,
612 bool ignoreGap =
true)
618 catch (std::bad_cast&) {}
623 catch (std::bad_cast&) {}
624 throw Exception(
"SymbolListTools::getGCContent : unsupported CruxSymbolListInterface implementation.");
654 catch (std::bad_cast&) {}
659 catch (std::bad_cast&) {}
660 throw Exception(
"SymbolListTools::getNumberOfDistinctPositions : unsupported CruxSymbolListInterface implementation.");
690 catch (std::bad_cast&) {}
695 catch (std::bad_cast&) {}
696 throw Exception(
"SymbolListTools::getNumberOfPositionsWithoutGap : unsupported CruxSymbolListInterface implementation.");
716 catch (std::bad_cast&) {}
722 catch (std::bad_cast&) {}
723 throw Exception(
"SymbolListTools::changeGapsToUnknownCharacters : unsupported CruxSymbolListInterface implementation.");
743 catch (std::bad_cast&) {}
749 catch (std::bad_cast&) {}
750 throw Exception(
"SymbolListTools::changeUnresolvedCharactersToGaps : unsupported CruxSymbolListInterface implementation.");
768 bool resolveUnknowns);
802 bool resolveUnknowns);
839 bool resolveUnknowns);
The CruxSymbolList interface.
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
Get the alphabet associated to the list.
virtual size_t size() const =0
Get the number of elements in the list.
The specific IntSymbolList interface.
The ProbabilisticSymbolList interface.
This alphabet is used to deal NumericAlphabet.