bpp-popgen
3.0.0
|
The Individual class. More...
#include <Bpp/PopGen/DataSet/Individual.h>
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... | |
Individual & | operator= (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 Date & | getDate () const |
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 |
Get the coordinates of the Induvidual. More... | |
bool | hasCoord () const |
Tell if this Individual has coordinates. More... | |
void | setX (const double x) |
Set the X coordinate of the Individual. More... | |
void | setY (const double y) |
Set the Y coordinate of th Individual. More... | |
double | getX () const |
Get the X coordinate of the Individual. More... | |
double | getY () const |
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 |
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) |
Add a sequence to the Individual. More... | |
const Sequence & | getSequenceByName (const std::string &sequence_name) const |
Get a sequence by its name. More... | |
const Sequence & | getSequenceAtPosition (const size_t sequence_position) const |
Get a sequence by its position. More... | |
void | deleteSequenceByName (const std::string &sequence_name) |
Delete a sequence. More... | |
void | deleteSequenceAtPosition (size_t sequence_position) |
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 |
Return the alphabet of the sequences. More... | |
std::vector< std::string > | getSequencesNames () const |
Get the sequences' names. More... | |
std::vector< size_t > | getSequencesPositions () const |
Get the sequences' positions. More... | |
size_t | getSequencePosition (const std::string &sequence_name) const |
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 |
Get a reference to the sequence container. More... | |
void | setGenotype (const MultilocusGenotype &genotype) |
Set a genotype. More... | |
void | initGenotype (size_t loci_number) |
Init the genotype. More... | |
const MultilocusGenotype & | getGenotype () const |
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) |
Set a MonolocusGenotype. More... | |
void | setMonolocusGenotypeByAlleleKey (size_t locus_position, const std::vector< size_t > allele_keys) |
Set a MonolocusGenotype. More... | |
void | setMonolocusGenotypeByAlleleId (size_t locus_position, const std::vector< std::string > allele_id, const LocusInfo &locus_info) |
Set a MonolocusGenotype. More... | |
const MonolocusGenotype & | getMonolocusGenotype (size_t locus_position) |
Get a MonolocusGenotype. More... | |
size_t | countNonMissingLoci () const |
Count the number of non missing MonolocusGenotype. More... | |
size_t | countHomozygousLoci () const |
Count the number of homozygous MonolocusGenotype. More... | |
size_t | countHeterozygousLoci () const |
Count the number of heterozygous MonolocusGenotype. More... | |
Protected Attributes | |
std::string | id_ |
unsigned short | sex_ |
std::unique_ptr< Date > | date_ |
std::unique_ptr< Point2D< double > > | coord_ |
const Locality< double > * | locality_ |
std::unique_ptr< MapSequenceContainer > | sequences_ |
std::unique_ptr< MultilocusGenotype > | genotype_ |
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.
Definition at line 75 of file Individual.h.
Individual::Individual | ( | ) |
Build a void new Individual.
Definition at line 47 of file Individual.cpp.
Individual::Individual | ( | const std::string & | id | ) |
Build a new Individual with an identifier.
Definition at line 55 of file Individual.cpp.
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.
id | The id of the Individual as a string. |
date | The date of the Individual as a Date object. |
coord | The coordinates of the Individual as a Point2D object. |
locality | The locality of the Individual as a pointer to a Locality object. |
sex | The sex of the Individual as an unsigned short. |
Definition at line 63 of file Individual.cpp.
Individual::Individual | ( | const Individual & | ind | ) |
The Individual copy constructor.
Definition at line 76 of file Individual.cpp.
References genotype_, getCoord(), getDate(), getGenotype(), getLocality(), getSequences(), hasGenotype(), setCoord(), setDate(), setLocality(), and setSequences().
|
virtual |
Destroy an Individual.
Definition at line 113 of file Individual.cpp.
void Individual::addSequence | ( | size_t | sequence_key, |
const Sequence & | sequence | ||
) |
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.
sequence_key | the place where the sequence will be put. |
sequence | The sequence to add. |
AlphabetMismatchException | if the sequence's alphabet doesn't match the container's alphabet. |
BadIdentifierException | if sequence's name is already in use. |
BadIntegerException | if sequence_position is already in use. |
Definition at line 298 of file Individual.cpp.
References bpp::Sequence::getAlphabet(), bpp::AlphabetMismatchException::getAlphabets(), bpp::Sequence::getName(), sequences_, bpp::TextTools::toString(), and bpp::Exception::what().
Referenced by bpp::PopgenlibIO::parseIndividual_().
size_t Individual::countHeterozygousLoci | ( | ) | const |
Count the number of heterozygous MonolocusGenotype.
NullPointerException | if there is no genotype defined. |
Definition at line 621 of file Individual.cpp.
References genotype_, and hasGenotype().
size_t Individual::countHomozygousLoci | ( | ) | const |
Count the number of homozygous MonolocusGenotype.
NullPointerException | if there is no genotype defined. |
Definition at line 612 of file Individual.cpp.
References genotype_, and hasGenotype().
size_t Individual::countNonMissingLoci | ( | ) | const |
Count the number of non missing MonolocusGenotype.
NullPointerException | if there is no genotype defined. |
Definition at line 603 of file Individual.cpp.
References genotype_, and hasGenotype().
void Individual::deleteGenotype | ( | ) |
Delete the genotype of the individual.
Definition at line 517 of file Individual.cpp.
References genotype_.
void Individual::deleteSequenceAtPosition | ( | size_t | sequence_position | ) |
Delete a sequence.
sequence_position | The position of the sequence. |
NullPointerException | if there is no sequence container defined. |
SequenceNotFoundException | if sequence_postion is not found. |
Definition at line 370 of file Individual.cpp.
References bpp::SequenceNotFoundException::getSequenceId(), sequences_, and bpp::TextTools::toString().
void Individual::deleteSequenceByName | ( | const std::string & | sequence_name | ) |
Delete a sequence.
sequence_name | The name of the sequence. |
NullPointerException | if there is no sequence container defined. |
SequenceNotFoundException | if sequence_name is not found. |
Definition at line 354 of file Individual.cpp.
References bpp::SequenceNotFoundException::getSequenceId(), and sequences_.
const Point2D< double > & Individual::getCoord | ( | ) | const |
Get the coordinates of the Induvidual.
Definition at line 215 of file Individual.cpp.
References coord_, and hasCoord().
Referenced by Individual(), and operator=().
const Date & Individual::getDate | ( | ) | const |
Get the date of the Individual.
Definition at line 183 of file Individual.cpp.
References date_, and hasDate().
Referenced by Individual(), operator=(), and bpp::PopgenlibIO::write().
const MultilocusGenotype & Individual::getGenotype | ( | ) | const |
Get the genotype.
Definition at line 508 of file Individual.cpp.
References genotype_, and hasGenotype().
Referenced by bpp::DataSet::getPolymorphismMultiGContainer(), Individual(), operator=(), bpp::DarwinVarSingle::write(), and bpp::PopgenlibIO::write().
|
inline |
Get the id of the Individual.
Definition at line 146 of file Individual.h.
References id_.
Referenced by bpp::Group::addIndividual(), operator=(), bpp::PopgenlibIO::parseIndividual_(), bpp::DarwinDon::write(), and bpp::PopgenlibIO::write().
const Locality< double > * Individual::getLocality | ( | ) | const |
Get 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().
const MonolocusGenotype & Individual::getMonolocusGenotype | ( | size_t | locus_position | ) |
Get a MonolocusGenotype.
NullPointerException | if there is no genotype defined. |
IndexOutOfBoundsException | if locus_position excedes the number of loci. |
Definition at line 587 of file Individual.cpp.
References genotype_, bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), and hasGenotype().
size_t Individual::getNumberOfSequences | ( | ) | const |
Get the number of sequences.
Definition at line 458 of file Individual.cpp.
References sequences_.
Referenced by hasSequences(), and bpp::PopgenlibIO::write().
const Alphabet * Individual::getSequenceAlphabet | ( | ) | const |
Return the alphabet of the sequences.
NullPointerException | if there is no sequence container defined. |
Definition at line 449 of file Individual.cpp.
References sequences_.
Referenced by bpp::DataSet::addIndividualToGroup().
const Sequence & Individual::getSequenceAtPosition | ( | const size_t | sequence_position | ) | const |
Get a sequence by its position.
sequence_position | The position of the sequence in the sequence set. |
NullPointerException | if there is no sequence container defined. |
SequenceNotFoundException | if sequence_position is not found (i.e. missing data or not used). |
Definition at line 338 of file Individual.cpp.
References bpp::SequenceNotFoundException::getSequenceId(), sequences_, and bpp::TextTools::toString().
Referenced by bpp::DataSet::getPolymorphismSequenceContainer(), and bpp::PopgenlibIO::write().
const Sequence & Individual::getSequenceByName | ( | const std::string & | sequence_name | ) | const |
Get a sequence by its name.
sequence_name | The name of the sequence. |
NullPointerException | if there is no sequence container defined. |
SequenceNotFoundException | if sequence_name is not found. |
Definition at line 322 of file Individual.cpp.
References bpp::SequenceNotFoundException::getSequenceId(), and sequences_.
size_t Individual::getSequencePosition | ( | const std::string & | sequence_name | ) | const |
Get the position of a sequence.
NullPointerException | if there is no sequence container defined. |
SequenceNotFoundException | if sequence_name is not found. |
Definition at line 410 of file Individual.cpp.
References bpp::SequenceNotFoundException::getSequenceId(), sequences_, and bpp::TextTools::toInt().
const OrderedSequenceContainer & Individual::getSequences | ( | ) | const |
Get a reference to the sequence container.
NullPointerException | if there is no sequence container defined. |
Definition at line 474 of file Individual.cpp.
References sequences_.
Referenced by Individual(), operator=(), and bpp::PopgenlibIO::write().
std::vector< std::string > Individual::getSequencesNames | ( | ) | const |
Get the sequences' names.
NullPointerException | if there is no sequence container defined. |
Definition at line 386 of file Individual.cpp.
References sequences_.
std::vector< size_t > Individual::getSequencesPositions | ( | ) | const |
Get the sequences' positions.
NullPointerException | if there is no sequence container defined. |
Definition at line 395 of file Individual.cpp.
References sequences_, and bpp::TextTools::toInt().
Referenced by hasSequenceAtPosition().
|
inline |
Get the sex of the Individual.
Definition at line 160 of file Individual.h.
References sex_.
Referenced by operator=().
double Individual::getX | ( | ) | const |
Get the X coordinate of the Individual.
Definition at line 252 of file Individual.cpp.
References coord_, and hasCoord().
Referenced by bpp::PopgenlibIO::write().
double Individual::getY | ( | ) | const |
Get the Y coordinate of the Individual.
Definition at line 262 of file Individual.cpp.
References coord_, and hasCoord().
Referenced by bpp::PopgenlibIO::write().
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(), setX(), setY(), and bpp::PopgenlibIO::write().
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().
bool Individual::hasGenotype | ( | ) | const |
Tell if the Individual has a MultilocusGenotype.
Definition at line 524 of file Individual.cpp.
References genotype_.
Referenced by countHeterozygousLoci(), countHomozygousLoci(), countNonMissingLoci(), getGenotype(), getMonolocusGenotype(), bpp::DataSet::getPolymorphismMultiGContainer(), Individual(), initGenotype(), operator=(), setMonolocusGenotype(), setMonolocusGenotypeByAlleleId(), setMonolocusGenotypeByAlleleKey(), and bpp::PopgenlibIO::write().
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().
bool Individual::hasSequenceAtPosition | ( | size_t | position | ) | const |
Tell if the Individual has a sequence at a given position.
Definition at line 433 of file Individual.cpp.
References getSequencesPositions(), and hasSequences().
Referenced by bpp::DataSet::getPolymorphismSequenceContainer().
bool Individual::hasSequences | ( | ) | const |
Tell if the Individual has some sequences.
Definition at line 426 of file Individual.cpp.
References getNumberOfSequences().
Referenced by bpp::DataSet::addIndividualToGroup(), hasSequenceAtPosition(), and bpp::PopgenlibIO::write().
void Individual::initGenotype | ( | size_t | loci_number | ) |
Init the genotype.
Exception | if the Individual already has a Genotype. |
BadIntegerException | if loci_number < 1. |
Definition at line 492 of file Individual.cpp.
References genotype_, bpp::BadIntegerException::getBadInteger(), and hasGenotype().
Referenced by bpp::PopgenlibIO::parseIndividual_().
Individual & Individual::operator= | ( | const Individual & | ind | ) |
The Individual copy operator.
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().
void Individual::setCoord | ( | const double | x, |
const double | y | ||
) |
Set the coordinates of the Individual.
x | The X coordinate as a double. |
y | The Y coordinate as a double. |
Definition at line 208 of file Individual.cpp.
References coord_.
void Individual::setCoord | ( | const Point2D< double > & | coord | ) |
Set the coodinates of the Individual.
coord | A Point2D object. |
Definition at line 201 of file Individual.cpp.
References coord_.
Referenced by Individual(), operator=(), and bpp::PopgenlibIO::parseIndividual_().
void Individual::setDate | ( | const Date & | date | ) |
Set the date of the Individual.
date | The date as a Date object. |
Definition at line 176 of file Individual.cpp.
References date_.
Referenced by Individual(), operator=(), and bpp::PopgenlibIO::parseIndividual_().
void Individual::setGenotype | ( | const MultilocusGenotype & | genotype | ) |
Set a genotype.
genotype | The MultilocusGenotype which will be copied. |
Definition at line 485 of file Individual.cpp.
References genotype_.
void Individual::setId | ( | const std::string & | id | ) |
Set the id of the Individual.
id | The id of the Individual as a string. |
Definition at line 160 of file Individual.cpp.
References id_.
Referenced by operator=(), and bpp::PopgenlibIO::parseIndividual_().
void Individual::setLocality | ( | const Locality< double > * | locality | ) |
Set the locality of the Individual.
locality | A pointer to a Locality object. |
Definition at line 273 of file Individual.cpp.
References locality_.
Referenced by Individual(), operator=(), and bpp::PopgenlibIO::parseIndividual_().
void Individual::setMonolocusGenotype | ( | size_t | locus_position, |
const MonolocusGenotype & | monogen | ||
) |
Set a MonolocusGenotype.
NullPointerException | if there is no genotype defined. |
IndexOutOfBoundsException | if locus_position excedes the number of loci. |
Definition at line 531 of file Individual.cpp.
References genotype_, bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), and hasGenotype().
void Individual::setMonolocusGenotypeByAlleleId | ( | size_t | locus_position, |
const std::vector< std::string > | allele_id, | ||
const LocusInfo & | locus_info | ||
) |
Set a MonolocusGenotype.
NullPointerException | if there is no genotype defined. |
IndexOutOfBoundsException | if locus_position excedes the number of loci. |
AlleleNotFoundException | if at least one the id is not found in the LocusInfo. |
Definition at line 567 of file Individual.cpp.
References genotype_, bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), bpp::AlleleNotFoundException::getIdentifier(), and hasGenotype().
Referenced by bpp::PopgenlibIO::parseIndividual_().
void Individual::setMonolocusGenotypeByAlleleKey | ( | size_t | locus_position, |
const std::vector< size_t > | allele_keys | ||
) |
Set a MonolocusGenotype.
NullPointerException | if there is no genotype defined. |
IndexOutOfBoundsException | if locus_position excedes the number of loci. |
Exception | if there is no key in allele_keys. |
Definition at line 547 of file Individual.cpp.
References genotype_, bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), and hasGenotype().
void Individual::setSequences | ( | const MapSequenceContainer & | msc | ) |
Set all the sequences with a MapSequenceContainer.
Definition at line 467 of file Individual.cpp.
References sequences_.
Referenced by Individual(), and operator=().
void Individual::setSex | ( | const unsigned short | sex | ) |
Set the sex of the Individual.
sex | An unsigned short coding for the sex. |
Definition at line 168 of file Individual.cpp.
References sex_.
Referenced by operator=().
void Individual::setX | ( | const double | x | ) |
Set the X coordinate of the Individual.
x | The 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.
References coord_, and hasCoord().
void Individual::setY | ( | const double | y | ) |
Set the Y coordinate of th Individual.
y | The 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.
References coord_, and hasCoord().
|
protected |
Definition at line 81 of file Individual.h.
Referenced by getCoord(), getX(), getY(), hasCoord(), operator=(), setCoord(), setX(), and setY().
|
protected |
Definition at line 80 of file Individual.h.
Referenced by getDate(), hasDate(), operator=(), and setDate().
|
protected |
Definition at line 84 of file Individual.h.
Referenced by countHeterozygousLoci(), countHomozygousLoci(), countNonMissingLoci(), deleteGenotype(), getGenotype(), getMonolocusGenotype(), hasGenotype(), Individual(), initGenotype(), operator=(), setGenotype(), setMonolocusGenotype(), setMonolocusGenotypeByAlleleId(), and setMonolocusGenotypeByAlleleKey().
|
protected |
Definition at line 78 of file Individual.h.
|
protected |
Definition at line 82 of file Individual.h.
Referenced by getLocality(), hasLocality(), operator=(), and setLocality().
|
protected |
Definition at line 83 of file Individual.h.
Referenced by addSequence(), deleteSequenceAtPosition(), deleteSequenceByName(), getNumberOfSequences(), getSequenceAlphabet(), getSequenceAtPosition(), getSequenceByName(), getSequencePosition(), getSequences(), getSequencesNames(), getSequencesPositions(), operator=(), and setSequences().
|
protected |
Definition at line 79 of file Individual.h.