bpp-popgen3  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...
 
virtual ~DataSet ()=default
 Destroy a DataSet. More...
 
 DataSet (const DataSet &ds)
 Copy constructor. More...
 
DataSetoperator= (const DataSet &ds)
 
void addLocality (const 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...
 
std::shared_ptr< const Locality< double > > getLocalityAtPosition (size_t localityPosition) const
 Get a Locality by localityPosition. More...
 
const Locality< double > & localityAtPosition (size_t localityPosition) const
 Get a Locality by localityPosition. More...
 
std::shared_ptr< const Locality< double > > getLocalityByName (const std::string &name) const
 Get a Locality by name. More...
 
const Locality< double > & localityByName (const std::string &name) const
 Get a Locality by name. More...
 
void deleteLocalityAtPosition (size_t localityPosition)
 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 groupPosition) const
 Get a group by position. More...
 
void deleteGroupAtPosition (size_t groupPosition)
 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 groupPosition, const Individual &individual)
 Add an Individual to a Group. More...
 
void addEmptyIndividualToGroup (size_t groupPosition, const std::string &individual_id)
 Add an empty Individual to a Group. More...
 
size_t getNumberOfIndividualsInGroup (size_t groupPosition) const
 Get the number of Individuals in a Group. More...
 
size_t getIndividualPositionInGroup (size_t groupPosition, const std::string &individual_id) const
 Get the position of an Individual in a Group. More...
 
const IndividualgetIndividualAtPositionFromGroup (size_t groupPosition, size_t individualPosition) const
 Get an Individual from a Group. More...
 
const IndividualgetIndividualByIdFromGroup (size_t groupPosition, const std::string &individualId) const
 Get an Individual from a Group. More...
 
void deleteIndividualAtPositionFromGroup (size_t groupPosition, size_t individualPosition)
 Delete an Individual from a group. More...
 
void deleteIndividualByIdFromGroup (size_t groupPosition, const std::string &individualId)
 Delete an Individual from a group. More...
 
void setIndividualSexInGroup (size_t groupPosition, size_t individualPosition, const unsigned short sex)
 Set the sex of an Individual in a Group. More...
 
unsigned short getIndividualSexInGroup (size_t groupPosition, size_t individualPosition) const
 Get the sex of an Individual in a Group. More...
 
void setIndividualDateInGroup (size_t groupPosition, size_t individualPosition, const Date &date)
 Set the Date of an Individual in a Group. More...
 
const DateindividualDateInGroup (size_t groupPosition, size_t individualPosition) const
 Get the Date of an Individual in a Group. More...
 
void setIndividualCoordInGroup (size_t groupPosition, size_t individualPosition, const Point2D< double > &coord)
 Set the coordinates of an Individual in a Group. More...
 
const Point2D< double > & individualCoordInGroup (size_t groupPosition, size_t individualPosition) const
 Get the coordinate of an Individual in a Group. More...
 
void setIndividualLocalityInGroupByName (size_t groupPosition, size_t individualPosition, const std::string &localityName)
 Set the Locality of an Individual in a Group. More...
 
std::shared_ptr< const Locality< double > > getIndividualLocalityInGroup (size_t groupPosition, size_t individualPosition) const
 Get the Locality of an Individual in a Group. More...
 
void addIndividualSequenceInGroup (size_t groupPosition, size_t individualPosition, size_t sequencePosition, std::unique_ptr< Sequence > &sequence)
 Add a Sequence to an Individual in a Group. More...
 
const SequencegetIndividualSequenceByNameInGroup (size_t groupPosition, size_t individualPosition, const std::string &sequenceName) const
 Get a Sequence from an Individual of a Group. More...
 
const SequencegetIndividualSequenceAtPositionInGroup (size_t groupPosition, size_t individualPosition, size_t sequencePosition) const
 Get a Sequence from an Individual of a Group. More...
 
void deleteIndividualSequenceByNameInGroup (size_t groupPosition, size_t individualPosition, const std::string &sequenceName)
 Delete a Sequence of an Individual of a Group. More...
 
void deleteIndividualSequenceAtPositionInGroup (size_t groupPosition, size_t individualPosition, size_t sequencePosition)
 Delete a Sequence of an Individual of a Group. More...
 
std::vector< std::string > getIndividualSequencesNamesInGroup (size_t groupPosition, size_t individualPosition) const
 Get the Sequences' names from an Individual of a Group. More...
 
size_t getIndividualSequencePositionInGroup (size_t groupPosition, size_t individualPosition, const std::string &sequenceName) const
 Get the position of a Sequence in an Individual of a Group. More...
 
size_t getIndividualNumberOfSequencesInGroup (size_t groupPosition, size_t individualPosition) const
 Get the number of Sequences in an Individual of a Group. More...
 
void setIndividualGenotypeInGroup (size_t groupPosition, size_t individualPosition, const MultilocusGenotype &genotype)
 Set the MultilocusGenotype of an Individual in a Group. More...
 
void initIndividualGenotypeInGroup (size_t groupPosition, size_t individualPosition)
 Initialize the genotype of an Individual in a Group. More...
 
void deleteIndividualGenotypeInGroup (size_t groupPosition, size_t individualPosition)
 Delete the MultilocusGenotype of an Individual from a Group. More...
 
void setIndividualMonolocusGenotypeInGroup (size_t groupPosition, size_t individualPosition, size_t locusPosition, const MonolocusGenotypeInterface &monogen)
 Set a MonolocusGenotype of an Individual from a group. More...
 
void setIndividualMonolocusGenotypeByAlleleKeyInGroup (size_t groupPosition, size_t individualPosition, size_t locusPosition, const std::vector< size_t > alleleKeys)
 Set a MonolocusGenotype of an Individual from a group. More...
 
void setIndividualMonolocusGenotypeByAlleleIdInGroup (size_t groupPosition, size_t individualPosition, size_t locusPosition, const std::vector< std::string > alleleId)
 Set a MonolocusGenotype of an Individual from a group. More...
 
const MonolocusGenotypeInterfacegetIndividualMonolocusGenotypeInGroup (size_t groupPosition, size_t individualPosition, size_t locusPosition) const
 Get a MonolocusGenotype from an Individual of a Group. More...
 
void setAlphabet (std::shared_ptr< const Alphabet > alpha)
 Set the alphabet of the AnalyzedSequences. More...
 
void setAlphabet (const std::string &alphaType)
 Set the alphabet of the AnalyzedSequences by its type.. More...
 
std::shared_ptr< const AlphabetgetAlphabet () const
 Get a pointer toward the alphabet if there is sequence data. More...
 
const Alphabetalphabet () const
 Get a reference toward 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 numberOfLoci)
 Initialize the AnalyzedLoci for number of loci. More...
 
const AnalyzedLocianalyzedLoci () 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...
 
std::unique_ptr< PolymorphismMultiGContainergetPolymorphismMultiGContainer () const
 Get a PolymorphismMultiGContainer with all allelic data of the DataSet. More...
 
std::unique_ptr< PolymorphismMultiGContainergetPolymorphismMultiGContainer (const std::map< size_t, std::vector< size_t >> &selection) const
 Get a PolymorphismMultiGContainer from a selection of groups and individuals. More...
 
std::unique_ptr< 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

std::unique_ptr< AnalyzedLocianalyzedLoci_
 
std::shared_ptr< const AlphabetsequenceAlphabet_
 
std::vector< std::shared_ptr< Locality< double > > > localities_
 
std::vector< std::unique_ptr< 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 36 of file DataSet.h.

Constructor & Destructor Documentation

◆ DataSet() [1/2]

bpp::DataSet::DataSet ( )
inline

Build a new void DataSet.

Definition at line 49 of file DataSet.h.

◆ ~DataSet()

virtual bpp::DataSet::~DataSet ( )
virtualdefault

Destroy a DataSet.

◆ DataSet() [2/2]

DataSet::DataSet ( const DataSet ds)

Copy constructor.

Definition at line 13 of file DataSet.cpp.

References analyzedLoci_, 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  groupPosition,
const std::string &  individual_id 
)

Add an empty Individual to a Group.

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

Definition at line 374 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 154 of file DataSet.cpp.

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

Referenced by splitGroup().

◆ addIndividualSequenceInGroup()

void DataSet::addIndividualSequenceInGroup ( size_t  groupPosition,
size_t  individualPosition,
size_t  sequencePosition,
std::unique_ptr< Sequence > &  sequence 
)

Add a Sequence to an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds 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 623 of file DataSet.cpp.

References bpp::IndexOutOfBoundsException::getBadIndex(), bpp::IndexOutOfBoundsException::getBounds(), bpp::AlphabetMismatchException::getFirstAlphabet(), bpp::BadIdentifierException::getIdentifier(), getNumberOfGroups(), bpp::AlphabetMismatchException::getSecondAlphabet(), groups_, and setAlphabet().

◆ addIndividualToGroup()

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

◆ addLocality()

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

Add a locality to the DataSet.

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

Definition at line 60 of file DataSet.cpp.

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

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

◆ alphabet()

const Alphabet& bpp::DataSet::alphabet ( ) const
inline

Get a reference toward the alphabet if there is sequence data.

Exceptions
NullPointerExceptionif there is no sequence data.

Definition at line 573 of file DataSet.h.

References sequenceAlphabet_.

◆ analyzedLoci()

const AnalyzedLoci& bpp::DataSet::analyzedLoci ( ) const
inline

Get the AnalyzedLoci if there is one.

Exceptions
NullPointerExceptionif there is no AnalyzedLoci.

Definition at line 621 of file DataSet.h.

References analyzedLoci_.

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

◆ deleteAnalyzedLoci()

void bpp::DataSet::deleteAnalyzedLoci ( )
inline

Delete the AnalyzedLoci.

Definition at line 631 of file DataSet.h.

References analyzedLoci_.

◆ deleteGroupAtPosition()

void DataSet::deleteGroupAtPosition ( size_t  groupPosition)

Delete a Group from the DataSet.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.

Definition at line 242 of file DataSet.cpp.

References groups_.

Referenced by mergeGroups(), and mergeTwoGroups().

◆ deleteIndividualAtPositionFromGroup()

void DataSet::deleteIndividualAtPositionFromGroup ( size_t  groupPosition,
size_t  individualPosition 
)

Delete an Individual from a group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.

Definition at line 447 of file DataSet.cpp.

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

◆ deleteIndividualByIdFromGroup()

void DataSet::deleteIndividualByIdFromGroup ( size_t  groupPosition,
const std::string &  individualId 
)

Delete an Individual from a group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndividualNotFoundExceptionif individual_id is not found.

Definition at line 463 of file DataSet.cpp.

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

◆ deleteIndividualGenotypeInGroup()

void DataSet::deleteIndividualGenotypeInGroup ( size_t  groupPosition,
size_t  individualPosition 
)

Delete the MultilocusGenotype of an Individual from a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.

Definition at line 856 of file DataSet.cpp.

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

◆ deleteIndividualSequenceAtPositionInGroup()

void DataSet::deleteIndividualSequenceAtPositionInGroup ( size_t  groupPosition,
size_t  individualPosition,
size_t  sequencePosition 
)

Delete a Sequence of an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no sequences.
SequenceNotFoundExceptionif sequence_position is not found.

Definition at line 724 of file DataSet.cpp.

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

◆ deleteIndividualSequenceByNameInGroup()

void DataSet::deleteIndividualSequenceByNameInGroup ( size_t  groupPosition,
size_t  individualPosition,
const std::string &  sequenceName 
)

Delete a Sequence of an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no sequences.
SequenceNotFoundExceptionif sequence_name is not found.

Definition at line 700 of file DataSet.cpp.

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

◆ deleteLocalityAtPosition()

void DataSet::deleteLocalityAtPosition ( size_t  localityPosition)

Delete a Locality from the DataSet.

Exceptions
IndexOutOfBoundsExceptionif locality_position exceeds the number of Locality.

Definition at line 130 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 139 of file DataSet.cpp.

References deleteLocalityAtPosition(), and getLocalityPosition().

◆ getAlphabet()

std::shared_ptr<const Alphabet> bpp::DataSet::getAlphabet ( ) const
inline

Get a pointer toward the alphabet if there is sequence data.

Exceptions
NullPointerExceptionif there is no sequence data.

Definition at line 561 of file DataSet.h.

References sequenceAlphabet_.

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

◆ getAlphabetType()

std::string bpp::DataSet::getAlphabetType ( ) const
inline

Get the alphabet type as a string.

Exceptions
NullPointerExceptionif there is no sequence data.

Definition at line 585 of file DataSet.h.

References sequenceAlphabet_.

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

◆ getGroupAtPosition()

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

Get a group by position.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.

Definition at line 233 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 178 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 193 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  groupPosition,
size_t  individualPosition 
) const

Get an Individual from a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.

Definition at line 415 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  groupPosition,
const std::string &  individualId 
) const

Get an Individual from a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndividualNotFoundExceptionif individual_id is not found.

Definition at line 431 of file DataSet.cpp.

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

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

◆ getIndividualLocalityInGroup()

shared_ptr< const Locality< double > > DataSet::getIndividualLocalityInGroup ( size_t  groupPosition,
size_t  individualPosition 
) const

Get the Locality of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no locality.

Definition at line 603 of file DataSet.cpp.

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

◆ getIndividualMonolocusGenotypeInGroup()

const MonolocusGenotypeInterface & DataSet::getIndividualMonolocusGenotypeInGroup ( size_t  groupPosition,
size_t  individualPosition,
size_t  locusPosition 
) const

Get a MonolocusGenotype from an Individual of a Group.

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

Definition at line 957 of file DataSet.cpp.

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

◆ getIndividualNumberOfSequencesInGroup()

size_t DataSet::getIndividualNumberOfSequencesInGroup ( size_t  groupPosition,
size_t  individualPosition 
) const

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

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no sequences.

Definition at line 792 of file DataSet.cpp.

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

◆ getIndividualPositionInGroup()

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

Get the position of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndividualNotFoundExceptionif individual_id is not found.

Definition at line 399 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  groupPosition,
size_t  individualPosition,
size_t  sequencePosition 
) const

Get a Sequence from an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no sequences.
SequenceNotFoundExceptionif sequence_position is not found.

Definition at line 676 of file DataSet.cpp.

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

◆ getIndividualSequenceByNameInGroup()

const Sequence & DataSet::getIndividualSequenceByNameInGroup ( size_t  groupPosition,
size_t  individualPosition,
const std::string &  sequenceName 
) const

Get a Sequence from an Individual of a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds 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 652 of file DataSet.cpp.

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

◆ getIndividualSequencePositionInGroup()

size_t DataSet::getIndividualSequencePositionInGroup ( size_t  groupPosition,
size_t  individualPosition,
const std::string &  sequenceName 
) const

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

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no sequences.
SequenceNotFoundExceptionif sequence_name is not found.

Definition at line 768 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  groupPosition,
size_t  individualPosition 
) const

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

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no sequences.

Definition at line 748 of file DataSet.cpp.

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

◆ getIndividualSexInGroup()

unsigned short DataSet::getIndividualSexInGroup ( size_t  groupPosition,
size_t  individualPosition 
) const

Get the sex of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.

Definition at line 495 of file DataSet.cpp.

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

◆ getLocalityAtPosition()

shared_ptr< const Locality< double > > DataSet::getLocalityAtPosition ( size_t  localityPosition) const

Get a Locality by localityPosition.

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

Definition at line 84 of file DataSet.cpp.

References localities_.

Referenced by getLocalityByName().

◆ getLocalityByName()

shared_ptr< 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 102 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 72 of file DataSet.cpp.

References localities_.

Referenced by deleteLocalityByName(), getLocalityByName(), and localityByName().

◆ getLocusInfoAtPosition()

const LocusInfo & DataSet::getLocusInfoAtPosition ( size_t  locus_position) const

◆ getLocusInfoByName()

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

Get a LocusInfo by its name.

Definition at line 1014 of file DataSet.cpp.

References analyzedLoci_.

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

◆ getNumberOfGroups()

◆ getNumberOfIndividualsInGroup()

size_t DataSet::getNumberOfIndividualsInGroup ( size_t  groupPosition) const

Get the number of Individuals in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.

Definition at line 390 of file DataSet.cpp.

References getNumberOfGroups(), and groups_.

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

◆ getNumberOfLocalities()

size_t bpp::DataSet::getNumberOfLocalities ( ) const
inline

Get the number of Localities.

Definition at line 138 of file DataSet.h.

References localities_.

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

◆ 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 1099 of file DataSet.cpp.

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

◆ getPloidyByLocusPosition()

size_t DataSet::getPloidyByLocusPosition ( size_t  locus_position) const

Get the ploidy of a locus.

Definition at line 1115 of file DataSet.cpp.

References analyzedLoci_, bpp::IndexOutOfBoundsException::getBadIndex(), and bpp::IndexOutOfBoundsException::getBounds().

◆ getPolymorphismMultiGContainer() [1/2]

unique_ptr< PolymorphismMultiGContainer > DataSet::getPolymorphismMultiGContainer ( ) const

◆ getPolymorphismMultiGContainer() [2/2]

unique_ptr< 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 1153 of file DataSet.cpp.

References getGroupPosition(), getIndividualAtPositionFromGroup(), and groups_.

◆ getPolymorphismSequenceContainer()

unique_ptr< 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 1191 of file DataSet.cpp.

References getAlphabet(), getGroupPosition(), and getIndividualAtPositionFromGroup().

◆ hasAlleleicData()

bool bpp::DataSet::hasAlleleicData ( ) const
inline

Tell if there is alelelic data.

Definition at line 711 of file DataSet.h.

References analyzedLoci_.

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

◆ hasLocality()

bool bpp::DataSet::hasLocality ( ) const
inline

Tell if there is at least one locality.

Definition at line 143 of file DataSet.h.

References getNumberOfLocalities().

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

◆ hasSequenceData()

bool bpp::DataSet::hasSequenceData ( ) const
inline

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

Definition at line 706 of file DataSet.h.

References sequenceAlphabet_.

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

◆ individualCoordInGroup()

const Point2D< double > & DataSet::individualCoordInGroup ( size_t  groupPosition,
size_t  individualPosition 
) const

Get the coordinate of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no coordinate.

Definition at line 563 of file DataSet.cpp.

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

◆ individualDateInGroup()

const Date & DataSet::individualDateInGroup ( size_t  groupPosition,
size_t  individualPosition 
) const

Get the Date of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no date.

Definition at line 527 of file DataSet.cpp.

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

◆ initAnalyzedLoci()

void bpp::DataSet::initAnalyzedLoci ( size_t  numberOfLoci)
inline

Initialize the AnalyzedLoci for number of loci.

Exceptions
Exceptionif the AnalyzedLoci has already been initialized.

Definition at line 609 of file DataSet.h.

References analyzedLoci_.

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

◆ initIndividualGenotypeInGroup()

void DataSet::initIndividualGenotypeInGroup ( size_t  groupPosition,
size_t  individualPosition 
)

Initialize the genotype of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds 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 828 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().

◆ localityAtPosition()

const Locality< double > & DataSet::localityAtPosition ( size_t  localityPosition) const

Get a Locality by localityPosition.

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

Definition at line 93 of file DataSet.cpp.

References localities_.

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

◆ localityByName()

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

Get a Locality by name.

Exceptions
LocalityNotFoundExceptionif the locality's name is not found.

Definition at line 116 of file DataSet.cpp.

References getLocalityPosition(), and localityAtPosition().

◆ 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 exceeds the number of groups.

Definition at line 289 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 method merge two groups. The source group is emptied into the target and then is deleted.

Definition at line 258 of file DataSet.cpp.

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

◆ operator=()

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

Definition at line 33 of file DataSet.cpp.

References analyzedLoci_, groups_, localities_, and sequenceAlphabet_.

◆ setAlphabet() [1/2]

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

Set the alphabet of the AnalyzedSequences by its type..

Definition at line 984 of file DataSet.cpp.

References bpp::AlphabetTools::DNA_ALPHABET, bpp::AlphabetTools::PROTEIN_ALPHABET, bpp::AlphabetTools::RNA_ALPHABET, and sequenceAlphabet_.

◆ setAlphabet() [2/2]

void bpp::DataSet::setAlphabet ( std::shared_ptr< const Alphabet alpha)
inline

Set the alphabet of the AnalyzedSequences.

Definition at line 549 of file DataSet.h.

References sequenceAlphabet_.

Referenced by addIndividualSequenceInGroup(), addIndividualToGroup(), and bpp::PopgenlibIO::parseGeneral_().

◆ setAnalyzedLoci()

void bpp::DataSet::setAnalyzedLoci ( const AnalyzedLoci analyzedLoci)
inline

Set the AnalyzedLoci to the DataSet.

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

Definition at line 599 of file DataSet.h.

References analyzedLoci(), analyzedLoci_, and bpp::AnalyzedLoci::clone().

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 206 of file DataSet.cpp.

References groups_.

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

◆ setIndividualCoordInGroup()

void DataSet::setIndividualCoordInGroup ( size_t  groupPosition,
size_t  individualPosition,
const Point2D< double > &  coord 
)

Set the coordinates of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.

Definition at line 547 of file DataSet.cpp.

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

◆ setIndividualDateInGroup()

void DataSet::setIndividualDateInGroup ( size_t  groupPosition,
size_t  individualPosition,
const Date date 
)

Set the Date of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.

Definition at line 511 of file DataSet.cpp.

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

◆ setIndividualGenotypeInGroup()

void DataSet::setIndividualGenotypeInGroup ( size_t  groupPosition,
size_t  individualPosition,
const MultilocusGenotype genotype 
)

Set the MultilocusGenotype of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.

Definition at line 812 of file DataSet.cpp.

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

◆ setIndividualLocalityInGroupByName()

void DataSet::setIndividualLocalityInGroupByName ( size_t  groupPosition,
size_t  individualPosition,
const std::string &  localityName 
)

Set the Locality of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
LocalityNotFoundExceptionif locality_name is not found.

Definition at line 583 of file DataSet.cpp.

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

◆ setIndividualMonolocusGenotypeByAlleleIdInGroup()

void DataSet::setIndividualMonolocusGenotypeByAlleleIdInGroup ( size_t  groupPosition,
size_t  individualPosition,
size_t  locusPosition,
const std::vector< std::string >  alleleId 
)

Set a MonolocusGenotype of an Individual from a group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no genotype.
IndexOutOfBoundsExceptionif locus_position exceeds the number of locus.
Exceptionif there is no key in allele_keys.

Definition at line 928 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  groupPosition,
size_t  individualPosition,
size_t  locusPosition,
const std::vector< size_t >  alleleKeys 
)

Set a MonolocusGenotype of an Individual from a group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no genotype.
IndexOutOfBoundsExceptionif locus_position exceeds the number of locus.
Exceptionif the ploidy doesn't match.

Definition at line 900 of file DataSet.cpp.

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

◆ setIndividualMonolocusGenotypeInGroup()

void DataSet::setIndividualMonolocusGenotypeInGroup ( size_t  groupPosition,
size_t  individualPosition,
size_t  locusPosition,
const MonolocusGenotypeInterface monogen 
)

Set a MonolocusGenotype of an Individual from a group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.
NullPointerExceptionif the individual has no genotype.
IndexOutOfBoundsExceptionif locus_position exceeds the number of locus.

Definition at line 872 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  groupPosition,
size_t  individualPosition,
const unsigned short  sex 
)

Set the sex of an Individual in a Group.

Exceptions
IndexOutOfBoundsExceptionif groupPosition exceeds the number of groups.
IndexOutOfBoundsExceptionif individualPosition exceeds the number of individual in the group.

Definition at line 479 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 exceeds the total of LocusInfo of the DataSet.

Definition at line 998 of file DataSet.cpp.

References analyzedLoci_.

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 exceeds the number of individuals of the group.

Definition at line 320 of file DataSet.cpp.

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

Member Data Documentation

◆ analyzedLoci_

◆ groups_

◆ localities_

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

◆ sequenceAlphabet_

std::shared_ptr<const Alphabet> bpp::DataSet::sequenceAlphabet_
private

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