bpp-seq3  3.0.0
VectorSiteContainer.cpp
Go to the documentation of this file.
1 //
2 // File: VectorSiteContainer.cpp
3 // Authors:
4 // Julien Dutheil
5 // Created: 2003-10-06 11:50:40
6 //
7 
8 /*
9  Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
10 
11  This software is a computer program whose purpose is to provide classes
12  for sequences analysis.
13 
14  This software is governed by the CeCILL license under French law and
15  abiding by the rules of distribution of free software. You can use,
16  modify and/ or redistribute the software under the terms of the CeCILL
17  license as circulated by CEA, CNRS and INRIA at the following URL
18  "http://www.cecill.info".
19 
20  As a counterpart to the access to the source code and rights to copy,
21  modify and redistribute granted by the license, users are provided only
22  with a limited warranty and the software's author, the holder of the
23  economic rights, and the successive licensors have only limited
24  liability.
25 
26  In this respect, the user's attention is drawn to the risks associated
27  with loading, using, modifying and/or developing or reproducing the
28  software by the user in light of its specific status of free software,
29  that may mean that it is complicated to manipulate, and that also
30  therefore means that it is reserved for developers and experienced
31  professionals having in-depth computer knowledge. Users are therefore
32  encouraged to load and test the software's suitability as regards their
33  requirements in conditions enabling the security of their systems and/or
34  data to be ensured and, more generally, to use and operate it in the
35  same conditions as regards security.
36 
37  The fact that you are presently reading this means that you have had
38  knowledge of the CeCILL license and that you accept its terms.
39 */
40 
41 #include <iostream>
42 
43 #include "VectorSiteContainer.h"
44 
45 using namespace std;
46 
47 #include <Bpp/Text/TextTools.h>
48 
49 using namespace bpp;
50 
53 VectorSiteContainer::VectorSiteContainer(
54  const std::vector<const CruxSymbolListSite*>& vs,
55  const Alphabet* alpha,
56  bool checkPositions) :
60 {
61  if (vs.size() == 0)
62  throw Exception("VectorSiteContainer::VectorSiteContainer. Empty site set.");
63 
64  size_t nbSeq = vs[0]->size();
65 
66  // Seq names and comments:
67 
68  for (size_t i = 0; i < nbSeq; i++)
70 
71  // Now try to add each site:
72  for (size_t i = 0; i < vs.size(); i++)
73  {
74  if (!dynamic_cast<const Site*>(vs[i]))
75  throw Exception("VectorSiteContainer::VectorSiteContainer : Not a Site in position " + TextTools::toString(i));
76 
77  addSite(dynamic_cast<const Site&>(*vs[i]), checkPositions); // This may throw an exception if position argument already exists or its size is not valid.
78  }
79 }
80 
82  const std::vector<const Site*>& vs,
83  const Alphabet* alpha,
84  bool checkPositions) :
88 {
89  if (vs.size() == 0)
90  throw Exception("VectorSiteContainer::VectorSiteContainer. Empty site set.");
91 
92  size_t nbSeq = vs[0]->size();
93 
94  // Seq names and comments:
95 
96  for (size_t i = 0; i < nbSeq; i++)
98 
99  // Now try to add each site:
100  for (size_t i = 0; i < vs.size(); i++)
101  {
102  addSite(*vs[i], checkPositions); // This may throw an exception if position argument already exists or is size is not valid.
103  }
104 }
105 
106 /******************************************************************************/
107 
112 {
113  // Seq names and comments:
114  for (size_t i = 0; i < size; i++)
116 
117 }
118 
119 /******************************************************************************/
120 
121 VectorSiteContainer::VectorSiteContainer(const std::vector<std::string>& names, const Alphabet* alpha) :
125 {
126  // Seq names and comments:
127  for (auto i : names)
129 
130 }
131 
132 /******************************************************************************/
133 
138 {}
139 
140 /******************************************************************************/
141 
146 {
147  // Now try to add each site:
148  for (size_t i = 0; i < vsc.getNumberOfSites(); i++)
149  addSite(vsc.getSite(i), false); // We assume that positions are correct.
150 
151 }
152 
153 /******************************************************************************/
154 
159 {
160  // Now try to add each site:
161  for (size_t i = 0; i < sc.getNumberOfSites(); i++)
162  addSite(sc.getSite(i), false); // We assume that positions are correct.
163 
164  for (auto i : sc.getSequenceNames())
166 }
167 
168 /******************************************************************************/
169 
174 {
175  for (size_t i = 0; i < osc.getNumberOfSequences(); i++)
176  addSequence(osc.getSequence(i), false);
177 
178  reindexSites();
179 }
180 
181 /******************************************************************************/
182 
187 {
188  for (auto name: sc.getSequenceNames())
189  addSequence(sc.getSequence(name), false);
190 
191  reindexSites();
192 }
193 
194 /******************************************************************************/
195 
199  AbstractSequenceContainer(avc.getAlphabet())
200 {
201  if (avc.getNumberOfSites() == 0)
202  throw Exception("VectorSiteContainer::VectorSiteContainer(AlignedValuesContainer): Empty site set.");
203 
204  // Seq names and comments:
205 
206  for (size_t i = 0; i < avc.getNumberOfSequences(); i++)
208 
209  // Now try to add each site:
210  for (size_t i = 0; i < avc.getNumberOfSites(); i++)
211  {
212  if (!dynamic_cast<const Site*>(&avc.getSymbolListSite(i)))
213  throw Exception("VectorSiteContainer::VectorSiteContainer(AlignedValuesContainer) : Not a Site in position " + TextTools::toString(i));
214 
215  addSite(dynamic_cast<const Site&>(avc.getSymbolListSite(i)));
216  }
217 }
218 
219 /******************************************************************************/
220 
222 {
223  clear();
226 
227  // Now try to add each site:
228  for (size_t i = 0; i < vsc.getNumberOfSites(); i++)
229  addSite(vsc.getSite(i), false); // We assume that positions are correct.
230 
231  return *this;
232 }
233 
234 /******************************************************************************/
235 
237 {
238  clear();
240  // Now try to add each site:
241  for (size_t i = 0; i < sc.getNumberOfSites(); i++)
242  addSite(sc.getSite(i), false); // We assume that positions are correct.
243 
244  for (auto i : sc.getSequenceNames())
246 
247  return *this;
248 }
249 
250 /******************************************************************************/
251 
253 {
254  clear();
256 
257  size_t nbSeq = osc.getNumberOfSequences();
258  for (size_t i = 0; i < nbSeq; i++)
259  addSequence(osc.getSequence(i), false);
260 
261  reindexSites();
262 
263  return *this;
264 }
265 
266 /******************************************************************************/
267 
269 {
270  clear();
272 
273  for (auto name: sc.getSequenceNames())
274  addSequence(sc.getSequence(name), false);
275 
276  reindexSites();
277 
278  return *this;
279 }
280 
281 /******************************************************************************/
282 
283 void VectorSiteContainer::setSite(size_t pos, const Site& site, bool checkPositions)
284 {
285  if (pos >= getNumberOfSites())
286  throw IndexOutOfBoundsException("VectorSiteContainer::setSite.", pos, 0, getNumberOfSites() - 1);
287 
288  // Check size:
289  if (site.size() != getNumberOfSequences())
290  throw SiteException("AlignedSequenceContainer::setSite. Site does not have the appropriate length", &site);
291 
292  // New site's alphabet and site container's alphabet matching verification
293  if (site.getAlphabet()->getAlphabetType() != getAlphabet()->getAlphabetType())
294  throw AlphabetMismatchException("VectorSiteContainer::setSite", getAlphabet(), site.getAlphabet());
295 
296  // Check position:
297  if (checkPositions)
298  {
299  int position = site.getPosition();
300  // For all positions in vector : throw exception if position already exists
301  for (size_t i = 0; i < getNumberOfSites(); i++)
302  {
303  if (getSite(i).getPosition() == position)
304  throw SiteException("VectorSiteContainer::setSite: Site position already exists in container", &site);
305  }
306  }
307 
308  VectorPositionedContainer<Site>::addObject(shared_ptr<Site>(site.clone()), pos, false);
309 
310  // Clean Sequence Container cache
311  for (size_t i=0; i<getNumberOfSequences(); i++)
312  {
315  }
316 }
317 
318 /******************************************************************************/
319 
320 void VectorSiteContainer::addSite(const Site& site, bool checkPositions)
321 {
322  // Check size:
323  if (getNumberOfSequences() != 0 && (site.size() != getNumberOfSequences()))
324  throw SiteException("VectorSiteContainer::addSite. Site does not have the appropriate length", &site);
325 
326  // New site's alphabet and site container's alphabet matching verification
327  if (site.getAlphabet()->getAlphabetType() != getAlphabet()->getAlphabetType())
328  throw AlphabetMismatchException("VectorSiteContainer::addSite", getAlphabet(), site.getAlphabet());
329 
330  // Check position:
331  if (checkPositions)
332  {
333  int position = site.getPosition();
334  // For all positions in vector : throw exception if position already exists
335  for (size_t i = 0; i < getNumberOfSites(); i++)
336  {
337  if (getSite(i).getPosition() == position)
338  throw SiteException("VectorSiteContainer::addSite(site, bool): Site position already exists in container", &site);
339  }
340  }
341 
342  VectorPositionedContainer<Site>::appendObject(shared_ptr<Site>(site.clone()));
343 
344  if (getNumberOfSequences() == 0)
345  for (size_t i = 0; i < site.size(); i++)
347  else
348  {
349  for (size_t i=0; i<getNumberOfSequences(); i++)
350  {
353  }
354 
355  }
356 
357 }
358 
359 /******************************************************************************/
360 
361 void VectorSiteContainer::addSite(const Site& site, int position, bool checkPositions)
362 {
363  // Check size:
364  if (getNumberOfSequences() != 0 && (site.size() != getNumberOfSequences()))
365  throw SiteException("VectorSiteContainer::addSite. Site does not have the appropriate length", &site);
366 
367  // New site's alphabet and site container's alphabet matching verification
368  if (site.getAlphabet()->getAlphabetType() != getAlphabet()->getAlphabetType())
369  throw AlphabetMismatchException("VectorSiteContainer::addSite", getAlphabet(), site.getAlphabet());
370 
371  // Check position:
372  if (checkPositions)
373  {
374  // For all positions in vector : throw exception if position already exists
375  for (size_t i = 0; i < getNumberOfSites(); i++)
376  {
377  if (getSite(i).getPosition() == position)
378  throw SiteException("VectorSiteContainer::addSite. Site position already exists in container", &site);
379  }
380  }
381 
382  shared_ptr<Site> nsite(shared_ptr<Site>(site.clone()));
383  nsite->setPosition(position);
385 
386  if (getNumberOfSequences() == 0)
387  for (size_t i = 0; i < site.size(); i++)
389  else
391 }
392 
393 /******************************************************************************/
394 
395 void VectorSiteContainer::addSite(const Site& site, size_t siteIndex, bool checkPositions)
396 {
397  if (siteIndex >= getNumberOfSites())
398  throw IndexOutOfBoundsException("VectorSiteContainer::addSite", siteIndex, 0, getNumberOfSites() - 1);
399 
400  // Check size:
401  if (site.size() != getNumberOfSequences())
402  throw SiteException("VectorSiteContainer::addSite. Site does not have the appropriate length", &site);
403 
404  // New site's alphabet and site container's alphabet matching verification
405  if (site.getAlphabet()->getAlphabetType() != getAlphabet()->getAlphabetType())
406  throw AlphabetMismatchException("VectorSiteContainer::addSite", getAlphabet(), site.getAlphabet());
407 
408  // Check position:
409  if (checkPositions)
410  {
411  int position = site.getPosition();
412  // For all positions in vector : throw exception if position already exists
413  for (size_t i = 0; i < getNumberOfSites(); i++)
414  {
415  if (getSite(i).getPosition() == position)
416  throw SiteException("VectorSiteContainer::addSite. Site position already exists in container", &site);
417  }
418  }
419 
420  VectorPositionedContainer<Site>::insertObject(shared_ptr<Site>(site.clone()), siteIndex);
421 
422  if (getNumberOfSequences() == 0)
423  for (size_t i = 0; i < site.size(); i++)
425  else
426  {
427  for (size_t i=0; i<getNumberOfSequences(); i++)
428  {
431  }
432  }
433 }
434 
435 /******************************************************************************/
436 
437 void VectorSiteContainer::addSite(const Site& site, size_t siteIndex, int position, bool checkPositions)
438 {
439  if (siteIndex >= getNumberOfSites())
440  throw IndexOutOfBoundsException("VectorSiteContainer::addSite", siteIndex, 0, getNumberOfSites() - 1);
441 
442  // Check size:
443  if (site.size() != getNumberOfSequences())
444  throw SiteException("VectorSiteContainer::addSite. Site does not have the appropriate length", &site);
445 
446  // New site's alphabet and site container's alphabet matching verification
447  if (site.getAlphabet()->getAlphabetType() != getAlphabet()->getAlphabetType())
448  {
449  throw AlphabetMismatchException("VectorSiteContainer::addSite", getAlphabet(), site.getAlphabet());
450  }
451 
452  // Check position:
453  if (checkPositions)
454  {
455  // For all positions in vector : throw exception if position already exists
456  for (size_t i = 0; i < getNumberOfSites(); i++)
457  {
458  if (getSite(i).getPosition() == position)
459  throw SiteException("VectorSiteContainer::addSite. Site position already exists in container", &site);
460  }
461  }
462 
463  shared_ptr<Site> nsite(shared_ptr<Site>(site.clone()));
464  nsite->setPosition(position);
466 
467  if (getNumberOfSequences() == 0)
468  for (size_t i = 0; i < site.size(); i++)
470  else
471  {
472  for (size_t i=0; i<getNumberOfSequences(); i++)
473  {
476  }
477  }
478 }
479 
480 
481 /******************************************************************************/
482 
484 {
485  for (size_t i = 0; i < getNumberOfSites(); i++)
486  {
487  getSite(i).setPosition((int)i + 1);
488  }
489 }
490 
491 /******************************************************************************/
492 
494 {
495  Vint positions(getNumberOfSites());
496  for (size_t i = 0; i < getNumberOfSites(); i++)
497  {
498  positions[i] = getSite(i).getPosition();
499  }
500 
501  return positions;
502 }
503 
504 
506 {
507  if (vPositions.size() != getNumberOfSites())
508  throw BadSizeException("VectorSiteContainer::setSitePositions bad size of positions vector", vPositions.size(), getNumberOfSites());
509 
510  for (size_t i = 0; i < getNumberOfSites(); i++)
511  {
512  getSite(i).setPosition(vPositions[i]);
513  }
514 }
515 
516 /******************************************************************************/
517 
519 {
520  if (i >= getNumberOfSequences())
521  throw IndexOutOfBoundsException("VectorSiteContainer::getSequence.", i, 0, getNumberOfSequences() - 1);
522 
523  // If Sequence already exsits
525  if (!isAvailableName(name))
527 
528  // Main loop : for all sites
529  size_t n = getNumberOfSites();
530  vector<int> sequence(n);
531  for (size_t j = 0; j < n; j++)
532  sequence[j] = getSite(j)[i];
533 
534  shared_ptr<Sequence> ns(new BasicSequence(
535  name,
536  sequence,
538  getAlphabet()));
539 
540  VectorMappedContainer<Sequence>::addObject_(ns, i, ns->getName(), false);
541 
542  return *ns;
543 }
544 
545 /******************************************************************************/
546 
547 const Sequence& VectorSiteContainer::getSequence(const string& name) const
548 {
549  // Look for sequence name:
550  size_t pos = getSequencePosition(name);
551  return getSequence(pos);
552 }
553 
554 /******************************************************************************/
555 
556 void VectorSiteContainer::setSequence(const string& name, const Sequence& sequence, bool checkNames)
557 {
558  // Look for sequence name:
559  size_t pos = getSequencePosition(name);
560  setSequence(pos, sequence, checkNames);
561 }
562 
563 /******************************************************************************/
564 
565 void VectorSiteContainer::setSequence(size_t pos, const Sequence& sequence, bool checkNames)
566 {
567  if (pos >= getNumberOfSequences())
568  throw IndexOutOfBoundsException("VectorSiteContainer::setSequence", pos, 0, getNumberOfSequences() - 1);
569 
570  // New sequence's alphabet and site container's alphabet matching verification
571  if (sequence.getAlphabet()->getAlphabetType() != getAlphabet()->getAlphabetType())
572  throw AlphabetMismatchException("VectorSiteContainer::setSequence", getAlphabet(), sequence.getAlphabet());
573 
574  const string& sname = sequence.getName();
575 
576  // If the container has only one sequence, we set the size to the size of this sequence:
577  if (getNumberOfSequences() == 1)
578  {
579  realloc(sequence.size());
580  }
581  else
582  {
583  if (sequence.size() != getNumberOfSites())
584  throw SequenceException("VectorSiteContainer::setSequence. Sequence has not the appropriate length.", &sequence);
585 
586  if (checkNames)
587  {
589  throw SequenceException("VectorSiteContainer::setSequence. Name already exists in another sequence in container.", &sequence);
590  }
591 
592  }
593 
594  // Update elements at each site:
595  for (size_t i = 0; i < getNumberOfSites(); i++)
596  {
597  getSite(i).setElement(pos, sequence.getValue(i));
598  }
599 
600  // Update name:
602 
603  // clear related Sequence in Container
605  {
607  }
608 }
609 
610 /******************************************************************************/
611 
612 std::shared_ptr<Sequence> VectorSiteContainer::removeSequence(size_t iseq)
613 {
614  getSequence(iseq);
615 
616  for (size_t i = 0; i < getNumberOfSites(); i++)
617  getSite(i).deleteElement(iseq);
618 
620 }
621 
622 // /******************************************************************************/
623 
624 std::shared_ptr<Sequence> VectorSiteContainer::removeSequence(const string& name)
625 {
626  // Look for sequence name:
627  size_t pos = getSequencePosition(name);
628  return removeSequence(pos);
629 }
630 
631 /******************************************************************************/
632 
633 void VectorSiteContainer::addSequence(const Sequence& sequence, bool checkNames)
634 {
635  // If the container has no sequence, we set the size to the size of this sequence:
636  if (getNumberOfSequences() == 0)
637  realloc(sequence.size());
638 
639  // New sequence's alphabet and site container's alphabet matching verification
640  if (sequence.getAlphabet()->getAlphabetType() != getAlphabet()->getAlphabetType())
641  throw AlphabetMismatchException("VectorSiteContainer::addSequence", getAlphabet(), sequence.getAlphabet());
642 
643  if (sequence.size() != getNumberOfSites())
644  throw SequenceException("VectorSiteContainer::addSequence. Sequence has not the appropriate length: " + TextTools::toString(sequence.size()) + ", should be " + TextTools::toString(getNumberOfSites()) + ".", &sequence);
645 
646  const string& sname = sequence.getName();
647 
648  if (checkNames && VectorMappedContainer<Sequence>::hasObject(sname))
649  throw SequenceException("VectorSiteContainer::addSequence. Name already exists in container.", &sequence);
650 
651  // Update elements at each site:
652  for (size_t i = 0; i < getNumberOfSites(); i++)
653  getSite(i).addElement(sequence.getValue(i));
654 
655  // Add empty sequence
656  VectorMappedContainer<Sequence>::appendObject(shared_ptr<Sequence> (new BasicSequence(sname, "", sequence.getComments(), getAlphabet())), sname);
657 }
658 
659 /******************************************************************************/
660 
661 void VectorSiteContainer::addSequence(const Sequence& sequence, size_t pos, bool checkNames)
662 {
663  if (pos >= getNumberOfSequences())
664  throw IndexOutOfBoundsException("VectorSiteContainer::addSequence.", pos, 0, getNumberOfSequences() - 1);
665 
666  if (sequence.size() != getNumberOfSites())
667  throw SequenceNotAlignedException("VectorSiteContainer::addSequence", &sequence);
668 
669  // New sequence's alphabet and site container's alphabet matching verification
670  if (sequence.getAlphabet()->getAlphabetType() != getAlphabet()->getAlphabetType())
671  throw AlphabetMismatchException("VectorSiteContainer::addSequence", getAlphabet(), sequence.getAlphabet());
672 
673  const string& sname = sequence.getName();
674 
675  if (checkNames && VectorMappedContainer<Sequence>::hasObject(sname))
676  throw SequenceException("VectorSiteContainer::addSequence. Name already exists in container.", &sequence);
677 
678  // Update elements at each site:
679  for (size_t i = 0; i < getNumberOfSites(); i++)
680  getSite(i).addElement(pos, sequence.getValue(i));
681 
682  VectorMappedContainer<Sequence>::insertObject(shared_ptr<Sequence> (new BasicSequence(sname, "", sequence.getComments(), getAlphabet())), pos, sname);
683 
684 }
685 
686 /******************************************************************************/
687 
689 {
692 }
693 
694 /******************************************************************************/
695 
697 {
698  clear();
699  Site s(getAlphabet());
700 
701  for (size_t i = 0; i < n; i++)
702  addSite(s, false);
703 
704  reindexSites();
705 }
706 
707 /******************************************************************************/
708 
709 void VectorSiteContainer::setComments(size_t sequenceIndex, const Comments& comments)
710 {
711  VectorMappedContainer<Sequence>::getObject(sequenceIndex)->setComments(comments);
712 }
713 
714 /******************************************************************************/
715 
717 {
720  return vsc;
721 }
722 
723 /******************************************************************************/
virtual int getPosition() const
Get the position of this site.
Definition: CoreSite.h:183
virtual void setPosition(int position)
Set the position of this site.
Definition: CoreSite.h:185
Partial implementation of the OrderedSequenceContainer interface.
AbstractSequenceContainer & operator=(const AbstractSequenceContainer &sc)
void setGeneralComments(const Comments &comments)
Set the comments of this container.
const Alphabet * getAlphabet() const
Get container's alphabet.
const Comments & getGeneralComments() const
Get the comments of this container.
The Container of Aligned Values interface.
virtual const CruxSymbolListSite & getSymbolListSite(size_t siteIndex) const =0
Get a CruxSymbolListSite from a given position.
virtual size_t getNumberOfSites() const =0
Get the number of aligned positions in the container.
Exception thrown when two alphabets do not match.
The Alphabet interface.
Definition: Alphabet.h:133
virtual std::string getAlphabetType() const =0
Identification method.
virtual void setElement(size_t pos, const std::string &c)
A basic implementation of the Sequence interface.
Definition: Sequence.h:155
virtual const std::string & getName() const =0
Get the name of this sequence.
virtual const Comments & getComments() const =0
Get the comments.
virtual const T & getValue(size_t pos) const =0
checked access to a character in list.
virtual void deleteElement(size_t pos)=0
Remove the element at position 'pos'.
virtual const Alphabet * getAlphabet() const =0
Get the alphabet associated to the list.
virtual size_t size() const =0
Get the number of elements in the list.
void changeName(const std::string &okey, const std::string &nkey)
change the key of an object.
bool isAvailableName(std::string objectName) const
Return if the name is in the map keys and the mapped object is nullptr or empty.
The OrderedSequenceContainer interface.
virtual const Sequence & getSequence(const std::string &name) const=0
Retrieve a sequence object from the container.
virtual const Sequence & getSequence(size_t sequenceIndex) const =0
Retrieve a sequence object from the container.
virtual std::shared_ptr< Sequence > removeSequence(const std::string &name)=0
Extract (and remove) a sequence from the container.
virtual const Comments & getComments(size_t sequenceIndex) const=0
virtual void setSequence(const std::string &name, const Sequence &sequence, bool checkName)=0
Replace a sequence in the container.
virtual const std::string & getName(size_t sequenceIndex) const =0
Get the name of a particular row of the alignement (aka sequence).
The SequenceContainer interface.
virtual const Sequence & getSequence(const std::string &name) const =0
Retrieve a sequence object from the container.
The sequence exception base class.
Exception thrown when a sequence is not align with others.
The sequence interface.
Definition: Sequence.h:71
virtual size_t getNumberOfSequences() const =0
Get the number of sequences in the container.
virtual std::vector< std::string > getSequenceNames() const =0
Get all the names of the sequences in the container.
The SiteContainer interface.
Definition: SiteContainer.h:65
virtual const Site & getSite(size_t siteIndex) const =0
Get a site from the container.
The site exception base class.
The Site class.
Definition: Site.h:68
virtual void addElement(const std::string &c)
Site * clone() const
Definition: Site.h:145
The template VectorMappedContainer class.
const std::shared_ptr< T > getObject(size_t objectIndex) const
Retrieve an object from the container. Set as protected since they will be public under T specific na...
void appendObject(std::shared_ptr< T > object, const std::string &name, bool check=true)
void addObject_(std::shared_ptr< T > object, size_t objectIndex, const std::string &name, bool check=false) const
void clear()
Delete all objects in the container.
std::string getObjectName(size_t objectIndex) const
std::shared_ptr< T > removeObject(size_t objectIndex)
Extract and remove a object from the container.
void insertObject(std::shared_ptr< T > object, size_t objectIndex, const std::string &name)
VectorMappedContainer< T > & operator=(const VectorMappedContainer &vsc)
The template VectorPositionedContainer class.
void appendObject(std::shared_ptr< T > object)
void nullify()
Nullify all elements.
void addObject(std::shared_ptr< T > object, size_t objectIndex, bool checkPosition=false)
Add an object.
void insertObject(std::shared_ptr< T > object, size_t objectIndex)
Insert an object.
The VectorSiteContainer class.
void reindexSites()
Set all positions attributes.
void addSite(const Site &site, bool checkPosition=true)
Add a site in the container.
void addSequence(const Sequence &sequence, bool checkName=true)
Add a sequence to the container.
virtual void setComments(size_t sequenceIndex, const Comments &comments)=0
void setSite(size_t siteIndex, const Site &site, bool checkPosition=true)
Set a site in the container.
VectorSiteContainer & operator=(const VectorSiteContainer &vsc)
const Site & getSite(size_t siteIndex) const
Get a site from the container.
size_t getNumberOfSites() const
Get the number of aligned positions in the container.
Vint getSitePositions() const
Get all position attributes of sites.
VectorSiteContainer * createEmptyContainer() const
Return a copy of this container, but with no data inside.
VectorSiteContainer(const std::vector< const CruxSymbolListSite * > &vs, const Alphabet *alpha, bool checkPositions=true)
Build a new container from a set of sites.
void clear()
Delete all objects in the container.
size_t getSequencePosition(const std::string &name) const
Get the position of a sequence in sequence container from its name.
size_t getNumberOfSequences() const
Get the number of sequences in the container.
void setSitePositions(Vint vPositions)
Set all position attributes of sites.
std::string toString(T t)
This alphabet is used to deal NumericAlphabet.
std::vector< int > Vint
std::vector< std::string > Comments
Declaration of Comments type.
Definition: Commentable.h:58