src/c++/lib/genotyping/GenotypeSet.cpp
/**
 * Add a genotype for a particular sample
 * @param allele_names names of all alleles in GT
 * @param gt genotype of the sample
 * @return sample index
 */
Add a genotype for a particular sample
@param allele_names names of all alleles in GT
@param gt genotype of the sample
@return sample index
Add a genotype for a particular sample @param allele_names names of all alleles in GT @param gt genotype of the sample @return sample index
size_t GenotypeSet::add(std::vector<std::string> const& allele_names, Genotype const& gt)
{
    genotypes.push_back(gt);
    Genotype& remapped_gt = genotypes.back();
    std::vector<uint64_t> gt_remapping(allele_names.size());
    size_t j = 0;
    for (auto const& a : allele_names)
    {
        auto a_it = std::find(merged_allele_names.begin(), merged_allele_names.end(), a);
        if (a_it == merged_allele_names.end())
        {
            gt_remapping[j] = merged_allele_names.size();
            merged_allele_names.push_back(a);
        }
        else
        {
            gt_remapping[j] = static_cast<unsigned long>(a_it - merged_allele_names.begin());
        }
        ++j;
    }
    remapped_gt.relabel(gt_remapping);
    return genotypes.size() - 1;
}
size_t GenotypeSet :: add ( std :: vector < std :: string > const & allele_names , Genotype const & gt ) { genotypes . push_back ( gt ) ; Genotype & remapped_gt = genotypes . back ( ) ; std :: vector < uint64_t > gt_remapping ( allele_names . size ( ) ) ; size_t j = 0 ; for ( auto const & a : allele_names ) { auto a_it = std :: find ( merged_allele_names . begin ( ) , merged_allele_names . end ( ) , a ) ; if ( a_it == merged_allele_names . end ( ) ) { gt_remapping [ j ] = merged_allele_names . size ( ) ; merged_allele_names . push_back ( a ) ; } else { gt_remapping [ j ] = static_cast < unsigned long > ( a_it - merged_allele_names . begin ( ) ) ; } ++ j ; } remapped_gt . relabel ( gt_remapping ) ; return genotypes . size ( ) - 1 ; }
Add a genotype for a particular sample
 @param allele_names names of all alleles in GT
 @param gt genotype of the sample
 @return sample index
Add a genotype for a particular sample @param allele_names names of all alleles in GT @param gt genotype of the sample @return sample index