5 #ifndef BPP_SEQ_APP_SEQUENCEAPPLICATIONTOOLS_H
6 #define BPP_SEQ_APP_SEQUENCEAPPLICATIONTOOLS_H
12 #include "../Alphabet/Alphabet.h"
13 #include "../AlphabetIndex/AlphabetIndex1.h"
14 #include "../AlphabetIndex/AlphabetIndex2.h"
15 #include "../GeneticCode/GeneticCode.h"
16 #include "../Container/SequenceContainer.h"
17 #include "../Container/VectorSiteContainer.h"
18 #include "../Container/SiteContainerTools.h"
19 #include "../SiteTools.h"
69 const std::map<std::string, std::string>& params,
70 const std::string& suffix =
"",
71 bool suffixIsOptional =
true,
73 bool allowGeneric =
false,
91 std::shared_ptr<const NucleicAlphabet> alphabet,
92 const std::string& description);
105 std::shared_ptr<const Alphabet> alphabet,
106 const std::string& description,
107 const std::string& message =
"Alphabet measure:",
108 bool verbose =
true);
111 std::shared_ptr<const CodonAlphabet> alphabet,
112 std::shared_ptr<const GeneticCode> gencode,
113 const std::string& description,
114 const std::string& message =
"Alphabet measure:",
115 bool verbose =
true);
130 std::shared_ptr<const Alphabet> alphabet,
131 const std::string& description,
132 const std::string& message =
"Alphabet distance:",
133 bool verbose =
true);
136 std::shared_ptr<const CodonAlphabet> alphabet,
137 std::shared_ptr<const GeneticCode> gencode,
138 const std::string& description,
139 const std::string& message =
"Alphabet distance:",
140 bool verbose =
true);
161 std::shared_ptr<const Alphabet> alpha,
162 const std::map<std::string, std::string>& params,
163 const std::string& suffix =
"",
164 bool suffixIsOptional =
true,
185 std::shared_ptr<const Alphabet> alpha,
186 const std::map<std::string, std::string>& params,
187 const std::string& suffix =
"",
188 bool suffixIsOptional =
true,
209 std::shared_ptr<const Alphabet> alpha,
210 const std::map<std::string, std::string>& params,
211 const std::string& suffix =
"",
212 bool suffixIsOptional =
true,
233 static std::map<size_t, std::unique_ptr<VectorSiteContainer>>
235 std::shared_ptr<const Alphabet> alpha,
236 const std::map<std::string, std::string>& params,
237 const std::string& prefix =
"input.",
238 const std::string& suffix =
"",
239 bool suffixIsOptional =
true,
260 static std::map<size_t, std::unique_ptr<ProbabilisticVectorSiteContainer>>
262 std::shared_ptr<const Alphabet> alpha,
263 const std::map<std::string, std::string>& params,
264 const std::string& prefix =
"input.",
265 const std::string& suffix =
"",
266 bool suffixIsOptional =
true,
289 const std::map<std::string, std::string>& params,
290 std::string suffix =
"",
291 bool suffixIsOptional =
true,
324 template<
class SiteType,
class SequenceType>
325 static std::unique_ptr< TemplateVectorSiteContainer<SiteType, SequenceType>>
328 const std::map<std::string, std::string>& params,
329 std::string suffix =
"",
330 bool suffixIsOptional =
true,
331 bool gapAsUnknown =
true,
336 std::unique_ptr< TemplateVectorSiteContainer<SiteType, SequenceType>> sitesToAnalyse;
346 sitesToAnalyse = std::make_unique< TemplateVectorSiteContainer<SiteType, SequenceType>>(allSites);
347 size_t nbSites = sitesToAnalyse->getNumberOfSites();
353 if (maxGapOption[maxGapOption.size() - 1] ==
'%')
355 double gapFreq =
TextTools::toDouble(maxGapOption.substr(0, maxGapOption.size() - 1)) / 100;
356 gapCount = gapFreq * (int)numSeq;
365 for (
size_t i = nbSites; i > 0; i--)
371 sitesToAnalyse->deleteSites(i - 1, 1);
379 double unresCount = 0;
381 if (maxUnresolvedOption[maxUnresolvedOption.size() - 1] ==
'%')
383 double unresFreq =
TextTools::toDouble(maxUnresolvedOption.substr(0, maxUnresolvedOption.size() - 1)) / 100;
384 unresCount = unresFreq * (int)numSeq;
389 nbSites = sitesToAnalyse->getNumberOfSites();
395 for (
size_t i = nbSites; i > 0; i--)
401 sitesToAnalyse->deleteSites(i - 1, 1);
407 else if (option ==
"complete")
410 size_t nbSites = sitesToAnalyse->getNumberOfSites();
414 else if (option ==
"nogap")
417 size_t nbSites = sitesToAnalyse->getNumberOfSites();
423 throw Exception(
"Option '" + option +
"' unknown in parameter 'sequence.sites_to_use'.");
426 auto ca = std::dynamic_pointer_cast<const CodonAlphabet>(sitesToAnalyse->getAlphabet());
430 if ((option !=
"") && verbose)
436 auto nucAlph = ca->getNucleicAlphabet();
445 return sitesToAnalyse;
466 const std::map<std::string, std::string>& params,
467 const std::string& suffix =
"",
486 const std::map<std::string, std::string>& params,
487 const std::string& suffix =
"",
The SequenceContainer interface.
virtual size_t getNumberOfSequences() const =0
Get the number of sequences in the container.
double toDouble(const std::string &s, char dec='.', char scientificNotation='e')
std::string toString(T t)
This alphabet is used to deal NumericAlphabet.