17 const std::string& path,
18 shared_ptr<const Alphabet> alpha)
23 auto psc = make_unique<PolymorphismSequenceContainer>(*seqc);
24 Comments maseFileHeader = seqc->getComments();
26 for (
auto& mi : groupMap)
29 if (key.compare(0, 8,
"OUTGROUP") == 0)
32 for (
size_t i = 0; i != ss.size(); ++i)
34 psc->setAsOutgroupMember(ss[i]);
47 auto psci = make_unique<PolymorphismSequenceContainer>(psc);
55 throw Exception(
"PolymorphismSequenceContainerTools::extractIngroup: no Ingroup sequences found.");
57 for (
size_t i = ss.size(); i > 0; --i)
59 psci->deleteSequence(ss[i - 1]);
70 auto psci = make_unique<PolymorphismSequenceContainer>(psc);
78 throw Exception(
"PolymorphismSequenceContainerTools::extractOutgroup: no Outgroup sequences found.");
80 for (
size_t i = ss.size(); i > 0; i--)
82 psci->deleteSequence(ss[i - 1]);
94 auto psci = make_unique<PolymorphismSequenceContainer>(psc);
102 throw GroupNotFoundException(
"PolymorphismSequenceContainerTools::extractGroup: group_id not found.", groupId);
104 for (
size_t i = ss.size(); i > 0; i--)
106 psci->deleteSequence(ss[i - 1]);
117 auto newpsc = make_unique<PolymorphismSequenceContainer>(psc.
getAlphabet());
118 for (
size_t i = 0; i < ss.size(); ++i)
120 auto tmpSeq = make_unique<Sequence>(psc.
sequence(ss[i]));
121 newpsc->addSequenceWithFrequency(tmpSeq->getName(), tmpSeq, psc.
getSequenceCount(i));
123 newpsc->setAsIngroupMember(i);
126 newpsc->setAsOutgroupMember(i);
143 for (
size_t i = 0; i < nbSeq; ++i)
147 vector<size_t> vv(n);
160 noGapCont->setSequenceNames(seqNames,
false);
162 for (
size_t i = 0; i < nbSeq; ++i)
166 noGapCont->setAsIngroupMember(i);
169 noGapCont->setAsOutgroupMember(i);
176 auto tmpSite = make_unique<Site>(ngsi.
nextSite());
177 noGapCont->addSite(tmpSite);
189 unique_ptr<PolymorphismSequenceContainer> npsc =
nullptr;
190 unique_ptr<SimpleSiteContainerIterator> ssi =
nullptr;
193 npsc = extractIngroup(psc);
198 while (ssi->hasMoreSites())
211 unique_ptr<PolymorphismSequenceContainer> npsc =
nullptr;
212 unique_ptr<SimpleSiteContainerIterator> ssi =
nullptr;
215 npsc = extractIngroup(psc);
220 while (ssi->hasMoreSites())
233 complete->setSequenceNames(seqNames,
false);
235 for (
size_t i = 0; i < nbSeq; ++i)
239 complete->setAsIngroupMember(i);
242 complete->setAsOutgroupMember(i);
249 auto tmpSite = make_unique<Site>(csi.
nextSite());
250 complete->addSite(tmpSite);
260 auto psci = make_unique<PolymorphismSequenceContainer>(psc);
264 size_t n = psci->getNumberOfSites();
267 psci->deleteSite(n - i - 1);
277 const string& setName,
289 auto psci = make_unique<PolymorphismSequenceContainer>(*pscc);
293 psci->setAsIngroupMember(i);
296 psci->setAsOutgroupMember(i);
300 psci->clearComments();
308 const string& setName)
315 if (find(codss.begin(), codss.end(), i) == codss.end())
319 auto psci = make_unique<PolymorphismSequenceContainer>(*sc);
323 psci->setAsIngroupMember(i);
326 psci->setAsOutgroupMember(i);
337 const string& setName,
352 if (
static_cast<int>(pos) -
static_cast<int>(start) >= 0)
362 auto newpsc = make_unique<PolymorphismSequenceContainer>(*sc);
366 newpsc->setAsIngroupMember(j);
369 newpsc->setAsOutgroupMember(j);
380 const string& setName,
390 psc.
site(codss[0]).getValue(0) == 0 &&
391 psc.
site(codss[1]).getValue(0) == 3 &&
392 psc.
site(codss[2]).getValue(0) == 2)
395 int c1 = psc.
site(codss[codss.size() - 3]).getValue(0);
396 int c2 = psc.
site(codss[codss.size() - 2]).getValue(0);
397 int c3 = psc.
site(codss[codss.size() - 1]).getValue(0);
399 last = codss[codss.size() - 1];
401 for (
size_t i = first; i < last; i++)
403 if (find(codss.begin(), codss.end(), i) == codss.end())
409 auto psci = make_unique<PolymorphismSequenceContainer>(*sc);
413 psci->setAsIngroupMember(i);
416 psci->setAsOutgroupMember(i);
427 const string& setName)
436 psc.
site(codss[0]).getValue(0) == 0 &&
437 psc.
site(codss[1]).getValue(0) == 3 &&
438 psc.
site(codss[2]).getValue(0) == 2)
440 for (
size_t i = 0; i < last; ++i)
442 if (find(codss.begin(), codss.end(), i) == codss.end())
448 auto psci = make_unique<PolymorphismSequenceContainer>(*sc);
452 psci->setAsIngroupMember(i);
455 psci->setAsOutgroupMember(i);
466 const string& setName,
474 int c1 = psc.
site(codss[codss.size() - 3]).getValue(0);
475 int c2 = psc.
site(codss[codss.size() - 2]).getValue(0);
476 int c3 = psc.
site(codss[codss.size() - 1]).getValue(0);
478 first = codss[codss.size() - 1];
481 if (find(codss.begin(), codss.end(), i) == codss.end())
487 auto psci = make_unique<PolymorphismSequenceContainer>(*sc);
491 psci->setAsIngroupMember(i);
494 psci->setAsOutgroupMember(i);
508 if (!maseFileHeader.size())
511 for (
auto& mi : groupMap)
514 if (key.compare(0, 7,
"INGROUP") == 0)
535 auto tmpSite = make_unique<Site>(site);
536 psco->addSite(tmpSite);
543 psco->setAsIngroupMember(i);
546 psco->setAsOutgroupMember(i);
565 auto tmpSite = make_unique<Site>(site);
566 psco->addSite(tmpSite);
573 psco->setAsIngroupMember(i);
576 psco->setAsOutgroupMember(i);
void readSequences(std::istream &input, SequenceContainerInterface &sc) const override
std::shared_ptr< const Alphabet > getAlphabet() const override
int getCodon(int pos1, int pos2, int pos3) const
bool hasMoreSites() const override
const SiteType & nextSite() override
virtual const CodonAlphabet & codonAlphabet() const
virtual bool isStop(int state) const=0
The GroupNotFoundException class.
const SiteType & nextSite() override
bool hasMoreSites() const override
The PolymorphismSequenceContainer class.
size_t getGroupId(size_t index) const
Get the group identifier of the sequence.
bool isIngroupMember(size_t index) const
Tell if the sequence is ingroup by index.
unsigned int getSequenceCount(size_t index) const
Get the count of a sequence by index.
const std::string & getToken(size_t pos) const
const SequenceType & sequence(const std::string &sequenceKey) const override
const SiteType & site(size_t sitePosition) const override
size_t getNumberOfSequences() const override
size_t getNumberOfSites() const override
std::vector< std::string > getSequenceNames() const override
std::size_t count(const std::string &s, const std::string &pattern)
SimpleTemplateSiteContainerIterator< Site, Sequence, std::string > SimpleSiteContainerIterator
std::vector< size_t > SiteSelection
std::vector< size_t > SequenceSelection
std::vector< std::string > Comments