bpp-popgen  2.2.0
bpp::Individual Class Reference

The Individual class. More...

#include <Bpp/PopGen/Individual.h>

+ Collaboration diagram for bpp::Individual:

Public Member Functions

 Individual ()
 Build a void new Individual. More...
 
 Individual (const std::string &id)
 Build a new Individual with an identifier. More...
 
 Individual (const std::string &id, const Date &date, const Point2D< double > &coord, Locality< double > *locality, const unsigned short sex)
 Build a new Individual with parameters. More...
 
 Individual (const Individual &ind)
 The Individual copy constructor. More...
 
virtual ~Individual ()
 Destroy an Individual. More...
 
Individualoperator= (const Individual &ind)
 The Individual copy operator. More...
 
void setId (const std::string &id)
 Set the id of the Individual. More...
 
const std::string & getId () const
 Get the id of the Individual. More...
 
void setSex (const unsigned short sex)
 Set the sex of the Individual. More...
 
unsigned short getSex () const
 Get the sex of the Individual. More...
 
void setDate (const Date &date)
 Set the date of the Individual. More...
 
const DategetDate () const throw (NullPointerException)
 Get the date of the Individual. More...
 
bool hasDate () const
 Tell if this Individual has a date. More...
 
void setCoord (const Point2D< double > &coord)
 Set the coodinates of the Individual. More...
 
void setCoord (const double x, const double y)
 Set the coordinates of the Individual. More...
 
const Point2D< double > & getCoord () const throw (NullPointerException)
 Get the coordinates of the Induvidual. More...
 
bool hasCoord () const
 Tell if this Individual has coordinates. More...
 
void setX (const double x) throw (NullPointerException)
 Set the X coordinate of the Individual. More...
 
void setY (const double y) throw (NullPointerException)
 Set the Y coordinate of th Individual. More...
 
double getX () const throw (NullPointerException)
 Get the X coordinate of the Individual. More...
 
double getY () const throw (NullPointerException)
 Get the Y coordinate of the Individual. More...
 
void setLocality (const Locality< double > *locality)
 Set the locality of the Individual. More...
 
const Locality< double > * getLocality () const throw (NullPointerException)
 Get the locality of the Individual. More...
 
bool hasLocality () const
 Tell if this Individual has a locality. More...
 
void addSequence (size_t sequence_key, const Sequence &sequence) throw (Exception)
 Add a sequence to the Individual. More...
 
const Sequence & getSequenceByName (const std::string &sequence_name) const throw (Exception)
 Get a sequence by its name. More...
 
const Sequence & getSequenceAtPosition (const size_t sequence_position) const throw (Exception)
 Get a sequence by its position. More...
 
void deleteSequenceByName (const std::string &sequence_name) throw (Exception)
 Delete a sequence. More...
 
void deleteSequenceAtPosition (size_t sequence_position) throw (Exception)
 Delete a sequence. More...
 
bool hasSequences () const
 Tell if the Individual has some sequences. More...
 
bool hasSequenceAtPosition (size_t position) const
 Tell if the Individual has a sequence at a given position. More...
 
const Alphabet * getSequenceAlphabet () const throw (NullPointerException)
 Return the alphabet of the sequences. More...
 
std::vector< std::string > getSequencesNames () const throw (NullPointerException)
 Get the sequences' names. More...
 
std::vector< size_t > getSequencesPositions () const throw (NullPointerException)
 Get the sequences' positions. More...
 
size_t getSequencePosition (const std::string &sequence_name) const throw (Exception)
 Get the position of a sequence. More...
 
size_t getNumberOfSequences () const
 Get the number of sequences. More...
 
void setSequences (const MapSequenceContainer &msc)
 Set all the sequences with a MapSequenceContainer. More...
 
const OrderedSequenceContainer & getSequences () const throw (NullPointerException)
 Get a reference to the sequence container. More...
 
void setGenotype (const MultilocusGenotype &genotype)
 Set a genotype. More...
 
void initGenotype (size_t loci_number) throw (Exception)
 Init the genotype. More...
 
const MultilocusGenotypegetGenotype () const throw (NullPointerException)
 Get the genotype. More...
 
void deleteGenotype ()
 Delete the genotype of the individual. More...
 
bool hasGenotype () const
 Tell if the Individual has a MultilocusGenotype. More...
 
void setMonolocusGenotype (size_t locus_position, const MonolocusGenotype &monogen) throw (Exception)
 Set a MonolocusGenotype. More...
 
void setMonolocusGenotypeByAlleleKey (size_t locus_position, const std::vector< size_t > allele_keys) throw (Exception)
 Set a MonolocusGenotype. More...
 
void setMonolocusGenotypeByAlleleId (size_t locus_position, const std::vector< std::string > allele_id, const LocusInfo &locus_info) throw (Exception)
 Set a MonolocusGenotype. More...
 
const MonolocusGenotypegetMonolocusGenotype (size_t locus_position) throw (Exception)
 Get a MonolocusGenotype. More...
 
size_t countNonMissingLoci () const throw (NullPointerException)
 Count the number of non missing MonolocusGenotype. More...
 
size_t countHomozygousLoci () const throw (NullPointerException)
 Count the number of homozygous MonolocusGenotype. More...
 
size_t countHeterozygousLoci () const throw (NullPointerException)
 Count the number of heterozygous MonolocusGenotype. More...
 

Protected Attributes

std::string id_
 
unsigned short sex_
 
std::auto_ptr< Datedate_
 
std::auto_ptr< Point2D< double > > coord_
 
const Locality< double > * locality_
 
std::auto_ptr< MapSequenceContainer > sequences_
 
std::auto_ptr< MultilocusGenotypegenotype_
 

Detailed Description

The Individual class.

This class is designed to store data on a single individual. This individual has only one sequence for each locus ... no information about diploid sequence data. See the no more in use MultiSeqIndividual documentation for an alternative.

Author
Sylvain Gaillard

Definition at line 75 of file Individual.h.

Constructor & Destructor Documentation

◆ Individual() [1/4]

Individual::Individual ( )

Build a void new Individual.

Definition at line 47 of file Individual.cpp.

◆ Individual() [2/4]

Individual::Individual ( const std::string &  id)

Build a new Individual with an identifier.

Definition at line 55 of file Individual.cpp.

◆ Individual() [3/4]

Individual::Individual ( const std::string &  id,
const Date date,
const Point2D< double > &  coord,
Locality< double > *  locality,
const unsigned short  sex 
)

Build a new Individual with parameters.

Parameters
idThe id of the Individual as a string.
dateThe date of the Individual as a Date object.
coordThe coordinates of the Individual as a Point2D object.
localityThe locality of the Individual as a pointer to a Locality object.
sexThe sex of the Individual as an unsigned short.

Definition at line 63 of file Individual.cpp.

◆ Individual() [4/4]

Individual::Individual ( const Individual ind)

◆ ~Individual()

Individual::~Individual ( )
virtual

Destroy an Individual.

Definition at line 113 of file Individual.cpp.

Member Function Documentation

◆ addSequence()

void Individual::addSequence ( size_t  sequence_key,
const Sequence &  sequence 
)
throw (Exception
)

Add a sequence to the Individual.

Creates the sequence container when adding the first sequence. Otherwize add the sequence to the end of the sequence container.

Parameters
sequence_keythe place where the sequence will be put.
sequenceThe sequence to add.
Exceptions
AlphabetMismatchExceptionif the sequence's alphabet doesn't match the container's alphabet.
BadIdentifierExceptionif sequence's name is already in use.
BadIntegerExceptionif sequence_position is already in use.

Definition at line 298 of file Individual.cpp.

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

◆ countHeterozygousLoci()

size_t Individual::countHeterozygousLoci ( ) const
throw (NullPointerException
)

Count the number of heterozygous MonolocusGenotype.

Exceptions
NullPointerExceptionif there is no genotype defined.

Definition at line 624 of file Individual.cpp.

References genotype_, and hasGenotype().

◆ countHomozygousLoci()

size_t Individual::countHomozygousLoci ( ) const
throw (NullPointerException
)

Count the number of homozygous MonolocusGenotype.

Exceptions
NullPointerExceptionif there is no genotype defined.

Definition at line 615 of file Individual.cpp.

References genotype_, and hasGenotype().

◆ countNonMissingLoci()

size_t Individual::countNonMissingLoci ( ) const
throw (NullPointerException
)

Count the number of non missing MonolocusGenotype.

Exceptions
NullPointerExceptionif there is no genotype defined.

Definition at line 606 of file Individual.cpp.

References genotype_, and hasGenotype().

◆ deleteGenotype()

void Individual::deleteGenotype ( )

Delete the genotype of the individual.

Definition at line 520 of file Individual.cpp.

References genotype_.

◆ deleteSequenceAtPosition()

void Individual::deleteSequenceAtPosition ( size_t  sequence_position)
throw (Exception
)

Delete a sequence.

Parameters
sequence_positionThe position of the sequence.
Exceptions
NullPointerExceptionif there is no sequence container defined.
SequenceNotFoundExceptionif sequence_postion is not found.

Definition at line 373 of file Individual.cpp.

◆ deleteSequenceByName()

void Individual::deleteSequenceByName ( const std::string &  sequence_name)
throw (Exception
)

Delete a sequence.

Parameters
sequence_nameThe name of the sequence.
Exceptions
NullPointerExceptionif there is no sequence container defined.
SequenceNotFoundExceptionif sequence_name is not found.

Definition at line 357 of file Individual.cpp.

◆ getCoord()

const Point2D< double > & Individual::getCoord ( ) const
throw (NullPointerException
)

Get the coordinates of the Induvidual.

Returns
A pointer toward a Point2D object if the Individual has coordinates. Otherwise throw a NullPointerException.

Definition at line 215 of file Individual.cpp.

References coord_, and hasCoord().

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

◆ getDate()

const Date & Individual::getDate ( ) const
throw (NullPointerException
)

Get the date of the Individual.

Returns
A pointer toward a Date object if the Individual has a date. Otherwise throw a NullPointerException.

Definition at line 183 of file Individual.cpp.

References date_, and hasDate().

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

◆ getGenotype()

const MultilocusGenotype & Individual::getGenotype ( ) const
throw (NullPointerException
)

Get the genotype.

Definition at line 511 of file Individual.cpp.

References genotype_, and hasGenotype().

Referenced by bpp::DataSet::getPolymorphismMultiGContainer(), Individual(), operator=(), and bpp::PopgenlibIO::write().

◆ getId()

const std::string& bpp::Individual::getId ( ) const
inline

Get the id of the Individual.

Returns
The id of the Individual as a string.

Definition at line 146 of file Individual.h.

References id_.

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

◆ getLocality()

const Locality< double > * Individual::getLocality ( ) const
throw (NullPointerException
)

Get the locality of the Individual.

Returns
A pointer to the Locality of the Individual.

Definition at line 280 of file Individual.cpp.

References hasLocality(), and locality_.

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

◆ getMonolocusGenotype()

const MonolocusGenotype & Individual::getMonolocusGenotype ( size_t  locus_position)
throw (Exception
)

Get a MonolocusGenotype.

Exceptions
NullPointerExceptionif there is no genotype defined.
IndexOutOfBoundsExceptionif locus_position excedes the number of loci.

Definition at line 590 of file Individual.cpp.

◆ getNumberOfSequences()

size_t Individual::getNumberOfSequences ( ) const

Get the number of sequences.

Definition at line 461 of file Individual.cpp.

References sequences_.

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

◆ getSequenceAlphabet()

const Alphabet * Individual::getSequenceAlphabet ( ) const
throw (NullPointerException
)

Return the alphabet of the sequences.

Exceptions
NullPointerExceptionif there is no sequence container defined.

Definition at line 452 of file Individual.cpp.

References sequences_.

◆ getSequenceAtPosition()

const Sequence & Individual::getSequenceAtPosition ( const size_t  sequence_position) const
throw (Exception
)

Get a sequence by its position.

Parameters
sequence_positionThe position of the sequence in the sequence set.
Returns
A reference to the sequence.
Exceptions
NullPointerExceptionif there is no sequence container defined.
SequenceNotFoundExceptionif sequence_position is not found (i.e. missing data or not used).

Definition at line 340 of file Individual.cpp.

Referenced by bpp::DataSet::getPolymorphismSequenceContainer(), and bpp::PopgenlibIO::write().

◆ getSequenceByName()

const Sequence & Individual::getSequenceByName ( const std::string &  sequence_name) const
throw (Exception
)

Get a sequence by its name.

Parameters
sequence_nameThe name of the sequence.
Returns
A reference to the sequence.
Exceptions
NullPointerExceptionif there is no sequence container defined.
SequenceNotFoundExceptionif sequence_name is not found.

Definition at line 323 of file Individual.cpp.

◆ getSequencePosition()

size_t Individual::getSequencePosition ( const std::string &  sequence_name) const
throw (Exception
)

Get the position of a sequence.

Exceptions
NullPointerExceptionif there is no sequence container defined.
SequenceNotFoundExceptionif sequence_name is not found.

Definition at line 413 of file Individual.cpp.

◆ getSequences()

const OrderedSequenceContainer & Individual::getSequences ( ) const
throw (NullPointerException
)

Get a reference to the sequence container.

Exceptions
NullPointerExceptionif there is no sequence container defined.

Definition at line 477 of file Individual.cpp.

References sequences_.

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

◆ getSequencesNames()

std::vector< std::string > Individual::getSequencesNames ( ) const
throw (NullPointerException
)

Get the sequences' names.

Returns
All the sequences' names of the individual in a vector of string.
Exceptions
NullPointerExceptionif there is no sequence container defined.

Definition at line 389 of file Individual.cpp.

References sequences_.

◆ getSequencesPositions()

std::vector< size_t > Individual::getSequencesPositions ( ) const
throw (NullPointerException
)

Get the sequences' positions.

Returns
All the positions where a sequence is found.
Exceptions
NullPointerExceptionif there is no sequence container defined.

Definition at line 398 of file Individual.cpp.

References sequences_.

Referenced by hasSequenceAtPosition().

◆ getSex()

unsigned short bpp::Individual::getSex ( ) const
inline

Get the sex of the Individual.

Returns
The sex of the Individual as an unsigned short.

Definition at line 160 of file Individual.h.

References sex_.

Referenced by operator=().

◆ getX()

double Individual::getX ( ) const
throw (NullPointerException
)

Get the X coordinate of the Individual.

Returns
The X coordinate as a double if the Individual has coordinates. Otherwise throw a NullPointerException.

Definition at line 252 of file Individual.cpp.

References coord_, and hasCoord().

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

◆ getY()

double Individual::getY ( ) const
throw (NullPointerException
)

Get the Y coordinate of the Individual.

Returns
The Y coordinate as a double if the Individual has coordinates. Otherwise throw a NullPointerException.

Definition at line 262 of file Individual.cpp.

References coord_, and hasCoord().

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

◆ hasCoord()

bool Individual::hasCoord ( ) const

Tell if this Individual has coordinates.

Definition at line 225 of file Individual.cpp.

References coord_.

Referenced by getCoord(), getX(), getY(), and bpp::PopgenlibIO::write().

◆ hasDate()

bool Individual::hasDate ( ) const

Tell if this Individual has a date.

Definition at line 193 of file Individual.cpp.

References date_.

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

◆ hasGenotype()

◆ hasLocality()

bool Individual::hasLocality ( ) const

Tell if this Individual has a locality.

Definition at line 290 of file Individual.cpp.

References locality_.

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

◆ hasSequenceAtPosition()

bool Individual::hasSequenceAtPosition ( size_t  position) const

Tell if the Individual has a sequence at a given position.

Definition at line 436 of file Individual.cpp.

References getSequencesPositions(), and hasSequences().

Referenced by bpp::DataSet::getPolymorphismSequenceContainer().

◆ hasSequences()

bool Individual::hasSequences ( ) const

Tell if the Individual has some sequences.

Returns
TRUE if the individual has at least one sequence.
FALSE if the container is empty or undifined.

Definition at line 429 of file Individual.cpp.

References getNumberOfSequences().

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

◆ initGenotype()

void Individual::initGenotype ( size_t  loci_number)
throw (Exception
)

Init the genotype.

Exceptions
Exceptionif the Individual already has a Genotype.
BadIntegerExceptionif loci_number < 1.

Definition at line 495 of file Individual.cpp.

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

◆ operator=()

Individual & Individual::operator= ( const Individual ind)

The Individual copy operator.

Returns
A ref toward the assigned Individual. Make a copy of each atribute of the Individual.

Definition at line 117 of file Individual.cpp.

References coord_, date_, genotype_, getCoord(), getDate(), getGenotype(), getId(), getLocality(), getSequences(), getSex(), hasGenotype(), locality_, sequences_, setCoord(), setDate(), setId(), setLocality(), setSequences(), and setSex().

◆ setCoord() [1/2]

void Individual::setCoord ( const Point2D< double > &  coord)

Set the coodinates of the Individual.

Parameters
coordA Point2D object.

Definition at line 201 of file Individual.cpp.

References coord_.

Referenced by Individual(), operator=(), and bpp::PopgenlibIO::parseIndividual_().

◆ setCoord() [2/2]

void Individual::setCoord ( const double  x,
const double  y 
)

Set the coordinates of the Individual.

Parameters
xThe X coordinate as a double.
yThe Y coordinate as a double.

Definition at line 208 of file Individual.cpp.

References coord_.

◆ setDate()

void Individual::setDate ( const Date date)

Set the date of the Individual.

Parameters
dateThe date as a Date object.

Definition at line 176 of file Individual.cpp.

References date_.

Referenced by Individual(), operator=(), and bpp::PopgenlibIO::parseIndividual_().

◆ setGenotype()

void Individual::setGenotype ( const MultilocusGenotype genotype)

Set a genotype.

Parameters
genotypeThe MultilocusGenotype which will be copied.

Definition at line 488 of file Individual.cpp.

References genotype_.

◆ setId()

void Individual::setId ( const std::string &  id)

Set the id of the Individual.

Parameters
idThe id of the Individual as a string.

Definition at line 160 of file Individual.cpp.

References id_.

Referenced by operator=(), and bpp::PopgenlibIO::parseIndividual_().

◆ setLocality()

void Individual::setLocality ( const Locality< double > *  locality)

Set the locality of the Individual.

Parameters
localityA pointer to a Locality object.

Definition at line 273 of file Individual.cpp.

References locality_.

Referenced by Individual(), operator=(), and bpp::PopgenlibIO::parseIndividual_().

◆ setMonolocusGenotype()

void Individual::setMonolocusGenotype ( size_t  locus_position,
const MonolocusGenotype monogen 
)
throw (Exception
)

Set a MonolocusGenotype.

Exceptions
NullPointerExceptionif there is no genotype defined.
IndexOutOfBoundsExceptionif locus_position excedes the number of loci.

Definition at line 534 of file Individual.cpp.

◆ setMonolocusGenotypeByAlleleId()

void Individual::setMonolocusGenotypeByAlleleId ( size_t  locus_position,
const std::vector< std::string >  allele_id,
const LocusInfo locus_info 
)
throw (Exception
)

Set a MonolocusGenotype.

Exceptions
NullPointerExceptionif there is no genotype defined.
IndexOutOfBoundsExceptionif locus_position excedes the number of loci.
AlleleNotFoundExceptionif at least one the id is not found in the LocusInfo.

Definition at line 570 of file Individual.cpp.

References bpp::AlleleNotFoundException::getIdentifier().

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

◆ setMonolocusGenotypeByAlleleKey()

void Individual::setMonolocusGenotypeByAlleleKey ( size_t  locus_position,
const std::vector< size_t >  allele_keys 
)
throw (Exception
)

Set a MonolocusGenotype.

Exceptions
NullPointerExceptionif there is no genotype defined.
IndexOutOfBoundsExceptionif locus_position excedes the number of loci.
Exceptionif there is no key in allele_keys.

Definition at line 550 of file Individual.cpp.

◆ setSequences()

void Individual::setSequences ( const MapSequenceContainer &  msc)

Set all the sequences with a MapSequenceContainer.

Definition at line 470 of file Individual.cpp.

References sequences_.

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

◆ setSex()

void Individual::setSex ( const unsigned short  sex)

Set the sex of the Individual.

Parameters
sexAn unsigned short coding for the sex.

Definition at line 168 of file Individual.cpp.

References sex_.

Referenced by operator=().

◆ setX()

void Individual::setX ( const double  x)
throw (NullPointerException
)

Set the X coordinate of the Individual.

Parameters
xThe X coordinate as a double.

Set the X coordinate if the Individual has coordinates. Otherwise throw a NullPointerException.

Definition at line 232 of file Individual.cpp.

◆ setY()

void Individual::setY ( const double  y)
throw (NullPointerException
)

Set the Y coordinate of th Individual.

Parameters
yThe Y coordinate as a double.

Set the Y coordinate if the Individual has coordinates. Otherwise throw a NullPointerException.

Definition at line 242 of file Individual.cpp.

Member Data Documentation

◆ coord_

std::auto_ptr< Point2D<double> > bpp::Individual::coord_
protected

Definition at line 81 of file Individual.h.

Referenced by getCoord(), getX(), getY(), hasCoord(), operator=(), and setCoord().

◆ date_

std::auto_ptr<Date> bpp::Individual::date_
protected

Definition at line 80 of file Individual.h.

Referenced by getDate(), hasDate(), operator=(), and setDate().

◆ genotype_

std::auto_ptr<MultilocusGenotype> bpp::Individual::genotype_
protected

◆ id_

std::string bpp::Individual::id_
protected

Definition at line 78 of file Individual.h.

Referenced by getId(), and setId().

◆ locality_

const Locality<double>* bpp::Individual::locality_
protected

Definition at line 82 of file Individual.h.

Referenced by getLocality(), hasLocality(), operator=(), and setLocality().

◆ sequences_

std::auto_ptr<MapSequenceContainer> bpp::Individual::sequences_
protected

◆ sex_

unsigned short bpp::Individual::sex_
protected

Definition at line 79 of file Individual.h.

Referenced by getSex(), and setSex().


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