src/c++/lib/grmpy/CountAndGenotype.cpp
/**
 * main function for alignment and genotyping
 *
 * @param graphPath               If empty the alignment data of the first sample is used as graph
 * @param genotypingParameterPath path to genotyper settings
 * @param samples                 Collection of samples to genotype. Cannot be empty
 */
main function for alignment and genotyping
@param graphPath               If empty the alignment data of the first sample is used as graph
@param genotypingParameterPath path to genotyper settings
@param samples                 Collection of samples to genotype. Cannot be empty
main function for alignment and genotyping @param graphPath If empty the alignment data of the first sample is used as graph @param genotypingParameterPath path to genotyper settings @param samples Collection of samples to genotype . Cannot be empty
Json::Value countAndGenotype(
    const std::string& graphPath, const std::string& referencePath, const std::string& genotypingParameterPath,
    const genotyping::Samples& samples)
{
    LOG()->info("Running genotyper");
    Json::Value root = graphPath.empty() ? samples.front().get_alignment_data() : common::getJSON(graphPath);
    graphtools::Graph graph = grm::graphFromJson(root, referencePath, true);
    unsigned int male_ploidy = 2;
    unsigned int female_ploidy = 2;
    for (auto t_region : root["target_regions"])
    {
        std::stringstream ss(t_region.asString());
        std::string chrom;
        getline(ss, chrom, ':');
        if (chrom == "chrX" || chrom == "X")
        {
            male_ploidy = 1;
        }
        else if (chrom == "chrY" || chrom == "Y")
        {
            male_ploidy = 1;
            female_ploidy = 1;
        }
    }
    genotyping::GraphBreakpointGenotyper graph_genotyper(male_ploidy, female_ploidy);
    graph_genotyper.reset(&graph);
    graph_genotyper.setParameters(genotypingParameterPath);
    for (const genotyping::SampleInfo& sample_info : samples)
    {
        graph_genotyper.addAlignment(sample_info);
    }
    Json::Value ret = graph_genotyper.getGenotypes();
    LOG()->info("Done running genotyper");
    return ret;
}
Json :: Value countAndGenotype ( const std :: string & graphPath , const std :: string & referencePath , const std :: string & genotypingParameterPath , const genotyping :: Samples & samples ) { LOG ( ) -> info ( " " ) ; Json :: Value root = graphPath . empty ( ) ? samples . front ( ) . get_alignment_data ( ) : common :: getJSON ( graphPath ) ; graphtools :: Graph graph = grm :: graphFromJson ( root , referencePath , true ) ; unsigned int male_ploidy = 2 ; unsigned int female_ploidy = 2 ; for ( auto t_region : root [ " " ] ) { std :: stringstream ss ( t_region . asString ( ) ) ; std :: string chrom ; getline ( ss , chrom , ' ' ) ; if ( chrom == " " || chrom == " " ) { male_ploidy = 1 ; } else if ( chrom == " " || chrom == " " ) { male_ploidy = 1 ; female_ploidy = 1 ; } } genotyping :: GraphBreakpointGenotyper graph_genotyper ( male_ploidy , female_ploidy ) ; graph_genotyper . reset ( & graph ) ; graph_genotyper . setParameters ( genotypingParameterPath ) ; for ( const genotyping :: SampleInfo & sample_info : samples ) { graph_genotyper . addAlignment ( sample_info ) ; } Json :: Value ret = graph_genotyper . getGenotypes ( ) ; LOG ( ) -> info ( " " ) ; return ret ; }
main function for alignment and genotyping
 @param graphPath               If empty the alignment data of the first sample is used as graph
 @param genotypingParameterPath path to genotyper settings
 @param samples                 Collection of samples to genotype.
main function for alignment and genotyping @param graphPath If empty the alignment data of the first sample is used as graph @param genotypingParameterPath path to genotyper settings @param samples Collection of samples to genotype .
// Initialize walkable graph