29 throw IOException(
"GeneMapperCsvExport::read: fail to open stream.");
40 vector<string> ind_names;
41 vector<string> markers;
51 map<string, int> indname_marker;
54 string test_lab = dt(i, SAMPLE_NAME_H) + dt(i, MARKER_H);
55 if (indname_marker.find(test_lab) != indname_marker.end())
57 string new_lab = dt(i, SAMPLE_NAME_H) +
"_" +
TextTools::toString(indname_marker[test_lab] + 1);
58 dt (i, SAMPLE_NAME_H) = new_lab;
60 indname_marker[test_lab]++;
67 size_t loc_nbr = markers.size();
78 for (
unsigned int i = 0; i < ind_names.size(); i++)
91 vector<size_t> alleles_cols;
92 for (
size_t i = 0; i < col_names.size(); i++)
95 alleles_cols.push_back(i);
98 vector<vector<size_t>> alleles_pos;
99 for (
size_t i = 0; i < markers.size(); i++)
103 std::map< std::string, std::set< std::string >> markerAlleles;
106 for (
size_t j = 0; j < alleles_cols.size(); ++j)
108 if (dt(i, alleles_cols[j]) !=
"")
110 markerAlleles[dt(i, MARKER_H)].insert(dt(i, alleles_cols[j]));
114 for (std::map< std::string, std::set< std::string >>::iterator itm = markerAlleles.begin(); itm != markerAlleles.end(); itm++)
116 std::set< std::string >& s = itm->second;
117 for (std::set< std::string >::iterator its = s.begin(); its != s.end(); its++)
131 vector<size_t> alleles;
132 for (
size_t j = 0; j < alleles_cols.size(); j++)
136 unsigned int num = (dataset.
getLocusInfoByName(dt(i, mark_col_index))).getAlleleInfoKey(dt(i, alleles_cols[j]));
137 alleles.push_back(num);
181 size_t alleleNum = (itemNum - 7) / 4;
189 for (
unsigned int i = 0; i < alleleNum; ++i)
194 TextTools::to<unsigned int>(st.
getToken(5 + (2 * alleleNum) + i)),
virtual void read(std::istream &is, DataSet &data_set)=0
Read a DataSet on istream.
void addAlleleInfoByLocusName(const std::string &locusName, const AlleleInfo &allele)
Add an AlleleInfo to a LocusInfo by LocusInfo name.
void setLocusInfo(size_t locusPosition, const LocusInfo &locus)
Set a LocusInfo.
size_t getLocusInfoPosition(const std::string &locusName) const
Get the position of a LocusInfo.
The BasicAlleleInfo class.
void initAnalyzedLoci(size_t numberOfLoci)
Initialize the AnalyzedLoci for number of loci.
size_t getIndividualPositionInGroup(size_t groupPosition, const std::string &individual_id) const
Get the position of an Individual in a Group.
const AnalyzedLoci & analyzedLoci() const
Get the AnalyzedLoci if there is one.
void setAnalyzedLoci(const AnalyzedLoci &analyzedLoci)
Set the AnalyzedLoci to the DataSet.
size_t getGroupPosition(size_t group_id) const
Get the position of a Group.
const Individual & getIndividualByIdFromGroup(size_t groupPosition, const std::string &individualId) const
Get an Individual from a Group.
const LocusInfo & getLocusInfoByName(const std::string &locus_name) const
Get a LocusInfo by its name.
void addIndividualToGroup(size_t groupPosition, const Individual &individual)
Add an Individual to a Group.
void setIndividualMonolocusGenotypeInGroup(size_t groupPosition, size_t individualPosition, size_t locusPosition, const MonolocusGenotypeInterface &monogen)
Set a MonolocusGenotype of an Individual from a group.
void initIndividualGenotypeInGroup(size_t groupPosition, size_t individualPosition)
Initialize the genotype of an Individual in a Group.
void addEmptyGroup(size_t group_id)
Add an empty Group to the DataSet.
static std::unique_ptr< DataTable > read(std::istream &in, const std::string &sep="\t", bool header=true, int rowNames=-1)
std::vector< std::string > getColumnNames() const
std::vector< std::string > & getColumn(size_t index)
size_t getNumberOfRows() const
Store data for one allele.
Record(const std::string &row)
Constructor.
std::vector< GeneMapperCsvExport::Allele > alleles_
static const std::string PEAK_AREA_H
static const std::string SAMPLE_NAME_H
static const std::string SIZE_H
static const std::string MARKER_H
static const std::string ALLELE_H
static const std::string HEIGHT_H
static const std::string AN_H
static const std::string DYE_H
void read(std::istream &is, DataSet &data_set)
Read a DataSet on istream.
static const std::string SAMPLE_FILE_H
static const std::string PANEL_H
static const std::string DAC_H
static unsigned int UNKNOWN
The MultiAlleleMonolocusGenotype class.
size_t numberOfRemainingTokens() const
const std::string & getToken(size_t pos) const
double toDouble(const std::string &s, char dec='.', char scientificNotation='e')
bool isEmpty(const std::string &s)
bool startsWith(const std::string &s, const std::string &pattern)
std::string toString(T t)