bpp-popgen  3.0.0
bpp::DataSet Class Reference

The DataSet class. More...

#include <Bpp/PopGen/DataSet/DataSet.h>

+ Collaboration diagram for bpp::DataSet:

Public Member Functions

 DataSet ()
 Build a new void DataSet. More...
 
 ~DataSet ()
 Destroy a DataSet. More...
 
 DataSet (const DataSet &ds)
 Copy constructor. More...
 
DataSetoperator= (const DataSet &ds)
 
void addLocality (Locality< double > &locality)
 Add a locality to the DataSet. More...
 
size_t getLocalityPosition (const std::string &name) const
 Get the position of a locality in the container. More...
 
const Locality< double > & getLocalityAtPosition (size_t locality_position) const
 Get a Locality by locality_position. More...
 
const Locality< double > & getLocalityByName (const std::string &name) const
 Get a Locality by name. More...
 
void deleteLocalityAtPosition (size_t locality_position)
 Delete a Locality from the DataSet. More...
 
void deleteLocalityByName (const std::string &name)
 Delete a Locality from the DataSet. More...
 
size_t getNumberOfLocalities () const
 Get the number of Localities. More...
 
bool hasLocality () const
 Tell if there is at least one locality. More...
 
void addGroup (const Group &group)
 Add a Group to the DataSet. More...
 
void addEmptyGroup (size_t group_id)
 Add an empty Group to the DataSet. More...
 
const GroupgetGroupById (size_t group_id) const
 Get a group by identifier. More...
 
size_t getGroupPosition (size_t group_id) const
 Get the position of a Group. More...
 
std::string getGroupName (size_t group_id) const
 Get the name of a Group. If the name is an empty string it just returns the group_id. More...
 
void setGroupName (size_t group_id, const std::string &group_name) const
 set the name of a Group. More...
 
const GroupgetGroupAtPosition (size_t group_position) const
 Get a group by position. More...
 
void deleteGroupAtPosition (size_t group_position)
 Delete a Group from the DataSet. More...
 
size_t getNumberOfGroups () const
 Get the number of Groups. More...
 
void mergeTwoGroups (size_t source_id, size_t target_id)
 Merge two groups. More...
 
void mergeGroups (std::vector< size_t > &group_ids)
 Merge some Groups in one. More...
 
void splitGroup (size_t group_id, std::vector< size_t > individuals_selection)
 Split a group in two. More...
 
void addIndividualToGroup (size_t group_position, const Individual &individual)
 Add an Individual to a Group. More...
 
void addEmptyIndividualToGroup (size_t group_position, const std::string &individual_id)
 Add an empty Individual to a Group. More...
 
size_t getNumberOfIndividualsInGroup (size_t group_position) const
 Get the number of Individuals in a Group. More...
 
size_t getIndividualPositionInGroup (size_t group_position, const std::string &individual_id) const
 Get the position of an Individual in a Group. More...
 
const IndividualgetIndividualAtPositionFromGroup (size_t group_position, size_t individual_position) const
 Get an Individual from a Group. More...
 
const IndividualgetIndividualByIdFromGroup (size_t group_position, const std::string &individual_id) const
 Get an Individual from a Group. More...
 
void deleteIndividualAtPositionFromGroup (size_t group_position, size_t individual_position)
 Delete an Individual from a group. More...
 
void deleteIndividualByIdFromGroup (size_t group_position, const std::string &individual_id)
 Delete an Individual from a group. More...
 
void setIndividualSexInGroup (size_t group_position, size_t individual_position, const unsigned short sex)
 Set the sex of an Individual in a Group. More...
 
unsigned short getIndividualSexInGroup (size_t group_position, size_t individual_position) const
 Get the sex of an Individual in a Group. More...
 
void setIndividualDateInGroup (size_t group_position, size_t individual_position, const Date &date)
 Set the Date of an Individual in a Group. More...
 
const DategetIndividualDateInGroup (size_t group_position, size_t individual_position) const
 Get the Date of an Individual in a Group. More...
 
void setIndividualCoordInGroup (size_t group_position, size_t individual_position, const Point2D< double > &coord)
 Set the coordinates of an Individual in a Group. More...
 
const Point2D< double > * getIndividualCoordInGroup (size_t group_position, size_t individual_position) const
 Get the coordinate of an Individual in a Group. More...
 
void setIndividualLocalityInGroupByName (size_t group_position, size_t individual_position, const std::string &locality_name)
 Set the Locality of an Individual in a Group. More...
 
const Locality< double > * getIndividualLocalityInGroup (size_t group_position, size_t individual_position) const
 Get the Locality of an Individual in a Group. More...
 
void addIndividualSequenceInGroup (size_t group_position, size_t individual_position, size_t sequence_position, const Sequence &sequence)
 Add a Sequence to an Individual in a Group. More...
 
const SequencegetIndividualSequenceByNameInGroup (size_t group_position, size_t individual_position, const std::string &sequence_name) const
 Get a Sequence from an Individual of a Group. More...
 
const SequencegetIndividualSequenceAtPositionInGroup (size_t group_position, size_t individual_position, size_t sequence_position) const
 Get a Sequence from an Individual of a Group. More...
 
void deleteIndividualSequenceByNameInGroup (size_t group_position, size_t individual_position, const std::string &sequence_name)
 Delete a Sequence of an Individual of a Group. More...
 
void deleteIndividualSequenceAtPositionInGroup (size_t group_position, size_t individual_position, size_t sequence_position)
 Delete a Sequence of an Individual of a Group. More...
 
std::vector< std::string > getIndividualSequencesNamesInGroup (size_t group_position, size_t individual_position) const
 Get the Sequences' names from an Individual of a Group. More...
 
size_t getIndividualSequencePositionInGroup (size_t group_position, size_t individual_position, const std::string &sequence_name) const
 Get the position of a Sequence in an Individual of a Group. More...
 
size_t getIndividualNumberOfSequencesInGroup (size_t group_position, size_t individual_position) const
 Get the number of Sequences in an Individual of a Group. More...
 
void setIndividualGenotypeInGroup (size_t group_position, size_t individual_position, const MultilocusGenotype &genotype)
 Set the MultilocusGenotype of an Individual in a Group. More...
 
void initIndividualGenotypeInGroup (size_t group_position, size_t individual_position)
 Initialyze the genotype of an Individual in a Group. More...
 
void deleteIndividualGenotypeInGroup (size_t group_position, size_t individual_position)
 Delete the MultilocusGenotype of an Individual from a Group. More...
 
void setIndividualMonolocusGenotypeInGroup (size_t group_position, size_t individual_position, size_t locus_position, const MonolocusGenotype &monogen)
 Set a MonolocusGenotype of an Individual from a group. More...
 
void setIndividualMonolocusGenotypeByAlleleKeyInGroup (size_t group_position, size_t individual_position, size_t locus_position, const std::vector< size_t > allele_keys)
 Set a MonolocusGenotype of an Individual from a group. More...
 
void setIndividualMonolocusGenotypeByAlleleIdInGroup (size_t group_position, size_t individual_position, size_t locus_position, const std::vector< std::string > allele_id)
 Set a MonolocusGenotype of an Individual from a group. More...
 
const MonolocusGenotypegetIndividualMonolocusGenotypeInGroup (size_t group_position, size_t individual_position, size_t locus_position) const
 Get a MonolocusGenotype from an Individual of a Group. More...
 
void setAlphabet (const Alphabet *alpha)
 Set the alphabet of the AnalyzedSequences. More...
 
void setAlphabet (const std::string &alpha_type)
 Set the alphabet of the AnalyzedSequences by its type.. More...
 
const AlphabetgetAlphabet () const
 Get the alphabet if there is sequence data. More...
 
std::string getAlphabetType () const
 Get the alphabet type as a string. More...
 
void setAnalyzedLoci (const AnalyzedLoci &analyzedLoci)
 Set the AnalyzedLoci to the DataSet. More...
 
void initAnalyzedLoci (size_t number_of_loci)
 Initialize the AnalyzedLoci for number of loci. More...
 
const AnalyzedLocigetAnalyzedLoci () const
 Get the AnalyzedLoci if there is one. More...
 
void deleteAnalyzedLoci ()
 Delete the AnalyzedLoci. More...
 
void setLocusInfo (size_t locus_position, const LocusInfo &locus)
 Set a LocusInfo. More...
 
const LocusInfogetLocusInfoByName (const std::string &locus_name) const
 Get a LocusInfo by its name. More...
 
const LocusInfogetLocusInfoAtPosition (size_t locus_position) const
 Get a LocusInfo by its position. More...
 
void addAlleleInfoByLocusName (const std::string &locus_name, const AlleleInfo &allele)
 Add an AlleleInfo to a LocusInfo. More...
 
void addAlleleInfoByLocusPosition (size_t locus_position, const AlleleInfo &allele)
 Add an AlleleInfo to a LocusInfo. More...
 
size_t getNumberOfLoci () const
 Get the number of loci. More...
 
size_t getPloidyByLocusName (const std::string &locus_name) const
 Get the ploidy of a locus. More...
 
size_t getPloidyByLocusPosition (size_t locus_position) const
 Get the ploidy of a locus. More...
 
PolymorphismMultiGContainergetPolymorphismMultiGContainer () const
 Get a PolymorphismMultiGContainer with all allelic data of the DataSet. More...
 
PolymorphismMultiGContainergetPolymorphismMultiGContainer (const std::map< size_t, std::vector< size_t > > &selection) const
 Get a PolymorphismMultiGContainer from a selection of groups and individuals. More...
 
PolymorphismSequenceContainergetPolymorphismSequenceContainer (const std::map< size_t, std::vector< size_t > > &selection, size_t sequence_position) const
 Get a PolymorphismSequenceContainer from a selection of groups and individuals. More...
 
bool hasSequenceData () const
 Tell if at least one individual has at least one sequence. More...
 
bool hasAlleleicData () const
 Tell if there is alelelic data. More...
 

Private Attributes

AnalyzedLocianalyzedLoci_
 
AnalyzedSequencesanalyzedSequences_
 
std::vector< Locality< double > * > localities_
 
std::vector< Group * > groups_
 

Detailed Description

The DataSet class.

A DataSet the object that manage every data on which one can compute some statistics.

Author
Sylvain Gaillard

Definition at line 72 of file DataSet.h.

Constructor & Destructor Documentation

◆ DataSet() [1/2]

DataSet::DataSet ( )

Build a new void DataSet.

Definition at line 48 of file DataSet.cpp.

◆ ~DataSet()

DataSet::~DataSet ( )

◆ DataSet() [2/2]

DataSet::DataSet ( const DataSet ds)

Copy constructor.

Definition at line 55 of file DataSet.cpp.

References analyzedLoci_, analyzedSequences_, groups_, and localities_.

Member Function Documentation

◆ addAlleleInfoByLocusName()

void DataSet::addAlleleInfoByLocusName ( const std::string &  locus_name,
const AlleleInfo allele 
)

◆ addAlleleInfoByLocusPosition()

void DataSet::addAlleleInfoByLocusPosition ( size_t  locus_position,
const AlleleInfo allele 
)

◆ addEmptyGroup()

void DataSet::addEmptyGroup ( size_t  group_id)

◆ addEmptyIndividualToGroup()

void DataSet::addEmptyIndividualToGroup ( size_t  group_position,
const std::string &  individual_id 
)

Add an empty Individual to a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
BadIdentifierExceptionif the individual's id is already in use.

Definition at line 423 of file DataSet.cpp.

References bpp::BadIdentifierException::getIdentifier(), getNumberOfGroups(), and groups_.

Referenced by bpp::Genepop::read(), and bpp::Genetix::read().

◆ addGroup()

void DataSet::addGroup ( const Group group)

Add a Group to the DataSet.

Add a Group to the DataSet.

Parameters
groupA pointer to the Group to add.

Definition at line 205 of file DataSet.cpp.

References bpp::Group::getGroupId(), and groups_.

Referenced by splitGroup().

◆ addIndividualSequenceInGroup()

void DataSet::addIndividualSequenceInGroup ( size_t  group_position,
size_t  individual_position,
size_t  sequence_position,
const Sequence sequence 
)

Add a Sequence to an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
AlphabetMismatchExceptionif the sequence's alphabet doesn't match the container's alphabet.
BadIdentifierExceptionif the sequence's name is already in use.

Definition at line 672 of file DataSet.cpp.

References bpp::Sequence::getAlphabet(), bpp::AlphabetMismatchException::getAlphabets(), bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), bpp::BadIdentifierException::getIdentifier(), getNumberOfGroups(), groups_, and setAlphabet().

◆ addIndividualToGroup()

void DataSet::addIndividualToGroup ( size_t  group_position,
const Individual individual 
)

◆ addLocality()

void DataSet::addLocality ( Locality< double > &  locality)

Add a locality to the DataSet.

Parameters
localityA Locality object.
Exceptions
BadIdentifierExceptionif the locality's name already exists.

Definition at line 119 of file DataSet.cpp.

References bpp::Locality< T >::getName(), and localities_.

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

◆ deleteAnalyzedLoci()

void DataSet::deleteAnalyzedLoci ( )

Delete the AnalyzedLoci.

Definition at line 1102 of file DataSet.cpp.

References analyzedLoci_.

Referenced by setAnalyzedLoci().

◆ deleteGroupAtPosition()

void DataSet::deleteGroupAtPosition ( size_t  group_position)

Delete a Group from the DataSet.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.

Definition at line 290 of file DataSet.cpp.

References groups_.

Referenced by mergeGroups(), and mergeTwoGroups().

◆ deleteIndividualAtPositionFromGroup()

void DataSet::deleteIndividualAtPositionFromGroup ( size_t  group_position,
size_t  individual_position 
)

Delete an Individual from a group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.

Definition at line 496 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ deleteIndividualByIdFromGroup()

void DataSet::deleteIndividualByIdFromGroup ( size_t  group_position,
const std::string &  individual_id 
)

Delete an Individual from a group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndividualNotFoundExceptionif individual_id is not found.

Definition at line 512 of file DataSet.cpp.

References bpp::IndividualNotFoundException::getIdentifier(), getNumberOfGroups(), and groups_.

◆ deleteIndividualGenotypeInGroup()

void DataSet::deleteIndividualGenotypeInGroup ( size_t  group_position,
size_t  individual_position 
)

Delete the MultilocusGenotype of an Individual from a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.

Definition at line 905 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ deleteIndividualSequenceAtPositionInGroup()

void DataSet::deleteIndividualSequenceAtPositionInGroup ( size_t  group_position,
size_t  individual_position,
size_t  sequence_position 
)

Delete a Sequence of an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no sequences.
SequenceNotFoundExceptionif sequence_position is not found.

Definition at line 773 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), groups_, and bpp::IndexOutOfBoundsException::what().

◆ deleteIndividualSequenceByNameInGroup()

void DataSet::deleteIndividualSequenceByNameInGroup ( size_t  group_position,
size_t  individual_position,
const std::string &  sequence_name 
)

Delete a Sequence of an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no sequences.
SequenceNotFoundExceptionif sequence_name is not found.

Definition at line 749 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), bpp::SequenceNotFoundException::getSequenceId(), and groups_.

◆ deleteLocalityAtPosition()

void DataSet::deleteLocalityAtPosition ( size_t  locality_position)

Delete a Locality from the DataSet.

Exceptions
IndexOutOfBoundsExceptionif locality_position excedes the number of Locality.

Definition at line 166 of file DataSet.cpp.

References localities_.

Referenced by deleteLocalityByName().

◆ deleteLocalityByName()

void DataSet::deleteLocalityByName ( const std::string &  name)

Delete a Locality from the DataSet.

Exceptions
LocalityNotFoundExceptionif the locality's name is not found.

Definition at line 176 of file DataSet.cpp.

References deleteLocalityAtPosition(), and getLocalityPosition().

◆ getAlphabet()

const Alphabet * DataSet::getAlphabet ( ) const

Get the alphabet if there is sequence data.

Exceptions
NullPointerExceptionif there is no sequence data.

Definition at line 1046 of file DataSet.cpp.

References analyzedSequences_, and bpp::AnalyzedSequences::getAlphabet().

Referenced by getPolymorphismSequenceContainer(), and bpp::PopgenlibIO::read().

◆ getAlphabetType()

std::string DataSet::getAlphabetType ( ) const

Get the alphabet type as a string.

Exceptions
NullPointerExceptionif there is no sequence data.

Definition at line 1055 of file DataSet.cpp.

References analyzedSequences_, and bpp::AnalyzedSequences::getAlphabetType().

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

◆ getAnalyzedLoci()

const AnalyzedLoci * DataSet::getAnalyzedLoci ( ) const

Get the AnalyzedLoci if there is one.

Exceptions
NullPointerExceptionif there is no AnalyzedLoci.

Definition at line 1093 of file DataSet.cpp.

References analyzedLoci_.

Referenced by bpp::GeneMapperCsvExport::read(), and bpp::DarwinVarSingle::write().

◆ getGroupAtPosition()

const Group & DataSet::getGroupAtPosition ( size_t  group_position) const

Get a group by position.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.

Definition at line 281 of file DataSet.cpp.

References groups_.

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

◆ getGroupById()

const Group & DataSet::getGroupById ( size_t  group_id) const

Get a group by identifier.

Definition at line 229 of file DataSet.cpp.

References groups_.

Referenced by getGroupName(), mergeGroups(), and mergeTwoGroups().

◆ getGroupName()

string DataSet::getGroupName ( size_t  group_id) const

Get the name of a Group. If the name is an empty string it just returns the group_id.

Exceptions
GroupNotFoundExceptionif the group_id is not found.

Definition at line 241 of file DataSet.cpp.

References getGroupById(), bpp::Group::getGroupName(), and bpp::TextTools::toString().

◆ getGroupPosition()

size_t DataSet::getGroupPosition ( size_t  group_id) const

◆ getIndividualAtPositionFromGroup()

const Individual * DataSet::getIndividualAtPositionFromGroup ( size_t  group_position,
size_t  individual_position 
) const

Get an Individual from a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.

Definition at line 464 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

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

◆ getIndividualByIdFromGroup()

const Individual * DataSet::getIndividualByIdFromGroup ( size_t  group_position,
const std::string &  individual_id 
) const

Get an Individual from a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndividualNotFoundExceptionif individual_id is not found.

Definition at line 480 of file DataSet.cpp.

References bpp::IndividualNotFoundException::getIdentifier(), getNumberOfGroups(), and groups_.

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

◆ getIndividualCoordInGroup()

const Point2D< double > * DataSet::getIndividualCoordInGroup ( size_t  group_position,
size_t  individual_position 
) const

Get the coordinate of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no coordinate.

Definition at line 612 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ getIndividualDateInGroup()

const Date * DataSet::getIndividualDateInGroup ( size_t  group_position,
size_t  individual_position 
) const

Get the Date of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no date.

Definition at line 576 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ getIndividualLocalityInGroup()

const Locality< double > * DataSet::getIndividualLocalityInGroup ( size_t  group_position,
size_t  individual_position 
) const

Get the Locality of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no locality.

Definition at line 652 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ getIndividualMonolocusGenotypeInGroup()

const MonolocusGenotype * DataSet::getIndividualMonolocusGenotypeInGroup ( size_t  group_position,
size_t  individual_position,
size_t  locus_position 
) const

Get a MonolocusGenotype from an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no genotype.
IndexOutOfBoundsExceptionif locus_position excedes the number of locus.
AlleleNotFoundExceptionif at least one of the id is not found.

Definition at line 1002 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), groups_, and bpp::IndexOutOfBoundsException::what().

◆ getIndividualNumberOfSequencesInGroup()

size_t DataSet::getIndividualNumberOfSequencesInGroup ( size_t  group_position,
size_t  individual_position 
) const

Get the number of Sequences in an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no sequences.

Definition at line 841 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ getIndividualPositionInGroup()

size_t DataSet::getIndividualPositionInGroup ( size_t  group_position,
const std::string &  individual_id 
) const

Get the position of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndividualNotFoundExceptionif individual_id is not found.

Definition at line 448 of file DataSet.cpp.

References bpp::IndividualNotFoundException::getIdentifier(), getNumberOfGroups(), and groups_.

Referenced by bpp::GeneMapperCsvExport::read(), and bpp::Genepop::read().

◆ getIndividualSequenceAtPositionInGroup()

const Sequence & DataSet::getIndividualSequenceAtPositionInGroup ( size_t  group_position,
size_t  individual_position,
size_t  sequence_position 
) const

Get a Sequence from an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no sequences.
SequenceNotFoundExceptionif sequence_position is not found.

Definition at line 725 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), groups_, and bpp::IndexOutOfBoundsException::what().

◆ getIndividualSequenceByNameInGroup()

const Sequence & DataSet::getIndividualSequenceByNameInGroup ( size_t  group_position,
size_t  individual_position,
const std::string &  sequence_name 
) const

Get a Sequence from an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no sequences.
SequenceNotFoundExceptionif sequence_name is not found.
BadIntegerExceptionif sequence_position is already in use.

Definition at line 701 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), bpp::SequenceNotFoundException::getSequenceId(), and groups_.

◆ getIndividualSequencePositionInGroup()

size_t DataSet::getIndividualSequencePositionInGroup ( size_t  group_position,
size_t  individual_position,
const std::string &  sequence_name 
) const

Get the position of a Sequence in an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no sequences.
SequenceNotFoundExceptionif sequence_name is not found.

Definition at line 817 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), bpp::SequenceNotFoundException::getSequenceId(), and groups_.

◆ getIndividualSequencesNamesInGroup()

std::vector< std::string > DataSet::getIndividualSequencesNamesInGroup ( size_t  group_position,
size_t  individual_position 
) const

Get the Sequences' names from an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no sequences.

Definition at line 797 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ getIndividualSexInGroup()

unsigned short DataSet::getIndividualSexInGroup ( size_t  group_position,
size_t  individual_position 
) const

Get the sex of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.

Definition at line 544 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ getLocalityAtPosition()

const Locality< double > & DataSet::getLocalityAtPosition ( size_t  locality_position) const

Get a Locality by locality_position.

Returns
A const pointer to the locality matching the locality_position.
Parameters
locality_positionThe position of the Locality in the DataSet.
Exceptions
IndexOutOfBoundsExceptionif locality_position excedes the number of locality of the DataSet.

Definition at line 143 of file DataSet.cpp.

References localities_.

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

◆ getLocalityByName()

const Locality< double > & DataSet::getLocalityByName ( const std::string &  name) const

Get a Locality by name.

Exceptions
LocalityNotFoundExceptionif the locality's name is not found.

Definition at line 152 of file DataSet.cpp.

References getLocalityAtPosition(), and getLocalityPosition().

Referenced by bpp::PopgenlibIO::parseIndividual_(), and setIndividualLocalityInGroupByName().

◆ getLocalityPosition()

size_t DataSet::getLocalityPosition ( const std::string &  name) const

Get the position of a locality in the container.

Returns
The locality_position (position) of the Locality.
Parameters
nameThe locality's name to find.
Exceptions
LocalityNotFoundExceptionif the locality's name doesn't match any name in the DataSet.

Definition at line 131 of file DataSet.cpp.

References localities_.

Referenced by deleteLocalityByName(), and getLocalityByName().

◆ getLocusInfoAtPosition()

◆ getLocusInfoByName()

const LocusInfo & DataSet::getLocusInfoByName ( const std::string &  locus_name) const

Get a LocusInfo by its name.

Definition at line 1126 of file DataSet.cpp.

References analyzedLoci_, and bpp::AnalyzedLoci::getLocusInfoByName().

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

◆ getNumberOfGroups()

◆ getNumberOfIndividualsInGroup()

size_t DataSet::getNumberOfIndividualsInGroup ( size_t  group_position) const

Get the number of Individuals in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.

Definition at line 439 of file DataSet.cpp.

References getNumberOfGroups(), and groups_.

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

◆ getNumberOfLocalities()

size_t DataSet::getNumberOfLocalities ( ) const

Get the number of Localities.

Definition at line 190 of file DataSet.cpp.

References localities_.

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

◆ getNumberOfLoci()

size_t DataSet::getNumberOfLoci ( ) const

◆ getPloidyByLocusName()

size_t DataSet::getPloidyByLocusName ( const std::string &  locus_name) const

Get the ploidy of a locus.

Definition at line 1211 of file DataSet.cpp.

References analyzedLoci_, bpp::LocusNotFoundException::getIdentifier(), and bpp::AnalyzedLoci::getPloidyByLocusName().

◆ getPloidyByLocusPosition()

size_t DataSet::getPloidyByLocusPosition ( size_t  locus_position) const

◆ getPolymorphismMultiGContainer() [1/2]

◆ getPolymorphismMultiGContainer() [2/2]

PolymorphismMultiGContainer * DataSet::getPolymorphismMultiGContainer ( const std::map< size_t, std::vector< size_t > > &  selection) const

Get a PolymorphismMultiGContainer from a selection of groups and individuals.

Parameters
selectionA map with groups id as keys and vector of individuals position in each group as values.

Definition at line 1268 of file DataSet.cpp.

References bpp::PolymorphismMultiGContainer::addGroupName(), bpp::PolymorphismMultiGContainer::addMultilocusGenotype(), bpp::Individual::getGenotype(), getGroupPosition(), getIndividualAtPositionFromGroup(), groups_, and bpp::Individual::hasGenotype().

◆ getPolymorphismSequenceContainer()

PolymorphismSequenceContainer * DataSet::getPolymorphismSequenceContainer ( const std::map< size_t, std::vector< size_t > > &  selection,
size_t  sequence_position 
) const

Get a PolymorphismSequenceContainer from a selection of groups and individuals.

All the sequences are ingroup. You may change their state after created the container.

Parameters
selectionA map with groups id as keys and vector of individuals position in each group as values.
sequence_positionThe position of the sequence in the individuals;

Definition at line 1307 of file DataSet.cpp.

References bpp::PolymorphismSequenceContainer::addSequenceWithFrequency(), getAlphabet(), getGroupPosition(), getIndividualAtPositionFromGroup(), bpp::Sequence::getName(), bpp::Individual::getSequenceAtPosition(), bpp::Individual::hasSequenceAtPosition(), and bpp::PolymorphismSequenceContainer::setGroupId().

◆ hasAlleleicData()

bool DataSet::hasAlleleicData ( ) const

Tell if there is alelelic data.

Definition at line 1356 of file DataSet.cpp.

References analyzedLoci_.

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

◆ hasLocality()

bool DataSet::hasLocality ( ) const

Tell if there is at least one locality.

Definition at line 197 of file DataSet.cpp.

References getNumberOfLocalities().

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

◆ hasSequenceData()

bool DataSet::hasSequenceData ( ) const

Tell if at least one individual has at least one sequence.

Definition at line 1349 of file DataSet.cpp.

References analyzedSequences_.

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

◆ initAnalyzedLoci()

void DataSet::initAnalyzedLoci ( size_t  number_of_loci)

Initialize the AnalyzedLoci for number of loci.

Exceptions
Exceptionif the AnalyzedLoci has already been initialyzed.

Definition at line 1084 of file DataSet.cpp.

References analyzedLoci_.

Referenced by bpp::GeneMapperCsvExport::read(), bpp::Genepop::read(), and bpp::Genetix::read().

◆ initIndividualGenotypeInGroup()

void DataSet::initIndividualGenotypeInGroup ( size_t  group_position,
size_t  individual_position 
)

Initialyze the genotype of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
BadIntegerExceptionif the number of loci is < 1;
NullPointerExceptionif analyzed_loci is NULL.
Exceptionif the individual already has a genotype.

Definition at line 877 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::BadIntegerException::getBadInteger(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), getNumberOfLoci(), and groups_.

Referenced by bpp::GeneMapperCsvExport::read(), bpp::Genepop::read(), and bpp::Genetix::read().

◆ mergeGroups()

void DataSet::mergeGroups ( std::vector< size_t > &  group_ids)

Merge some Groups in one.

Merge all the groups which are specified in the first one (smallest identifier). When a group is merged to the first, it is deleted from the DataSet.

Parameters
group_idsA vector size_t listing the id of groups to merge.
Exceptions
IndexOutOfBoundsExceptionif one of the int in groups excedes the number of groups.

Definition at line 338 of file DataSet.cpp.

References deleteGroupAtPosition(), getGroupAtPosition(), getGroupById(), getGroupPosition(), bpp::Group::getIndividualAtPosition(), bpp::Group::getNumberOfIndividuals(), and groups_.

◆ mergeTwoGroups()

void DataSet::mergeTwoGroups ( size_t  source_id,
size_t  target_id 
)

Merge two groups.

This methode merge two groups. The source group is emptied into the target and then is deleted.

Definition at line 307 of file DataSet.cpp.

References deleteGroupAtPosition(), getGroupById(), getGroupPosition(), and groups_.

◆ operator=()

DataSet & DataSet::operator= ( const DataSet ds)

Definition at line 78 of file DataSet.cpp.

References analyzedLoci_, analyzedSequences_, groups_, and localities_.

◆ setAlphabet() [1/2]

void DataSet::setAlphabet ( const Alphabet alpha)

◆ setAlphabet() [2/2]

void DataSet::setAlphabet ( const std::string &  alpha_type)

Set the alphabet of the AnalyzedSequences by its type..

Definition at line 1037 of file DataSet.cpp.

References analyzedSequences_, and bpp::AnalyzedSequences::setAlphabet().

◆ setAnalyzedLoci()

void DataSet::setAnalyzedLoci ( const AnalyzedLoci analyzedLoci)

Set the AnalyzedLoci to the DataSet.

Exceptions
Exceptionif at least one Individual has a genotype refering to the actual AnalyzedLoci.

Definition at line 1066 of file DataSet.cpp.

References analyzedLoci_, and deleteAnalyzedLoci().

Referenced by bpp::GeneMapperCsvExport::read(), and bpp::PopgenlibIO::read().

◆ setGroupName()

void DataSet::setGroupName ( size_t  group_id,
const std::string &  group_name 
) const

set the name of a Group.

Exceptions
GroupNotFoundExceptionif the group_id is not found.

Definition at line 254 of file DataSet.cpp.

References groups_.

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

◆ setIndividualCoordInGroup()

void DataSet::setIndividualCoordInGroup ( size_t  group_position,
size_t  individual_position,
const Point2D< double > &  coord 
)

Set the coordinates of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.

Definition at line 596 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ setIndividualDateInGroup()

void DataSet::setIndividualDateInGroup ( size_t  group_position,
size_t  individual_position,
const Date date 
)

Set the Date of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.

Definition at line 560 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ setIndividualGenotypeInGroup()

void DataSet::setIndividualGenotypeInGroup ( size_t  group_position,
size_t  individual_position,
const MultilocusGenotype genotype 
)

Set the MultilocusGenotype of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.

Definition at line 861 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ setIndividualLocalityInGroupByName()

void DataSet::setIndividualLocalityInGroupByName ( size_t  group_position,
size_t  individual_position,
const std::string &  locality_name 
)

Set the Locality of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
LocalityNotFoundExceptionif locality_name is not found.

Definition at line 632 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), bpp::LocalityNotFoundException::getIdentifier(), getLocalityByName(), getNumberOfGroups(), and groups_.

◆ setIndividualMonolocusGenotypeByAlleleIdInGroup()

void DataSet::setIndividualMonolocusGenotypeByAlleleIdInGroup ( size_t  group_position,
size_t  individual_position,
size_t  locus_position,
const std::vector< std::string >  allele_id 
)

Set a MonolocusGenotype of an Individual from a group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no genotype.
IndexOutOfBoundsExceptionif locus_position excedes the number of locus.
Exceptionif there is no key in allele_keys.

Definition at line 973 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), bpp::AlleleNotFoundException::getIdentifier(), getLocusInfoAtPosition(), getNumberOfGroups(), groups_, and bpp::IndexOutOfBoundsException::what().

Referenced by bpp::Genepop::read(), and bpp::Genetix::read().

◆ setIndividualMonolocusGenotypeByAlleleKeyInGroup()

void DataSet::setIndividualMonolocusGenotypeByAlleleKeyInGroup ( size_t  group_position,
size_t  individual_position,
size_t  locus_position,
const std::vector< size_t >  allele_keys 
)

Set a MonolocusGenotype of an Individual from a group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no genotype.
IndexOutOfBoundsExceptionif locus_position excedes the number of locus.
Exceptionif the ploidy doesn't match.

Definition at line 945 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), groups_, and bpp::IndexOutOfBoundsException::what().

◆ setIndividualMonolocusGenotypeInGroup()

void DataSet::setIndividualMonolocusGenotypeInGroup ( size_t  group_position,
size_t  individual_position,
size_t  locus_position,
const MonolocusGenotype monogen 
)

Set a MonolocusGenotype of an Individual from a group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.
NullPointerExceptionif the individual has no genotype.
IndexOutOfBoundsExceptionif locus_position excedes the number of locus.

Definition at line 921 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), groups_, and bpp::IndexOutOfBoundsException::what().

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

◆ setIndividualSexInGroup()

void DataSet::setIndividualSexInGroup ( size_t  group_position,
size_t  individual_position,
const unsigned short  sex 
)

Set the sex of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif group_position excedes the number of groups.
IndexOutOfBoundsExceptionif individual_position excedes the number of individual in the group.

Definition at line 528 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), getNumberOfGroups(), and groups_.

◆ setLocusInfo()

void DataSet::setLocusInfo ( size_t  locus_position,
const LocusInfo locus 
)

Set a LocusInfo.

Exceptions
NullPointerExceptionif there is no AnalyzedLoci to setup.
IndexOutOfBoundsExceptionif locus_position excedes the total of LocusInfo of the DataSet.

Definition at line 1110 of file DataSet.cpp.

References analyzedLoci_, bpp::AnalyzedLoci::getNumberOfLoci(), and bpp::AnalyzedLoci::setLocusInfo().

Referenced by bpp::Genepop::read(), and bpp::Genetix::read().

◆ splitGroup()

void DataSet::splitGroup ( size_t  group_id,
std::vector< size_t >  individuals_selection 
)

Split a group in two.

Parameters
group_idThe identifier of the source group.
individuals_selectionThe positions of the Individuals to extract from the group to make the new group.
Exceptions
GroupNotFoundExceptionif the group_id is not found.
IndexOutOfBoundsExceptionif one position of the selection excedes the number of individuals of the group.

Definition at line 369 of file DataSet.cpp.

References addGroup(), bpp::Group::addIndividual(), getGroupPosition(), bpp::GroupNotFoundException::getIdentifier(), and groups_.

Member Data Documentation

◆ analyzedLoci_

◆ analyzedSequences_

AnalyzedSequences* bpp::DataSet::analyzedSequences_
private

◆ groups_

◆ localities_

std::vector<Locality<double>*> bpp::DataSet::localities_
private

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