bpp-popgen  3.0.0
bpp::LocusInfo Class Reference

The LocusInfo class. More...

#include <Bpp/PopGen/LocusInfo.h>

+ 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 &locus_info)
 Copy constructor. More...
 
virtual ~LocusInfo ()
 Destroy the LocusInfo. More...
 
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< AlleleInfo * > alleles_
 

Detailed Description

The LocusInfo class.

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

Author
Sylvain Gaillard

Definition at line 63 of file LocusInfo.h.

Constructor & Destructor Documentation

◆ LocusInfo() [1/2]

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

Build a new LocusInfo object.

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

Definition at line 55 of file LocusInfo.cpp.

◆ LocusInfo() [2/2]

LocusInfo::LocusInfo ( const LocusInfo locus_info)

Copy constructor.

Definition at line 59 of file LocusInfo.cpp.

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

◆ ~LocusInfo()

LocusInfo::~LocusInfo ( )
virtual

Destroy the LocusInfo.

Definition at line 71 of file LocusInfo.cpp.

References alleles_.

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 83 of file LocusInfo.cpp.

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

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

◆ clear()

void LocusInfo::clear ( )

Delete all alleles from the locus.

Definition at line 126 of file LocusInfo.cpp.

References alleles_.

◆ 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 94 of file LocusInfo.cpp.

References alleles_.

◆ getAlleleInfoByKey()

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

Retrieve an AlleleInfo object of the LocusInfo.

Exceptions
IndexOutOfBoundsExceptionif key excedes the number of alleles.

Definition at line 104 of file LocusInfo.cpp.

References alleles_.

Referenced by LocusInfo(), 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 111 of file LocusInfo.cpp.

References alleles_.

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

◆ getName()

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

Get the name of the locus.

Definition at line 101 of file LocusInfo.h.

References name_.

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

◆ getNumberOfAlleles()

size_t LocusInfo::getNumberOfAlleles ( ) const

Get the number of alleles at this locus.

Definition at line 121 of file LocusInfo.cpp.

References alleles_.

Referenced by LocusInfo(), 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 108 of file LocusInfo.h.

References ploidy_.

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

Member Data Documentation

◆ alleles_

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

◆ DIPLOID

unsigned int LocusInfo::DIPLOID = 2
static

Definition at line 73 of file LocusInfo.h.

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

◆ HAPLODIPLOID

unsigned int LocusInfo::HAPLODIPLOID = 0
static

Definition at line 71 of file LocusInfo.h.

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

◆ HAPLOID

unsigned int LocusInfo::HAPLOID = 1
static

Definition at line 72 of file LocusInfo.h.

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

◆ name_

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

Definition at line 66 of file LocusInfo.h.

Referenced by getName().

◆ ploidy_

unsigned int bpp::LocusInfo::ploidy_
private

Definition at line 67 of file LocusInfo.h.

Referenced by getPloidy().

◆ UNKNOWN

unsigned int LocusInfo::UNKNOWN = 9999
static

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