45 #include <Bpp/Seq/Container/VectorSiteContainer.h> 46 #include <Bpp/Seq/SiteTools.h> 61 VectorSiteContainer * sequenceSubset =
new VectorSiteContainer(sequenceSet.getAlphabet());
63 for (vector<const Node *>::iterator i = leaves.begin(); i < leaves.end(); i++)
65 const Sequence* newSeq = &sequenceSet.getSequence((* i)->getName());
66 if (newSeq == NULL)
throw SequenceNotFoundException(
"PatternToolsERROR: leaf name not found in sequence file: ", (* i) -> getName());
67 sequenceSubset -> addSequence(* newSeq);
69 return sequenceSubset;
76 VectorSiteContainer* sequenceSubset =
new VectorSiteContainer(sequenceSet.getAlphabet());
77 for (
unsigned int i = 0; i < names.size(); i++)
79 const Sequence* newSeq = &sequenceSet.getSequence(names[i]);
80 if (!newSeq)
throw SequenceNotFoundException(
"PatternTools ERROR: name not found in sequence file: ", names[i]);
81 sequenceSubset->addSequence(*newSeq);
83 return sequenceSubset;
90 if (siteSet.getNumberOfSites() == 0)
throw Exception(
"PatternTools::shrinkSiteSet siteSet is void.");
91 vector<const Site *> sites;
92 for (
unsigned int i = 0; i < siteSet.getNumberOfSites(); i++)
94 const Site* currentSite = &siteSet.getSite(i);
95 bool siteExists =
false;
96 for (
unsigned int j = 0; !siteExists && j < sites.size(); j++)
98 if (SiteTools::areSitesIdentical(* currentSite, * sites[j])) siteExists =
true;
100 if (!siteExists) sites.push_back(currentSite);
102 SiteContainer* result =
new VectorSiteContainer(sites, siteSet.getAlphabet(),
false);
103 result->setSequencesNames(siteSet.getSequencesNames(),
false);
111 size_t nbSites = sequences1.getNumberOfSites();
112 Vint indexes(nbSites);
113 for (
size_t i = 0; i < nbSites; i++) {
116 const Site* site = &sequences1.getSite(i);
117 for (
size_t j = 0; j < sequences2.getNumberOfSites(); j++)
119 if (SiteTools::areSitesIdentical(*site, sequences2.getSite(j)))
121 indexes[i] =
static_cast<int>(j);
The phylogenetic node class.