49 for (
size_t i = 0; i <
loci_.size(); i++)
69 for (
size_t i = 0; i <
loci_.size(); i++)
78 size_t locus_position,
80 throw (IndexOutOfBoundsException)
82 if (locus_position < loci_.size())
83 loci_[locus_position] =
new LocusInfo(locus);
85 throw IndexOutOfBoundsException(
"AnalyzedLoci::setLocusInfo: locus_position out of bounds",
86 locus_position, 0, loci_.size());
92 const std::string& locus_name)
const 95 for (
size_t i = 0; i < loci_.size(); i++)
97 if (loci_[i] != NULL && loci_[i]->getName() == locus_name)
106 const std::string& locus_name)
const 109 for (
size_t i = 0; i < loci_.size(); i++)
111 if (loci_[i] != NULL && loci_[i]->getName() == locus_name)
121 size_t locus_position)
const 124 if (locus_position >= loci_.size())
125 throw IndexOutOfBoundsException(
"AnalyzedLoci::getLocusInfoAtPosition: locus_position out of bounds.", locus_position, 0, loci_.size());
126 if (loci_[locus_position] != NULL)
127 return *(loci_[locus_position]);
129 throw NullPointerException(
"AnalyzedLoci::getLocusInfo: no locus defined here.");
139 bool locus_found =
false;
140 for (vector<LocusInfo*>::iterator it = loci_.begin(); it != loci_.end(); it++)
142 if ((*it)->getName() == locus_name)
147 (*it)->addAlleleInfo(allele);
166 if (locus_position < loci_.size())
170 loci_[locus_position]->addAlleleInfo(allele);
178 throw IndexOutOfBoundsException(
"AnalyzedLoci::addAlleleInfoByLocusPosition: locus_position out of bounds.",
179 locus_position, 0, loci_.size());
186 vector<size_t> allele_count;
187 for (
size_t i = 0; i <
loci_.size(); i++)
199 for (
size_t i = 0; i < loci_.size(); i++)
201 if (loci_[i] != NULL && loci_[i]->getName() == locus_name)
202 return loci_[i]->getPloidy();
211 throw (IndexOutOfBoundsException)
213 if (locus_position >= loci_.size())
214 throw IndexOutOfBoundsException(
"AnalyzedLoci::getPloidyByLocusPosition: locus_position out of bounds.", locus_position, 0, loci_.size());
215 return loci_[locus_position]->getPloidy();
size_t getNumberOfLoci() const
Get the number of loci.
size_t getLocusInfoPosition(const std::string &locus_name) const
Get the position of a LocusInfo.
void addAlleleInfoByLocusName(const std::string &locus_name, const AlleleInfo &allele)
Add an AlleleInfo to a LocusInfo by LocusInfo name.
const LocusInfo & getLocusInfoByName(const std::string &locus_name) const
Get a LocusInfo by name.
void addAlleleInfoByLocusPosition(size_t locus_position, const AlleleInfo &allele)
Add an AlleleInfo to a LocusInfo by its position.
The BadIdentifierException class.
unsigned int getPloidyByLocusPosition(size_t locus_position) const
Get the ploidy of a locus by its position.
virtual const std::string getIdentifier() const
Return the value of the identifier as a string.
const LocusInfo & getLocusInfoAtPosition(size_t locus_position) const
Get a LocusInfo by its position.
unsigned int getPloidyByLocusName(const std::string &locus_name) const
Get the ploidy of a locus by name.
std::vector< size_t > getNumberOfAlleles() const
Get the number of alleles at each locus.
void setLocusInfo(size_t locus_position, const LocusInfo &locus)
Set a LocusInfo.
std::vector< LocusInfo * > loci_
The AlleleInfo interface.
AnalyzedLoci(size_t number_of_loci)
Build a void AnalyzedLoci with a specific number of loci.
~AnalyzedLoci()
Destroy the AnalyzedLoci.
The LocusNotFoundException class.