bpp-popgen  2.2.0
bpp::PolymorphismSequenceContainer Class Reference

The PolymorphismSequenceContainer class. More...

#include <Bpp/PopGen/PolymorphismSequenceContainer.h>

+ Inheritance diagram for bpp::PolymorphismSequenceContainer:
+ Collaboration diagram for bpp::PolymorphismSequenceContainer:

Public Member Functions

 PolymorphismSequenceContainer (const Alphabet *alpha)
 Build a new empty PolymorphismSequenceContainer. More...
 
 PolymorphismSequenceContainer (size_t size, const Alphabet *alpha)
 Build a new empty PolymorphismSequenceContainer of given size. More...
 
 PolymorphismSequenceContainer (const OrderedSequenceContainer &sc)
 Build a PolymorphismSequenceContainer by copying data from an OrderedSequenceContainer. More...
 
 PolymorphismSequenceContainer (const SiteContainer &sc)
 Build a PolymorphismSequenceContainer by copying data from a SiteContainer. More...
 
 PolymorphismSequenceContainer (const PolymorphismSequenceContainer &psc)
 Copy constructor. More...
 
PolymorphismSequenceContaineroperator= (const PolymorphismSequenceContainer &psc)
 Operator= : copy operator. More...
 
virtual ~PolymorphismSequenceContainer ()
 Destroy a PolymorphismSequenceContainer. More...
 
PolymorphismSequenceContainerclone () const
 Clone a PolymorphismSequenceContainer. More...
 
Sequence * removeSequence (size_t index) throw (IndexOutOfBoundsException)
 Remove a sequence by index and return a pointer to this removed sequence. More...
 
Sequence * removeSequence (const std::string &name) throw (SequenceNotFoundException)
 Remove a sequence by name and return a pointer to this removed sequence. More...
 
void deleteSequence (size_t index) throw (IndexOutOfBoundsException)
 Delete a sequence by index. More...
 
void deleteSequence (const std::string &name) throw (SequenceNotFoundException)
 Delete a sequence by name. More...
 
void addSequenceWithFrequency (const Sequence &sequence, unsigned int frequency, bool checkName=true) throw (Exception)
 Add a sequence to the container. More...
 
void addSequenceWithFrequency (const Sequence &sequence, size_t sequenceIndex, unsigned int frequency, bool checkName=true) throw (Exception)
 
void addSequence (const Sequence &sequence, bool checkName=true) throw (Exception)
 
void addSequence (const Sequence &sequence, size_t sequenceIndex, bool checkName=true) throw (Exception)
 
void clear ()
 Clear the container of all its sequences. More...
 
size_t getGroupId (size_t index) const throw (IndexOutOfBoundsException)
 Get the group identifier of the sequence. More...
 
size_t getGroupId (const std::string &name) const throw (SequenceNotFoundException)
 Get the group identifier of a sequence. More...
 
std::set< size_t > getAllGroupsIds () const
 Get all the groups identifiers. More...
 
void setGroupId (size_t index, size_t group_id) throw (IndexOutOfBoundsException)
 Set the group identifier of a sequence. More...
 
void setGroupId (const std::string &name, size_t group_id) throw (SequenceNotFoundException)
 Set the group identifier of a sequence. More...
 
size_t getNumberOfGroups () const
 Get the number of groups. More...
 
bool isIngroupMember (size_t index) const throw (IndexOutOfBoundsException)
 Tell if the sequence is ingroup by index. More...
 
bool isIngroupMember (const std::string &name) const throw (SequenceNotFoundException)
 Tell if a sequence is ingroup by name. More...
 
void setAsIngroupMember (size_t index) throw (IndexOutOfBoundsException)
 Set a sequence as ingroup member by index. More...
 
void setAsIngroupMember (const std::string &name) throw (SequenceNotFoundException)
 Set a sequence as ingroup member by name. More...
 
void setAsOutgroupMember (size_t index) throw (IndexOutOfBoundsException)
 Set a sequence as outgroup member by index. More...
 
void setAsOutgroupMember (const std::string &name) throw (SequenceNotFoundException)
 Set a sequence as outgroup member by name. More...
 
void setSequenceCount (size_t index, unsigned int count) throw (Exception)
 Set the count of a sequence by index. More...
 
void setSequenceCount (const std::string &name, unsigned int count) throw (Exception)
 Set the count of a sequence by name. More...
 
void incrementSequenceCount (size_t index) throw (IndexOutOfBoundsException)
 Add 1 to the sequence count. More...
 
void incrementSequenceCount (const std::string &name) throw (SequenceNotFoundException)
 Add 1 to the sequence count. More...
 
void decrementSequenceCount (size_t index) throw (IndexOutOfBoundsException, BadIntegerException)
 Removz 1 to the sequence count. More...
 
void decrementSequenceCount (const std::string &name) throw (SequenceNotFoundException, BadIntegerException)
 Remove 1 to the sequence count. More...
 
unsigned int getSequenceCount (size_t index) const throw (IndexOutOfBoundsException)
 Get the count of a sequence by index. More...
 
unsigned int getSequenceCount (const std::string &name) const throw (SequenceNotFoundException)
 Get the count of a sequence by name. More...
 

Private Attributes

std::vector< bool > ingroup_
 
std::vector< unsigned int > count_
 
std::vector< size_t > group_
 

Detailed Description

The PolymorphismSequenceContainer class.

This is a VectorSiteContainer with effectif for each sequence. It also has flag for ingroup and outgroup.

Author
Sylvain Gaillard

Definition at line 102 of file PolymorphismSequenceContainer.h.

Constructor & Destructor Documentation

◆ PolymorphismSequenceContainer() [1/5]

PolymorphismSequenceContainer::PolymorphismSequenceContainer ( const Alphabet *  alpha)

Build a new empty PolymorphismSequenceContainer.

Definition at line 49 of file PolymorphismSequenceContainer.cpp.

Referenced by clone().

◆ PolymorphismSequenceContainer() [2/5]

PolymorphismSequenceContainer::PolymorphismSequenceContainer ( size_t  size,
const Alphabet *  alpha 
)

Build a new empty PolymorphismSequenceContainer of given size.

Definition at line 57 of file PolymorphismSequenceContainer.cpp.

◆ PolymorphismSequenceContainer() [3/5]

PolymorphismSequenceContainer::PolymorphismSequenceContainer ( const OrderedSequenceContainer &  sc)

Build a PolymorphismSequenceContainer by copying data from an OrderedSequenceContainer.

Definition at line 65 of file PolymorphismSequenceContainer.cpp.

◆ PolymorphismSequenceContainer() [4/5]

PolymorphismSequenceContainer::PolymorphismSequenceContainer ( const SiteContainer &  sc)

Build a PolymorphismSequenceContainer by copying data from a SiteContainer.

Definition at line 73 of file PolymorphismSequenceContainer.cpp.

◆ PolymorphismSequenceContainer() [5/5]

PolymorphismSequenceContainer::PolymorphismSequenceContainer ( const PolymorphismSequenceContainer psc)

Copy constructor.

Definition at line 81 of file PolymorphismSequenceContainer.cpp.

References count_, getGroupId(), getSequenceCount(), group_, ingroup_, and isIngroupMember().

◆ ~PolymorphismSequenceContainer()

PolymorphismSequenceContainer::~PolymorphismSequenceContainer ( )
virtual

Destroy a PolymorphismSequenceContainer.

Definition at line 118 of file PolymorphismSequenceContainer.cpp.

References clear().

Member Function Documentation

◆ addSequence() [1/2]

void bpp::PolymorphismSequenceContainer::addSequence ( const Sequence &  sequence,
bool  checkName = true 
)
throw (Exception
)
inline

◆ addSequence() [2/2]

void bpp::PolymorphismSequenceContainer::addSequence ( const Sequence &  sequence,
size_t  sequenceIndex,
bool  checkName = true 
)
throw (Exception
)
inline

Definition at line 197 of file PolymorphismSequenceContainer.h.

References addSequenceWithFrequency().

◆ addSequenceWithFrequency() [1/2]

void PolymorphismSequenceContainer::addSequenceWithFrequency ( const Sequence &  sequence,
unsigned int  frequency,
bool  checkName = true 
)
throw (Exception
)

Add a sequence to the container.

Exceptions
AlphabetMismatchExceptionif the sequence's alphabet doesn't match the container's alphabet.
SequenceExceptionif the sequence's size doesn't match the sequence's size of the container.
SequenceExceptionif the sequence's name already exists in the container.

Definition at line 181 of file PolymorphismSequenceContainer.cpp.

Referenced by addSequence(), bpp::DataSet::getPolymorphismSequenceContainer(), and bpp::PolymorphismSequenceContainerTools::getSelectedSequences().

◆ addSequenceWithFrequency() [2/2]

void PolymorphismSequenceContainer::addSequenceWithFrequency ( const Sequence &  sequence,
size_t  sequenceIndex,
unsigned int  frequency,
bool  checkName = true 
)
throw (Exception
)

Definition at line 198 of file PolymorphismSequenceContainer.cpp.

◆ clear()

void PolymorphismSequenceContainer::clear ( )

Clear the container of all its sequences.

Definition at line 215 of file PolymorphismSequenceContainer.cpp.

References count_, group_, and ingroup_.

Referenced by ~PolymorphismSequenceContainer().

◆ clone()

PolymorphismSequenceContainer* bpp::PolymorphismSequenceContainer::clone ( ) const
inline

◆ decrementSequenceCount() [1/2]

void PolymorphismSequenceContainer::decrementSequenceCount ( size_t  index)
throw (IndexOutOfBoundsException,
BadIntegerException
)

Removz 1 to the sequence count.

Exceptions
IndexOutOfBoundsExceptionif index excedes the number of sequences in the container.
BadIntegerExceptionif count < 1 ... use deleteSequence instead of setting the count to 0.

Definition at line 413 of file PolymorphismSequenceContainer.cpp.

◆ decrementSequenceCount() [2/2]

void PolymorphismSequenceContainer::decrementSequenceCount ( const std::string &  name)
throw (SequenceNotFoundException,
BadIntegerException
)

Remove 1 to the sequence count.

Exceptions
SequenceNotFoundExceptionif name is not found among the sequences' names.
BadIntegerExceptionif count < 1 ... use deleteSequence instead of setting the count to 0.

Definition at line 424 of file PolymorphismSequenceContainer.cpp.

◆ deleteSequence() [1/2]

void PolymorphismSequenceContainer::deleteSequence ( size_t  index)
throw (IndexOutOfBoundsException
)

Delete a sequence by index.

Exceptions
IndexOutOfBoundsExceptionif index excedes the number of sequences.

Definition at line 153 of file PolymorphismSequenceContainer.cpp.

Referenced by bpp::PolymorphismSequenceContainerTools::extractGroup(), bpp::PolymorphismSequenceContainerTools::extractIngroup(), and bpp::PolymorphismSequenceContainerTools::extractOutgroup().

◆ deleteSequence() [2/2]

void PolymorphismSequenceContainer::deleteSequence ( const std::string &  name)
throw (SequenceNotFoundException
)

Delete a sequence by name.

Exceptions
SequenceNotFoundExceptionif name is not found among the sequences' names.

Definition at line 167 of file PolymorphismSequenceContainer.cpp.

◆ getAllGroupsIds()

std::set< size_t > PolymorphismSequenceContainer::getAllGroupsIds ( ) const

Get all the groups identifiers.

Definition at line 248 of file PolymorphismSequenceContainer.cpp.

References group_.

Referenced by getNumberOfGroups().

◆ getGroupId() [1/2]

◆ getGroupId() [2/2]

size_t PolymorphismSequenceContainer::getGroupId ( const std::string &  name) const
throw (SequenceNotFoundException
)

Get the group identifier of a sequence.

Exceptions
SequenceNotFoundExceptionif name is not found among the sequences' names.

Definition at line 234 of file PolymorphismSequenceContainer.cpp.

◆ getNumberOfGroups()

size_t PolymorphismSequenceContainer::getNumberOfGroups ( ) const

Get the number of groups.

Definition at line 283 of file PolymorphismSequenceContainer.cpp.

References getAllGroupsIds().

◆ getSequenceCount() [1/2]

unsigned int PolymorphismSequenceContainer::getSequenceCount ( size_t  index) const
throw (IndexOutOfBoundsException
)

◆ getSequenceCount() [2/2]

unsigned int PolymorphismSequenceContainer::getSequenceCount ( const std::string &  name) const
throw (SequenceNotFoundException
)

Get the count of a sequence by name.

Exceptions
SequenceNotFoundExceptionif name is not found among the sequences' names.

Definition at line 451 of file PolymorphismSequenceContainer.cpp.

◆ incrementSequenceCount() [1/2]

void PolymorphismSequenceContainer::incrementSequenceCount ( size_t  index)
throw (IndexOutOfBoundsException
)

Add 1 to the sequence count.

Exceptions
IndexOutOfBoundsExceptionif index excedes the number of sequences in the container.

Definition at line 390 of file PolymorphismSequenceContainer.cpp.

◆ incrementSequenceCount() [2/2]

void PolymorphismSequenceContainer::incrementSequenceCount ( const std::string &  name)
throw (SequenceNotFoundException
)

Add 1 to the sequence count.

Exceptions
SequenceNotFoundExceptionif name is not found among the sequences' names.

Definition at line 399 of file PolymorphismSequenceContainer.cpp.

◆ isIngroupMember() [1/2]

◆ isIngroupMember() [2/2]

bool PolymorphismSequenceContainer::isIngroupMember ( const std::string &  name) const
throw (SequenceNotFoundException
)

Tell if a sequence is ingroup by name.

Exceptions
SequenceNotFoundExceptionif name is not found among the sequences' names.

Definition at line 299 of file PolymorphismSequenceContainer.cpp.

◆ operator=()

PolymorphismSequenceContainer & PolymorphismSequenceContainer::operator= ( const PolymorphismSequenceContainer psc)

Operator= : copy operator.

Definition at line 97 of file PolymorphismSequenceContainer.cpp.

References count_, getGroupId(), getSequenceCount(), group_, ingroup_, and isIngroupMember().

◆ removeSequence() [1/2]

Sequence * PolymorphismSequenceContainer::removeSequence ( size_t  index)
throw (IndexOutOfBoundsException
)

Remove a sequence by index and return a pointer to this removed sequence.

Exceptions
IndexOutOfBoundsExceptionif index excedes the number of sequences.

Definition at line 127 of file PolymorphismSequenceContainer.cpp.

◆ removeSequence() [2/2]

Sequence * PolymorphismSequenceContainer::removeSequence ( const std::string &  name)
throw (SequenceNotFoundException
)

Remove a sequence by name and return a pointer to this removed sequence.

Exceptions
SequenceNotFoundExceptionif name is not found among the sequences' names.

Definition at line 139 of file PolymorphismSequenceContainer.cpp.

◆ setAsIngroupMember() [1/2]

◆ setAsIngroupMember() [2/2]

void PolymorphismSequenceContainer::setAsIngroupMember ( const std::string &  name)
throw (SequenceNotFoundException
)

Set a sequence as ingroup member by name.

Exceptions
SequenceNotFoundExceptionif name is not found among the sequences' names.

Definition at line 322 of file PolymorphismSequenceContainer.cpp.

◆ setAsOutgroupMember() [1/2]

◆ setAsOutgroupMember() [2/2]

void PolymorphismSequenceContainer::setAsOutgroupMember ( const std::string &  name)
throw (SequenceNotFoundException
)

Set a sequence as outgroup member by name.

Exceptions
SequenceNotFoundExceptionif name is not found among the sequences' names.

Definition at line 346 of file PolymorphismSequenceContainer.cpp.

◆ setGroupId() [1/2]

◆ setGroupId() [2/2]

void PolymorphismSequenceContainer::setGroupId ( const std::string &  name,
size_t  group_id 
)
throw (SequenceNotFoundException
)

Set the group identifier of a sequence.

Exceptions
SequenceNotFoundExceptionif name is not found among the sequences' names.

Definition at line 269 of file PolymorphismSequenceContainer.cpp.

◆ setSequenceCount() [1/2]

void PolymorphismSequenceContainer::setSequenceCount ( size_t  index,
unsigned int  count 
)
throw (Exception
)

Set the count of a sequence by index.

Exceptions
IndexOutOfBoundsExceptionif index excedes the number of sequences in the container.
BadIntegerExceptionif count < 1 ... use deleteSequence instead of setting the count to 0.

Definition at line 361 of file PolymorphismSequenceContainer.cpp.

Referenced by bpp::PolymorphismSequenceContainerTools::getCompleteSites(), and bpp::PolymorphismSequenceContainerTools::getSitesWithoutGaps().

◆ setSequenceCount() [2/2]

void PolymorphismSequenceContainer::setSequenceCount ( const std::string &  name,
unsigned int  count 
)
throw (Exception
)

Set the count of a sequence by name.

Exceptions
throwSequenceNotFoundException if name is not found among the sequences' names.
BadIntegerExceptionif count < 1 ... use deleteSequence instead of setting the count to 0.

Definition at line 372 of file PolymorphismSequenceContainer.cpp.

Member Data Documentation

◆ count_

std::vector<unsigned int> bpp::PolymorphismSequenceContainer::count_
private

◆ group_

std::vector<size_t> bpp::PolymorphismSequenceContainer::group_
private

◆ ingroup_

std::vector<bool> bpp::PolymorphismSequenceContainer::ingroup_
private

The documentation for this class was generated from the following files: