52 throw IOException(
"DarwinVarSingle::write: fail to open stream.");
53 StlOutputStreamWrapper out(&os);
54 (out <<
"@DARwin 5.0 - SINGLE").endLine();
56 for (
size_t i = 0; i < data_set.getNumberOfGroups(); i++)
58 ind_nbr += data_set.getNumberOfIndividualsInGroup(i);
60 vector<string> header;
61 header.push_back(
"Unit");
62 for (
size_t i = 0; i < data_set.getNumberOfLoci(); i++)
64 const LocusInfo& li = data_set.getLocusInfoAtPosition(i);
70 size_t var_nbr = header.size() - 1;
72 (out << ind_nbr <<
"\t" << var_nbr).endLine();
73 VectorTools::print(header, out,
"\t");
76 for (
size_t i = 0; i < data_set.getNumberOfGroups(); i++)
78 size_t ind_nbr_ig = data_set.getNumberOfIndividualsInGroup(i);
79 for (
size_t j = 0; j < ind_nbr_ig; j++)
82 const MultilocusGenotype& geno = data_set.getIndividualAtPositionFromGroup(i, j)->getGenotype();
83 for (
size_t k = 0; k < geno.
size(); k++)
90 var.push_back(missingData_);
105 (out << j + (i * ind_nbr_ig) + 1 <<
"\t" << VectorTools::paste(var,
"\t")).endLine();
const MonolocusGenotype & getMonolocusGenotype(size_t locus_position) const
Get a MonolocusGenotype.
const AlleleInfo & getAlleleInfoByKey(size_t key) const
Retrieve an AlleleInfo object of the LocusInfo.
The MultilocusGenotype class.
bool isMonolocusGenotypeMissing(size_t locus_position) const
Tell if a MonolocusGenotype is a missing data.
std::vector< size_t > getNumberOfAlleles() const
Get the number of alleles at each locus.
const std::string & getName() const
Get the name of the locus.
size_t getNumberOfAlleles() const
Get the number of alleles at this locus.
virtual const std::string & getId() const =0
Get the identitier of the allele.
size_t size() const
Count the number of loci.
DarwinVarSingle(size_t missingData=999)
The MonolocusGenotype virtual class.
void write(std::ostream &os, const DataSet &data_set) const
Write a DataSet on ostream.
virtual void write(std::ostream &os, const DataSet &data_set) const =0
Write a DataSet on ostream.
virtual std::vector< size_t > getAlleleIndex() const =0
Get the alleles' index.