33 const unsigned short sex) :
36 date_(new
Date(date)),
37 coord_(new
Point2D<double>(coord)),
47 locality_(ind.locality_),
156 return date_ !=
nullptr;
238 throw (
NullPointerException(
"Individual::getLocality: no locality associated to this individual."));
248 throw (
NullPointerException(
"Individual::locality: no locality associated to this individual."));
257 sequences_ = make_unique<VectorSequenceContainer>(sequence->getAlphabet());
268 if (
string(e.
what()).find(
"name") <
string(e.
what()).size())
269 throw (
BadIdentifierException(
"Individual::addSequence: sequence's name already in use.", sequence->getName()));
348 vector<size_t> seqpos;
349 vector<string> seqkeys =
sequences_->getSequenceKeys();
350 for (
size_t i = 0; i < seqkeys.size(); i++)
387 for (
size_t i = 0; i < pos.size(); ++i)
389 if (pos[i] == position)
428 throw Exception(
"Individual::initGenotype: individual already has a genotype.");
465 size_t locusPosition,
472 genotype_->setMonolocusGenotype(locusPosition, monogen);
485 throw NullPointerException(
"Individual::setMonolocusGenotypeByAlleleKey: individual has no genotype.");
488 genotype_->setMonolocusGenotypeByAlleleKey(locus_position, allele_keys);
496 throw Exception(
"Individual::setMonolocusGenotypeByAlleleKey: no key in allele_keys.");
505 throw NullPointerException(
"Individual::setMonolocusGenotypeByAlleleId: individual has no genotype.");
508 genotype_->setMonolocusGenotypeByAlleleId(locus_position, allele_id, locus_info);
528 return genotype_->monolocusGenotype(locusPosition);
560 return genotype_->countHeterozygousLoci();
The AlleleNotFoundException class.
virtual const std::string getIdentifier() const
Return the value of the identifier as a string.
const Alphabet * getSecondAlphabet() const
const Alphabet * getFirstAlphabet() const
The BadIdentifierException class.
int getBadInteger() const
const char * what() const noexcept override
std::size_t getBadIndex() const
const std::array< std::size_t, 2 > & getBounds() const
double getY() const
Get the Y coordinate of the Individual.
const MonolocusGenotypeInterface & getMonolocusGenotype(size_t locusPosition)
Get a MonolocusGenotype.
bool hasCoord() const
Tell if this Individual has coordinates.
std::shared_ptr< const Alphabet > getSequenceAlphabet() const
Return the alphabet of the sequences.
size_t getNumberOfSequences() const
Get the number of sequences.
bool hasSequences() const
Tell if the Individual has some sequences.
virtual ~Individual()
Destroy an Individual.
const Sequence & sequenceByName(const std::string &sequenceName) const
Get a sequence from its name.
Individual()
Build a void new Individual.
unsigned short getSex() const
Get the sex of the Individual.
const Locality< double > & locality() const
Get the locality of the Individual.
void setSex(const unsigned short sex)
Set the sex of the Individual.
std::unique_ptr< Date > date_
size_t getSequencePosition(const std::string &sequenceKey) const
Get the position of a sequence.
size_t countNonMissingLoci() const
Count the number of non missing MonolocusGenotype.
void addSequence(size_t sequenceKey, std::unique_ptr< Sequence > &sequence)
Add a sequence to the Individual.
void setGenotype(const MultilocusGenotype &genotype)
Set a genotype.
void setMonolocusGenotype(size_t locusPosition, const MonolocusGenotypeInterface &monogen)
Set a MonolocusGenotype.
void deleteSequenceAtPosition(size_t sequencePosition)
Delete a sequence.
const std::string & getId() const
Get the id of the Individual.
std::unique_ptr< VectorSequenceContainer > sequences_
void setCoord(const Point2D< double > &coord)
Set the coordinates of the Individual.
void setY(const double y)
Set the Y coordinate of th Individual.
std::shared_ptr< const Locality< double > > getLocality() const
Get the locality of the Individual.
void setId(const std::string &id)
Set the id of the Individual.
void setLocality(std::shared_ptr< const Locality< double >> locality)
Set the locality of the Individual.
bool hasGenotype() const
Tell if the Individual has a MultilocusGenotype.
Individual & operator=(const Individual &ind)
The Individual copy operator.
void deleteSequenceByName(const std::string &sequenceName)
Delete a sequence.
void setMonolocusGenotypeByAlleleKey(size_t locusPosition, const std::vector< size_t > alleleKeys)
Set a MonolocusGenotype.
void setDate(const Date &date)
Set the date of the Individual.
void initGenotype(size_t lociNumber)
Init the genotype.
const MultilocusGenotype & getGenotype() const
Get the genotype.
bool hasLocality() const
Tell if this Individual has a locality.
std::vector< size_t > getSequencePositions() const
Get the sequences' positions.
bool hasSequenceAtPosition(size_t position) const
Tell if the Individual has a sequence at a given position.
size_t countHomozygousLoci() const
Count the number of homozygous MonolocusGenotype.
void setX(const double x)
Set the X coordinate of the Individual.
const Point2D< double > & coord() const
Get the coordinates of the Induvidual.
bool hasDate() const
Tell if this Individual has a date.
const SequenceContainerInterface & sequences() const
Get a reference to the sequence container.
std::unique_ptr< Point2D< double > > coord_
const Sequence & sequenceAtPosition(size_t sequencePosition) const
Get a sequence by its position.
void deleteGenotype()
Delete the genotype of the individual.
std::unique_ptr< MultilocusGenotype > genotype_
std::shared_ptr< const Locality< double > > locality_
void setMonolocusGenotypeByAlleleId(size_t locusPosition, const std::vector< std::string > alleleId, const LocusInfo &locusInfo)
Set a MonolocusGenotype.
size_t countHeterozygousLoci() const
Count the number of heterozygous MonolocusGenotype.
double getX() const
Get the X coordinate of the Individual.
const Date & date() const
Get the date of the Individual.
void setSequences(const SequenceContainerInterface &sc)
Set all the sequences with a SequenceContainer. The container will be copied.
const Alphabet & sequenceAlphabet() const
Return the alphabet of the sequences.
The MonolocusGenotype virtual class.
The MultilocusGenotype class.
virtual const std::string getSequenceId() const
int toInt(const std::string &s, char scientificNotation='e')
std::string toString(T t)