5 #ifndef BPP_PHYL_PATTERNTOOLS_H
6 #define BPP_PHYL_PATTERNTOOLS_H
43 template<
class N,
class E,
class I>
46 const std::shared_ptr<N> node,
54 catch (std::bad_cast& e) {}
61 catch (std::bad_cast& e) {}
63 throw Exception(
"PatternTools::getSequenceSubset : unsupported sequence type.");
75 template<
class N,
class E,
class I>
78 const std::shared_ptr<N> node,
83 auto sequenceSubset = std::make_unique<VectorSiteContainer>(alphabet);
94 auto newSeq = std::make_unique<Sequence>(sequenceSet.
sequence(i->getName()));
95 sequenceSubset->addSequence(i->getName(), newSeq);
97 catch (std::exception& e)
99 ApplicationTools::displayWarning(
"PatternTools::getSequenceSubset : Leaf name not found in sequence file: " + i->getName() +
" : Replaced with unknown sequence");
101 auto seq = std::make_unique<Sequence>(i->getName(),
"", alphabet);
102 seq->setToSizeR(nbSites);
104 sequenceSubset->addSequence(i->getName(), seq);
109 return sequenceSubset;
121 template<
class N,
class E,
class I>
124 const std::shared_ptr<N> node,
129 auto sequenceSubset = std::make_unique<ProbabilisticVectorSiteContainer>(alphabet);
133 for (
auto i : leaves)
140 auto newSeq = std::make_unique<ProbabilisticSequence>(sequenceSet.
sequence(i->getName()));
141 sequenceSubset->addSequence(newSeq->getName(), newSeq);
143 catch (std::exception
const& e)
145 ApplicationTools::displayWarning(
"PatternTools::getSequenceSubset : Leaf name not found in sequence file: " + i->getName() +
" : Replaced with unknown sequence");
147 auto newSeq = std::make_unique<ProbabilisticSequence>(i->getName(),
Table<double>(alphabet->getSize(), 0), alphabet);
148 newSeq->setToSizeR(nbSites);
150 sequenceSubset->addSequence(i->getName(), newSeq);
155 return sequenceSubset;
204 const std::vector<std::string>& names);
216 const std::vector<std::string>& names);
228 const std::vector<std::string>& names);
237 static std::unique_ptr<AlignmentDataInterface>
shrinkSiteSet(
247 static std::unique_ptr<SiteContainerInterface>
shrinkSiteSet(
257 static std::unique_ptr<ProbabilisticSiteContainerInterface>
shrinkSiteSet(
std::vector< std::shared_ptr< N > > getLeavesUnderNode(std::shared_ptr< N > node) const
The phylogenetic node class.
virtual Vint getSiteCoordinates() const=0
virtual const CoreSequenceInterface & sequence(const std::string &sequenceKey) const =0
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
virtual size_t getNumberOfSites() const override=0
Defines the basic types of data flow nodes.