bpp-popgen3  3.0.0
bpp::LocusInfo Class Reference

The LocusInfo class. More...

#include <Bpp/PopGen/LocusInfo.h>

+ Inheritance diagram for bpp::LocusInfo:
+ Collaboration diagram for bpp::LocusInfo:

Public Member Functions

 LocusInfo (const std::string &name, const unsigned int ploidy=DIPLOID)
 Build a new LocusInfo object. More...
 
 LocusInfo (const LocusInfo &locusInfo)
 Copy constructor. More...
 
LocusInfooperator= (const LocusInfo &locusInfo)
 
virtual ~LocusInfo ()=default
 Destroy the LocusInfo. More...
 
LocusInfoclone () const override
 
const std::string & getName () const
 Get the name of the locus. More...
 
unsigned int getPloidy () const
 Get the ploidy of the locus. More...
 
void addAlleleInfo (const AlleleInfo &allele)
 Add an AlleleInfo to the LocusInfo. More...
 
const AlleleInfogetAlleleInfoById (const std::string &id) const
 Retrieve an AlleleInfo object of the LocusInfo. More...
 
const AlleleInfogetAlleleInfoByKey (size_t key) const
 Retrieve an AlleleInfo object of the LocusInfo. More...
 
unsigned int getAlleleInfoKey (const std::string &id) const
 Get the position of an AlleleInfo. More...
 
size_t getNumberOfAlleles () const
 Get the number of alleles at this locus. More...
 
void clear ()
 Delete all alleles from the locus. More...
 

Static Public Attributes

static unsigned int HAPLODIPLOID = 0
 
static unsigned int HAPLOID = 1
 
static unsigned int DIPLOID = 2
 
static unsigned int UNKNOWN = 9999
 

Private Attributes

std::string name_
 
unsigned int ploidy_
 
std::vector< std::unique_ptr< AlleleInfo > > alleles_
 

Detailed Description

The LocusInfo class.

This is an AlleleInfo container with additional data like a name, the ploidy and some comments.

Author
Sylvain Gaillard

Definition at line 29 of file LocusInfo.h.

Constructor & Destructor Documentation

◆ LocusInfo() [1/2]

bpp::LocusInfo::LocusInfo ( const std::string &  name,
const unsigned int  ploidy = DIPLOID 
)
inline

Build a new LocusInfo object.

Parameters
nameThe name of the locus.
ploidyThe ploidy of the locus.

Definition at line 51 of file LocusInfo.h.

Referenced by clone().

◆ LocusInfo() [2/2]

bpp::LocusInfo::LocusInfo ( const LocusInfo locusInfo)
inline

Copy constructor.

Definition at line 60 of file LocusInfo.h.

References alleles_, bpp::AlleleInfo::clone(), getAlleleInfoByKey(), and getNumberOfAlleles().

◆ ~LocusInfo()

virtual bpp::LocusInfo::~LocusInfo ( )
virtualdefault

Destroy the LocusInfo.

Member Function Documentation

◆ addAlleleInfo()

void LocusInfo::addAlleleInfo ( const AlleleInfo allele)

Add an AlleleInfo to the LocusInfo.

Exceptions
BadIdentifierExceptionif the AlleleInfo's id already exists.

Definition at line 21 of file LocusInfo.cpp.

References bpp::AlleleInfo::clone(), and bpp::AlleleInfo::getId().

Referenced by bpp::Genetix::read().

◆ clear()

void bpp::LocusInfo::clear ( )
inline

Delete all alleles from the locus.

Definition at line 139 of file LocusInfo.h.

References alleles_.

◆ clone()

LocusInfo* bpp::LocusInfo::clone ( ) const
inlineoverridevirtual

Implements bpp::Clonable.

Definition at line 88 of file LocusInfo.h.

References LocusInfo().

Referenced by bpp::AnalyzedLoci::setLocusInfo().

◆ getAlleleInfoById()

const AlleleInfo & LocusInfo::getAlleleInfoById ( const std::string &  id) const

Retrieve an AlleleInfo object of the LocusInfo.

Exceptions
AlleleNotFoundExceptionif the id is not found.

Definition at line 32 of file LocusInfo.cpp.

◆ getAlleleInfoByKey()

const AlleleInfo & LocusInfo::getAlleleInfoByKey ( size_t  key) const

Retrieve an AlleleInfo object of the LocusInfo.

Exceptions
IndexOutOfBoundsExceptionif key exceeds the number of alleles.

Definition at line 42 of file LocusInfo.cpp.

Referenced by LocusInfo(), operator=(), bpp::DarwinVarSingle::write(), and bpp::PopgenlibIO::write().

◆ getAlleleInfoKey()

unsigned int LocusInfo::getAlleleInfoKey ( const std::string &  id) const

Get the position of an AlleleInfo.

Exceptions
AlleleNotFoundExceptionif the AlleleInfo's id is not found.

Definition at line 49 of file LocusInfo.cpp.

Referenced by bpp::MultilocusGenotype::setMonolocusGenotypeByAlleleId().

◆ getName()

const std::string& bpp::LocusInfo::getName ( ) const
inline

Get the name of the locus.

Definition at line 94 of file LocusInfo.h.

References name_.

Referenced by bpp::DarwinVarSingle::write(), and bpp::PopgenlibIO::write().

◆ getNumberOfAlleles()

size_t bpp::LocusInfo::getNumberOfAlleles ( ) const
inline

Get the number of alleles at this locus.

Definition at line 134 of file LocusInfo.h.

References alleles_.

Referenced by LocusInfo(), operator=(), bpp::DarwinVarSingle::write(), and bpp::PopgenlibIO::write().

◆ getPloidy()

unsigned int bpp::LocusInfo::getPloidy ( ) const
inline

Get the ploidy of the locus.

Returns
The ploidy as an unsigned integer.

Definition at line 101 of file LocusInfo.h.

References ploidy_.

Referenced by bpp::PopgenlibIO::write().

◆ operator=()

LocusInfo& bpp::LocusInfo::operator= ( const LocusInfo locusInfo)
inline

Member Data Documentation

◆ alleles_

std::vector<std::unique_ptr<AlleleInfo> > bpp::LocusInfo::alleles_
private

Definition at line 35 of file LocusInfo.h.

Referenced by clear(), getNumberOfAlleles(), LocusInfo(), and operator=().

◆ DIPLOID

unsigned int LocusInfo::DIPLOID = 2
static

Definition at line 40 of file LocusInfo.h.

Referenced by bpp::PopgenlibIO::parseLoci_(), and bpp::PopgenlibIO::write().

◆ HAPLODIPLOID

unsigned int LocusInfo::HAPLODIPLOID = 0
static

Definition at line 38 of file LocusInfo.h.

Referenced by bpp::PopgenlibIO::parseLoci_(), and bpp::PopgenlibIO::write().

◆ HAPLOID

unsigned int LocusInfo::HAPLOID = 1
static

Definition at line 39 of file LocusInfo.h.

Referenced by bpp::PopgenlibIO::parseLoci_(), and bpp::PopgenlibIO::write().

◆ name_

std::string bpp::LocusInfo::name_
private

Definition at line 33 of file LocusInfo.h.

Referenced by getName(), and operator=().

◆ ploidy_

unsigned int bpp::LocusInfo::ploidy_
private

Definition at line 34 of file LocusInfo.h.

Referenced by getPloidy(), and operator=().

◆ UNKNOWN

unsigned int LocusInfo::UNKNOWN = 9999
static

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