12 #include "../Alphabet/AlphabetTools.h"
13 #include "../Container/SiteContainerTools.h"
20 shared_ptr<Alphabet> BppSequenceApplication::getAlphabet(
22 bool suffixIsOptional,
23 bool allowGeneric)
const
25 return SequenceApplicationTools::getAlphabet(params_, suffix, suffixIsOptional, verbose_, allowGeneric, warn_);
28 shared_ptr<GeneticCode> BppSequenceApplication::getGeneticCode(
29 shared_ptr<const Alphabet>& alphabet,
31 bool suffixIsOptional)
const
33 shared_ptr<const CodonAlphabet> codonAlphabet = dynamic_pointer_cast<const CodonAlphabet>(alphabet);
37 auto allAlp = dynamic_pointer_cast<const AllelicAlphabet>(alphabet);
39 codonAlphabet = dynamic_pointer_cast<const CodonAlphabet>(allAlp->getStateAlphabet());
44 string codeDesc = ApplicationTools::getStringParameter(
"genetic_code", params_,
"Standard", suffix, suffixIsOptional, warn_);
46 ApplicationTools::displayResult(
"Genetic Code", codeDesc);
47 auto alphaPtr = codonAlphabet->getNucleicAlphabet();
48 return SequenceApplicationTools::getGeneticCode(alphaPtr, codeDesc);
54 map<size_t, unique_ptr<AlignmentDataInterface>>
55 BppSequenceApplication::getAlignmentsMap(
56 shared_ptr<const Alphabet>& alphabet,
57 bool changeGapsToUnknownCharacters,
59 const std::string& prefix,
60 const std::string& suffix,
61 bool suffixIsOptional)
const
65 auto mSites = SequenceApplicationTools::getProbabilisticSiteContainers(alphabet, params_, prefix, suffix, suffixIsOptional, verbose_, warn_);
67 if (!optionalData && mSites.size() == 0)
68 throw Exception(
"Missing data input.sequence.file option");
70 if (changeGapsToUnknownCharacters)
72 for (
auto& sites : mSites)
74 SiteContainerTools::changeGapsToUnknownCharacters(*sites.second);
78 for (
auto& sites : mSites)
80 if (sites.second->getNumberOfSites() == 0)
81 throw Exception(
"Empty alignment number " + TextTools::toString(sites.first));
84 map<size_t, unique_ptr<AlignmentDataInterface>> mSites2;
85 for (
auto& sites : mSites)
87 mSites2.emplace(sites.first, unique_ptr<AlignmentDataInterface>(sites.second.release()));
94 auto mSites = SequenceApplicationTools::getSiteContainers(alphabet, params_, prefix, suffix, suffixIsOptional, verbose_, warn_);
96 if (!optionalData && mSites.size() == 0)
97 throw Exception(
"Missing data input.sequence.file option");
99 if (changeGapsToUnknownCharacters)
101 for (
auto& itc : mSites)
103 SiteContainerTools::changeGapsToUnknownCharacters(*itc.second);
107 for (
auto& sites:mSites)
109 if (sites.second->getNumberOfSites() == 0)
110 throw Exception(
"Empty alignment number " + TextTools::toString(sites.first));
113 map<size_t, unique_ptr<AlignmentDataInterface>> mSites2;
114 for (
auto& sites : mSites)
116 mSites2.emplace(sites.first, unique_ptr<AlignmentDataInterface>(sites.second.release()));
123 map<size_t, unique_ptr<const AlignmentDataInterface>>
124 BppSequenceApplication::getConstAlignmentsMap(
125 shared_ptr<const Alphabet>& alphabet,
126 bool changeGapsToUnknownCharacters,
128 const std::string& prefix,
129 const std::string& suffix,
130 bool suffixIsOptional)
const
132 auto mSites = getAlignmentsMap(alphabet, changeGapsToUnknownCharacters, optionalData, prefix, suffix, suffixIsOptional);
134 map<size_t, unique_ptr<const AlignmentDataInterface>> mSitesConst;
135 for (
auto& sites : mSites)
137 mSitesConst[sites.first] = std::move(sites.second);
This alphabet is used to deal NumericAlphabet.