text:
// This file is auto-generated, don't edit it. Thanks.

#include <alibabacloud/ebs_20210730.hpp>
#include <alibabacloud/endpoint_util.hpp>
#include <alibabacloud/open_api.hpp>
#include <alibabacloud/open_api_util.hpp>
#include <boost/any.hpp>
#include <boost/throw_exception.hpp>
#include <darabonba/core.hpp>
#include <darabonba/util.hpp>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

using namespace Alibabacloud_Ebs20210730;

Alibabacloud_Ebs20210730::Client::Client(const shared_ptr<Alibabacloud_OpenApi::Config>& config) : Alibabacloud_OpenApi::Client(config) {
  _endpointRule = make_shared<string>("");
  checkConfig(config);
  _endpoint = make_shared<string>(getEndpoint(make_shared<string>("ebs"), _regionId, _endpointRule, _network, _suffix, _endpointMap, _endpoint));
};

string Alibabacloud_Ebs20210730::Client::getEndpoint(shared_ptr<string> productId,
                                                     shared_ptr<string> regionId,
                                                     shared_ptr<string> endpointRule,
                                                     shared_ptr<string> network,
                                                     shared_ptr<string> suffix,
                                                     shared_ptr<map<string, string>> endpointMap,
                                                     shared_ptr<string> endpoint) {
  if (!Darabonba_Util::Client::empty(endpoint)) {
    return *endpoint;
  }
  if (!Darabonba_Util::Client::isUnset<map<string, string>>(endpointMap) && !Darabonba_Util::Client::empty(make_shared<string>((*endpointMap)[regionId]))) {
    return (*endpointMap)[regionId];
  }
  return Alibabacloud_EndpointUtil::Client::getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

CreateDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::createDiskReplicaPairWithOptions(shared_ptr<CreateDiskReplicaPairRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  query->insert(pair<string, long>("Bandwidth", *request->bandwidth));
  query->insert(pair<string, string>("ChargeType", *request->chargeType));
  query->insert(pair<string, string>("ClientToken", *request->clientToken));
  query->insert(pair<string, string>("Description", *request->description));
  query->insert(pair<string, string>("DestinationDiskId", *request->destinationDiskId));
  query->insert(pair<string, string>("DestinationRegionId", *request->destinationRegionId));
  query->insert(pair<string, string>("DestinationZoneId", *request->destinationZoneId));
  query->insert(pair<string, string>("DiskId", *request->diskId));
  query->insert(pair<string, string>("PairName", *request->pairName));
  query->insert(pair<string, long>("Period", *request->period));
  query->insert(pair<string, string>("PeriodUnit", *request->periodUnit));
  query->insert(pair<string, string>("SourceRegionId", *request->sourceRegionId));
  query->insert(pair<string, string>("SourceZoneId", *request->sourceZoneId));
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))},
    {"body", boost::any(Darabonba_Util::Client::toMap(request))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("CreateDiskReplicaPair"))},
    {"version", boost::any(string("2021-07-30"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("json"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return CreateDiskReplicaPairResponse(callApi(params, req, runtime));
}

CreateDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::createDiskReplicaPair(shared_ptr<CreateDiskReplicaPairRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return createDiskReplicaPairWithOptions(request, runtime);
}

DeleteDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::deleteDiskReplicaPairWithOptions(shared_ptr<DeleteDiskReplicaPairRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  query->insert(pair<string, string>("ClientToken", *request->clientToken));
  query->insert(pair<string, string>("RegionId", *request->regionId));
  query->insert(pair<string, string>("ReplicaPairId", *request->replicaPairId));
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))},
    {"body", boost::any(Darabonba_Util::Client::toMap(request))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("DeleteDiskReplicaPair"))},
    {"version", boost::any(string("2021-07-30"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("json"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return DeleteDiskReplicaPairResponse(callApi(params, req, runtime));
}

DeleteDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::deleteDiskReplicaPair(shared_ptr<DeleteDiskReplicaPairRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return deleteDiskReplicaPairWithOptions(request, runtime);
}

DescribeDiskReplicaPairsResponse Alibabacloud_Ebs20210730::Client::describeDiskReplicaPairsWithOptions(shared_ptr<DescribeDiskReplicaPairsRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  query->insert(pair<string, long>("MaxResults", *request->maxResults));
  query->insert(pair<string, string>("NextToken", *request->nextToken));
  query->insert(pair<string, string>("PairIds", *request->pairIds));
  query->insert(pair<string, string>("RegionId", *request->regionId));
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))},
    {"body", boost::any(Darabonba_Util::Client::toMap(request))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("DescribeDiskReplicaPairs"))},
    {"version", boost::any(string("2021-07-30"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("json"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return DescribeDiskReplicaPairsResponse(callApi(params, req, runtime));
}

DescribeDiskReplicaPairsResponse Alibabacloud_Ebs20210730::Client::describeDiskReplicaPairs(shared_ptr<DescribeDiskReplicaPairsRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeDiskReplicaPairsWithOptions(request, runtime);
}

DescribeRegionsResponse Alibabacloud_Ebs20210730::Client::describeRegionsWithOptions(shared_ptr<DescribeRegionsRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  query->insert(pair<string, string>("AcceptLanguage", *request->acceptLanguage));
  query->insert(pair<string, string>("ResourceType", *request->resourceType));
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))},
    {"body", boost::any(Darabonba_Util::Client::toMap(request))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("DescribeRegions"))},
    {"version", boost::any(string("2021-07-30"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("json"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return DescribeRegionsResponse(callApi(params, req, runtime));
}

DescribeRegionsResponse Alibabacloud_Ebs20210730::Client::describeRegions(shared_ptr<DescribeRegionsRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return describeRegionsWithOptions(request, runtime);
}

FailoverDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::failoverDiskReplicaPairWithOptions(shared_ptr<FailoverDiskReplicaPairRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  query->insert(pair<string, string>("ClientToken", *request->clientToken));
  query->insert(pair<string, string>("RegionId", *request->regionId));
  query->insert(pair<string, string>("ReplicaPairId", *request->replicaPairId));
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))},
    {"body", boost::any(Darabonba_Util::Client::toMap(request))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("FailoverDiskReplicaPair"))},
    {"version", boost::any(string("2021-07-30"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("json"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return FailoverDiskReplicaPairResponse(callApi(params, req, runtime));
}

FailoverDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::failoverDiskReplicaPair(shared_ptr<FailoverDiskReplicaPairRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return failoverDiskReplicaPairWithOptions(request, runtime);
}

ModifyDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::modifyDiskReplicaPairWithOptions(shared_ptr<ModifyDiskReplicaPairRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  query->insert(pair<string, string>("ClientToken", *request->clientToken));
  query->insert(pair<string, string>("Description", *request->description));
  query->insert(pair<string, string>("PairName", *request->pairName));
  query->insert(pair<string, string>("RegionId", *request->regionId));
  query->insert(pair<string, string>("ReplicaPairId", *request->replicaPairId));
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))},
    {"body", boost::any(Darabonba_Util::Client::toMap(request))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("ModifyDiskReplicaPair"))},
    {"version", boost::any(string("2021-07-30"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("json"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return ModifyDiskReplicaPairResponse(callApi(params, req, runtime));
}

ModifyDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::modifyDiskReplicaPair(shared_ptr<ModifyDiskReplicaPairRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return modifyDiskReplicaPairWithOptions(request, runtime);
}

ReprotectDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::reprotectDiskReplicaPairWithOptions(shared_ptr<ReprotectDiskReplicaPairRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  query->insert(pair<string, string>("ClientToken", *request->clientToken));
  query->insert(pair<string, string>("RegionId", *request->regionId));
  query->insert(pair<string, string>("ReplicaPairId", *request->replicaPairId));
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))},
    {"body", boost::any(Darabonba_Util::Client::toMap(request))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("ReprotectDiskReplicaPair"))},
    {"version", boost::any(string("2021-07-30"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("json"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return ReprotectDiskReplicaPairResponse(callApi(params, req, runtime));
}

ReprotectDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::reprotectDiskReplicaPair(shared_ptr<ReprotectDiskReplicaPairRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return reprotectDiskReplicaPairWithOptions(request, runtime);
}

StartDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::startDiskReplicaPairWithOptions(shared_ptr<StartDiskReplicaPairRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  query->insert(pair<string, string>("ClientToken", *request->clientToken));
  query->insert(pair<string, string>("RegionId", *request->regionId));
  query->insert(pair<string, string>("ReplicaPairId", *request->replicaPairId));
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))},
    {"body", boost::any(Darabonba_Util::Client::toMap(request))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("StartDiskReplicaPair"))},
    {"version", boost::any(string("2021-07-30"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("json"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return StartDiskReplicaPairResponse(callApi(params, req, runtime));
}

StartDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::startDiskReplicaPair(shared_ptr<StartDiskReplicaPairRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return startDiskReplicaPairWithOptions(request, runtime);
}

StopDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::stopDiskReplicaPairWithOptions(shared_ptr<StopDiskReplicaPairRequest> request, shared_ptr<Darabonba_Util::RuntimeOptions> runtime) {
  Darabonba_Util::Client::validateModel(request);
  shared_ptr<map<string, boost::any>> query = make_shared<map<string, boost::any>>(map<string, boost::any>());
  query->insert(pair<string, string>("ClientToken", *request->clientToken));
  query->insert(pair<string, string>("RegionId", *request->regionId));
  query->insert(pair<string, string>("ReplicaPairId", *request->replicaPairId));
  shared_ptr<Alibabacloud_OpenApi::OpenApiRequest> req = make_shared<Alibabacloud_OpenApi::OpenApiRequest>(map<string, boost::any>({
    {"query", boost::any(Alibabacloud_OpenApiUtil::Client::query(query))},
    {"body", boost::any(Darabonba_Util::Client::toMap(request))}
  }));
  shared_ptr<Alibabacloud_OpenApi::Params> params = make_shared<Alibabacloud_OpenApi::Params>(map<string, boost::any>({
    {"action", boost::any(string("StopDiskReplicaPair"))},
    {"version", boost::any(string("2021-07-30"))},
    {"protocol", boost::any(string("HTTPS"))},
    {"pathname", boost::any(string("/"))},
    {"method", boost::any(string("POST"))},
    {"authType", boost::any(string("AK"))},
    {"style", boost::any(string("RPC"))},
    {"reqBodyType", boost::any(string("json"))},
    {"bodyType", boost::any(string("json"))}
  }));
  return StopDiskReplicaPairResponse(callApi(params, req, runtime));
}

StopDiskReplicaPairResponse Alibabacloud_Ebs20210730::Client::stopDiskReplicaPair(shared_ptr<StopDiskReplicaPairRequest> request) {
  shared_ptr<Darabonba_Util::RuntimeOptions> runtime = make_shared<Darabonba_Util::RuntimeOptions>();
  return stopDiskReplicaPairWithOptions(request, runtime);
}

max_stars_repo_name: aliyun/alibabacloud-cpp-sdk

max_issues_repo_name: aliyun/alibabacloud-cpp-sdk

max_forks_repo_name: aliyun/alibabacloud-cpp-sdk


text:
// All content Copyright (C) 2018 Genomics plc
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include "caller/haplotypeLikelihoods.hpp"
#include "alignment/aligner.hpp"
#include "utils/matrix.hpp"

namespace wecall
{
namespace caller
{
    std::vector< double > computeHaplotypeFrequencies( const utils::matrix_t & haplotypeLikelihoods )
    {
        std::vector< double > haplotypeFrequencies( haplotypeLikelihoods.size2(), 0.0 );
        for ( std::size_t haplotypeIndex = 0; haplotypeIndex != haplotypeLikelihoods.size2(); ++haplotypeIndex )
        {
            const auto column = utils::matrixColumn_t( haplotypeLikelihoods, haplotypeIndex );
            const auto hapFreq = std::accumulate( column.begin(), column.end(), 0.0 );
            haplotypeFrequencies[haplotypeIndex] = hapFreq;
        }
        return haplotypeFrequencies;
    }

    utils::matrix_t computeHaplotypeLikelihoods( const variant::HaplotypeVector & haplotypes,
                                                 const io::RegionsReads & readRange )
    {
        const auto nReads = static_cast< std::size_t >( std::distance( readRange.begin(), readRange.end() ) );
        const auto haplotypeSeqStart = haplotypes.paddedReferenceSequence()->start();

        utils::matrix_t readScores( nReads, haplotypes.size() );

        for ( std::size_t haplotypeIndex = 0; haplotypeIndex < haplotypes.size(); ++haplotypeIndex )
        {
            const auto & paddedHaplotypeSequences = haplotypes[haplotypeIndex].paddedSequences();

            std::vector< mapping::HashMapper > hashMappers;
            std::vector< alignment::GAlign > aligners;
            for ( const auto & paddedHaplotypeSequence : paddedHaplotypeSequences )
            {
                hashMappers.emplace_back( paddedHaplotypeSequence, constants::needlemanWunschPadding,
                                          constants::needlemanWunschPadding );
                aligners.emplace_back(
                    paddedHaplotypeSequence, constants::gapExtendPenalty, constants::nucleotidePrior,
                    alignment::computeGapOpen( paddedHaplotypeSequence, errorModels::illuminaErrorModel ) );
            }

            std::size_t readIndex = 0;
            for ( const auto & read : readRange )
            {
                const auto hintPosition = read.getStartPos() - haplotypeSeqStart;
                double maxReadScore = 0.0;
                for ( std::size_t sequenceIndex = 0; sequenceIndex < paddedHaplotypeSequences.size(); ++sequenceIndex )
                {
                    maxReadScore = std::max(
                        maxReadScore, computeLikelihoodForReadAndHaplotype(
                                          read, hintPosition, hashMappers[sequenceIndex], aligners[sequenceIndex] ) );
                }

                readScores( readIndex, haplotypeIndex ) = maxReadScore;
                ++readIndex;
            }
        }

        int64_t maxMappingQual = 0L;
        for ( const auto & read : readRange )
        {
            maxMappingQual = std::max( maxMappingQual, read.getMappingQuality() );
        }

        const double maxDifference = stats::fromPhredQ( maxMappingQual );

        utils::smoothLowOutliers( readScores, maxDifference );

        if ( false )
        {
            const auto debugFunc = [&haplotypes, &readScores, &readRange]() -> std::string
            {
                std::stringstream debugMessage;
                debugMessage << "Haplotypes order:- ";
                for ( const auto & haplotype : haplotypes )
                {
                    debugMessage << std::endl
                                 << haplotype.toString();
                }

                debugMessage << std::endl;
                for ( std::size_t hap_index = 0; hap_index < readScores.size2(); ++hap_index )
                {
                    debugMessage << "\tHaplotype scores for : " << haplotypes[hap_index].toString() << std::endl;
                    for ( std::size_t read_index = 0; read_index < readScores.size1(); ++read_index )
                    {
                        debugMessage << readScores( read_index, hap_index ) << ", ";
                    }
                    debugMessage << std::endl;
                }
                return debugMessage.str();
            };
            WECALL_LOG( SUPER_DEBUG, debugFunc() );
        }

        return readScores;
    }
}
}

ext: cpp

max_stars_repo_name: dylex/wecall

max_issues_repo_name: dylex/wecall

max_forks_repo_name: dylex/wecall


text:
#include <cstdio>
#include <cstdlib>

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>

#include <boost/config.hpp>
#include <boost/tokenizer.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/graph/visitors.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/breadth_first_search.hpp>

static void die(const char *reason) {
  fprintf(stderr, "%s\n", reason);
  exit(1);
}

template <typename DistanceMap>
class bacon_number_recorder : public boost::default_bfs_visitor {
  DistanceMap d;
 public:
  bacon_number_recorder(DistanceMap dist) : d(dist) {}

  template <typename Edge, typename Graph>
  void tree_edge(Edge e, const Graph & g) const {
    typename boost::graph_traits<Graph>::vertex_descriptor
      u = boost::source(e, g), v = boost::target(e, g);
    d[v] = d[u] + 1;
  }
};

typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
  boost::property<boost::vertex_name_t, std::string>,
  boost::property<boost::edge_name_t, std::string>> Graph;

typedef boost::property_map<Graph, boost::vertex_name_t>::type actor_name_map_t;
typedef boost::property_map<Graph, boost::edge_name_t>::type movie_name_map_t;
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
typedef std::map<std::string, Vertex> NameVertexMap;

template <typename DistanceMap>
bacon_number_recorder<DistanceMap> rec_num(DistanceMap d) {
  return bacon_number_recorder<DistanceMap>(d);
}

int main(int argc, char *argv[]) {
  std::ifstream datafile(argc >= 2 ? argv[1] : "./kevin-bacon.dat");
  if(!datafile) die("No datafile given.");

  Graph g;
  actor_name_map_t actor_name = boost::get(boost::vertex_name, g);
  movie_name_map_t connecting_movie = boost::get(boost::edge_name, g);

  NameVertexMap actors;

  for(std::string line; std::getline(datafile, line); ) {
    boost::char_delimiters_separator<char> sep(false, "", ";");
    boost::tokenizer<> line_toks(line, sep);
    boost::tokenizer<>::iterator i = line_toks.begin();
    std::string actors_name = *i++;

    NameVertexMap::iterator pos;
    bool inserted;
    Vertex u, v;

    boost::tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex()));
    if(inserted) {
      u = boost::add_vertex(g);
      actor_name[u] = actors_name;
      pos->second = u;
    } else u = pos->second;

    std::string movie_name = *i++;

    boost::tie(pos, inserted) = actors.insert(std::make_pair(*i, Vertex()));
    if(inserted) {
      v = boost::add_vertex(g);
      actor_name[v] = *i;
      pos->second = v;
    } else v = pos->second;

    boost::graph_traits<Graph>::edge_descriptor e;
    boost::tie(e, inserted) = boost::add_edge(u, v, g);

    if(inserted) connecting_movie[e] = movie_name;
  }

  std::vector<int> bacon_number(boost::num_vertices(g));

  Vertex src = actors["Kevin Bacon"];
  bacon_number[src] = 0;

  boost::breadth_first_search(g, src, boost::visitor(rec_num(&bacon_number[0])));

  boost::graph_traits<Graph>::vertex_iterator i, end;
  for(boost::tie(i, end) = boost::vertices(g); i != end; ++i) {
    std::cout << actor_name[*i] << " has a Bacon number of " <<
      bacon_number[*i] << std::endl;
  }

  return EXIT_SUCCESS;
}


text:
// Copyright (c) 2018 Graphcore Ltd. All rights reserved.
#define BOOST_TEST_MODULE EarlyUnfoTest

#include <boost/test/unit_test.hpp>

#include <popart/error.hpp>
#include <popart/inputshapeinfo.hpp>
#include <popart/tensorinfo.hpp>

using namespace popart;

BOOST_AUTO_TEST_CASE(InputShapeInfo_Case1) {
  auto ei = popart::InputShapeInfo();

  BOOST_CHECK(ei.has("cat") == false);
  BOOST_CHECK(ei.getAllTensorIds().size() == 0);
  BOOST_CHECK_THROW(ei.get("cat"), popart::error);

  popart::TensorInfo input("FLOAT", std::vector<int64_t>({2, 2}));
  ei.add("cat", input);

  BOOST_CHECK(ei.has("cat") == true);
  BOOST_CHECK(ei.getAllTensorIds().size() == 1);
  auto &output = ei.get("cat");

  BOOST_CHECK(input == output);

  popart::InputShapeInfo ei2(ei);

  BOOST_CHECK(ei.has("cat") == true);
  BOOST_CHECK(ei2.has("cat") == true);
}


text:
//  (C) Copyright John Maddock 2005.
//  Use, modification and distribution are subject to the
//  Boost Software License, Version 1.0. (See accompanying file
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifdef TEST_STD_HEADERS
#include <complex>
#else
#include <boost/tr1/complex.hpp>
#endif

#include <boost/test/test_tools.hpp>
#include <boost/test/included/test_exec_monitor.hpp>
#include <boost/test/floating_point_comparison.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_floating_point.hpp>
#include <boost/mpl/if.hpp>
#include <boost/static_assert.hpp>

#include <iostream>
#include <iomanip>

#ifndef VERBOSE
#undef BOOST_MESSAGE
#define BOOST_MESSAGE(x)
#endif

//
// This test verifies that the complex-algorithms that are
// overloaded for scalar types produce the same result as casting
// the argument to a complex type, and calling the complex version
// of the algorithm.  Relative errors must be within 2e in order for
// the tests to pass.
//

template <class T, class U>
void do_check(const T& t, const U& u)
{
   static const T two = 2;
   static const T factor = std::pow(two, 1-std::numeric_limits<T>::digits) * 200;
   BOOST_STATIC_ASSERT((::boost::is_same<T,U>::value));
   BOOST_CHECK_CLOSE(t, u, factor);
}

template <class T, class U>
void do_check(const std::complex<T>& t, const std::complex<U>& u)
{
   BOOST_STATIC_ASSERT((::boost::is_same<T,U>::value));
   do_check(t.real(), u.real());
   do_check(t.imag(), u.imag());
}

template <class T>
void check_val(const T& val)
{
   typedef typename boost::mpl::if_< boost::is_floating_point<T>, T, double>::type real_type;
   typedef std::complex<real_type> complex_type;

   real_type rval = static_cast<real_type>(val);
   complex_type cval = rval;

   if(val)
   {
      std::cout << "    Testing std::arg.\n";
      do_check(std::arg(cval), std::arg(rval));
      do_check(std::arg(cval), std::arg(val));
   }
   std::cout << "    Testing std::norm.\n";
   do_check(std::norm(cval), std::norm(rval));
   do_check(std::norm(cval), std::norm(val));
   std::cout << "    Testing std::conj.\n";
   do_check(std::conj(cval), std::conj(rval));
   do_check(std::conj(cval), std::conj(val));
   std::cout << "    Testing std::polar.\n";
   do_check(std::polar(val), std::polar(rval));
   do_check(std::polar(val, 0), std::polar(rval, 0));
   do_check(std::polar(val, val), std::polar(rval, rval));
   do_check(std::polar(val, rval), std::polar(rval, val));
   std::cout << "    Testing std::real.\n";
   do_check(std::real(cval), std::real(rval));
   do_check(std::real(cval), std::real(val));
   std::cout << "    Testing std::imaj.\n";
   do_check(std::imag(cval), std::imag(rval));
   do_check(std::imag(cval), std::imag(val));
   if(val && !boost::is_floating_point<T>::value)
   {
      //
      // Note that these tests are not run for floating point
      // types as that would only test the std lib vendor's
      // implementation of pow, not our additional overloads.
      // Note that some std lib's do fail these tests, gcc on
      // Darwin is a particularly bad example !
      //
      std::cout << "    Testing std::pow.\n";
      do_check(std::pow(cval, cval), std::pow(cval, val));
      do_check(std::pow(cval, cval), std::pow(cval, rval));
      do_check(std::pow(cval, cval), std::pow(val, cval));
      do_check(std::pow(cval, cval), std::pow(rval, cval));
   }
}

void do_check(double i)
{
   std::cout << "Checking type double with value " << i << std::endl;
   check_val(i);
   std::cout << "Checking type float with value " << i << std::endl;
   check_val(static_cast<float>(i));
   std::cout << "Checking type long double with value " << i << std::endl;
   check_val(static_cast<long double>(i));
}

void do_check(int i)
{
   std::cout << "Checking type char with value " << i << std::endl;
   check_val(static_cast<char>(i));
   std::cout << "Checking type unsigned char with value " << i << std::endl;
   check_val(static_cast<unsigned char>(i));
   std::cout << "Checking type signed char with value " << i << std::endl;
   check_val(static_cast<signed char>(i));
   std::cout << "Checking type short with value " << i << std::endl;
   check_val(static_cast<short>(i));
   std::cout << "Checking type unsigned short with value " << i << std::endl;
   check_val(static_cast<unsigned short>(i));
   std::cout << "Checking type int with value " << i << std::endl;
   check_val(static_cast<int>(i));
   std::cout << "Checking type unsigned int with value " << i << std::endl;
   check_val(static_cast<unsigned int>(i));
   std::cout << "Checking type long with value " << i << std::endl;
   check_val(static_cast<long>(i));
   std::cout << "Checking type unsigned long with value " << i << std::endl;
   check_val(static_cast<unsigned long>(i));
#ifdef BOOST_HAS_LONG_LONG
   std::cout << "Checking type long long with value " << i << std::endl;
   check_val(static_cast<long long>(i));
   std::cout << "Checking type unsigned long long with value " << i << std::endl;
   check_val(static_cast<unsigned long long>(i));
#elif defined(BOOST_HAS_MS_INT64)
   std::cout << "Checking type __int64 with value " << i << std::endl;
   check_val(static_cast<__int64>(i));
   std::cout << "Checking type unsigned __int64 with value " << i << std::endl;
   check_val(static_cast<unsigned __int64>(i));
#endif
   do_check(static_cast<double>(i));
}

int test_main(int, char*[])
{
   do_check(0);
   do_check(0.0);
   do_check(1);
   do_check(1.5);
   do_check(0.5);
   return 0;
}


text:
#include "X4ConverterTools/model/Component.h"
#include <boost/algorithm/string.hpp>
#include <iostream>

using namespace boost::algorithm;
namespace model {

    Component::Component(std::shared_ptr<ConversionContext> ctx) : AbstractElement(ctx) {}

    Component::Component(pugi::xml_node node, std::shared_ptr<ConversionContext> ctx) : AbstractElement(ctx) {
        auto componentsNode = node.child("components");
        if (componentsNode.empty()) {
            throw std::runtime_error("<components> node not found");
        }

        auto componentNode = componentsNode.child("component");
        if (componentNode.empty()) {
            throw std::runtime_error("<component> node not found");
        }

        if (componentNode.next_sibling()) {
            std::cerr << "Warning, this file contains more than one component. Ignoring all but the first."
                      << std::endl;
        }

        if (!componentNode.attribute("name")) {
            throw std::runtime_error("Unnamed component!");
        }
        if (!componentNode.child("source")) {
            std::cerr << "source directory not specified" << std::endl;
        } else {
            // TODO verify not null
            std::string ref = componentNode.child("source").attribute("geometry").value();
            attrs["src"] = ref;
            ctx->SetSourcePathSuffix(ref);
        }

        for (auto attr: componentNode.attributes()) {
            auto name = std::string(attr.name());
            auto value = std::string(attr.value());
            if (name == "name") {
                setName(value);
            } else {
                attrs[name] = value;
            }
        }

        auto connectionsNode = componentNode.child("connections");
        if (connectionsNode.empty()) {
            throw std::runtime_error("No connections found!");
        }
        for (auto connectionNode : connectionsNode.children()) {
            connections.emplace_back(connectionNode, ctx, getName());
        }

        auto layersNode = componentNode.child("layers");
        if (layersNode.empty()) {
            std::cerr << "Warning, <layers> node not found";
        }
        auto layerNode = layersNode.child("layer");
        if (layerNode.next_sibling()) {
            std::cerr << "Warning, this file contains more than one layer. Ignoring all but the first." << std::endl;
        }

    }

    aiNode *Component::ConvertToAiNode() {
        auto result = new aiNode(getName());
        std::map<std::string, aiNode *> nodes;
        nodes[getName()] = result;
        populateAiNodeChildren(result, attrToAiNode());

        // Convert all the nodes
        for (auto conn : connections) {
            std::string connName = conn.getName();
            if (nodes.count(connName)) {
                throw std::runtime_error("Duplicate key is not allowed!" + connName);
            }
            nodes[connName] = conn.ConvertToAiNode();

            // TODO get rid of this getParts somehow
            for (auto part : conn.getParts()) {
                std::string partName = part.getName();
                if (nodes.count(partName)) {
                    throw std::runtime_error("Duplicate key is not allowed!" + partName);
                }
                auto partNode = nodes[connName]->FindNode(partName.c_str());
                if (partNode == nullptr) {
                    throw std::runtime_error("something has gone horribly wrong");
                }
                nodes[partName] = partNode;
            }
        }

        // Now to unflatten everything
        std::map<std::string, std::vector<aiNode *>> parentMap;
        for (auto conn: connections) {
            auto parentName = conn.getParentName();
            if (!nodes.count(parentName)) {
                throw std::runtime_error("Missing parent \"" + parentName + "\" on: \"" + conn.getName() + "\"");
            } else {
                std::cout << conn.getName() << " " << parentName << std::endl;
                auto connNode = nodes[conn.getName()];
                if (parentMap.count(parentName) == 0) {
                    parentMap[parentName] = std::vector<aiNode *>();
                }
                if (connNode == nullptr) {
                    throw std::runtime_error("null ainode");
                }
                parentMap[parentName].push_back(connNode);
            }
        }
        for (const auto &pair : parentMap) {
            auto parentNode = nodes[pair.first];
            populateAiNodeChildren(parentNode, pair.second);
        }

        // Now double check that we didn't miss anything
        for (auto conn: connections) {
            auto connNode = nodes[conn.getName()];
            if (connNode->mParent == nullptr) {
                throw std::runtime_error("connection" + conn.getName() + "lost its parent");
            }
        }
        for (const auto &pair : nodes) {
            if (pair.first == getName()) {
                continue;
            }
            if (pair.second->mParent == nullptr) {
                throw std::runtime_error(std::string(pair.second->mName.C_Str()) + "lost its parent");
            }
            for (int i = 0; i < pair.second->mNumChildren; i++) {
                if (pair.second->mChildren[i] == nullptr) {
                    throw std::runtime_error(std::string(pair.second->mName.C_Str()) + "has null child");
                }
            }
        }
        auto rootChildren = new aiNode *[1];
        rootChildren[0] = result;
        auto fakeRoot = new aiNode("ROOT");
        fakeRoot->addChildren(1, rootChildren);
        delete[] rootChildren;
        return fakeRoot;
    }

    void Component::ConvertFromAiNode(aiNode *node) {
        setName(node->mName.C_Str());
        for (int i = 0; i < node->mNumChildren; i++) {
            auto child = node->mChildren[i];
            std::string childName = child->mName.C_Str();
            if (childName.find("class") != std::string::npos || childName.find("src") != std::string::npos) {
                // TODO improve me to not risk accidental matches
                readAiNodeChild(node, child);
                continue;
            } else if (childName.find('*') == std::string::npos) {
                std::cerr << "Warning, possible non-component directly under root, ignoring: " << childName
                          << std::endl;
            } else if (starts_with(childName, "layer")) {
                layers.emplace_back(child, ctx);

            } else {
                connections.emplace_back(child, ctx);
                recurseOnChildren(child, ctx);
            }
        }
    }

    void Component::recurseOnChildren(aiNode *tgt, std::shared_ptr<ConversionContext> ctx) {
        std::string tgtName = tgt->mName.C_Str();
        bool is_connection = tgtName.find('*') != std::string::npos;
        for (int i = 0; i < tgt->mNumChildren; i++) {
            auto child = tgt->mChildren[i];
            std::string childName = child->mName.C_Str();
            if (childName.find('*') != std::string::npos) {
                if (is_connection) {
                    throw std::runtime_error("connection cannot have a connection as a parent!");
                }
                connections.emplace_back(child, ctx, tgtName);
            }
            recurseOnChildren(child, ctx);
        }

    }

    void Component::ConvertToGameFormat(pugi::xml_node out) {
        // TODO asset.xmf?
        if (std::string(out.name()) != "components") {
            throw std::runtime_error("Component should be under components element");
        }
        auto compNode = AddChildByAttr(out, "component", "name", getName());
        auto connsNode = AddChild(compNode, "connections");
        for (const auto &attr : attrs) {
            if (attr.first == "src") {
                AddChildByAttr(compNode, "source", "geometry", attr.second);
                // TODO compare to output path and confirm if wrong
                ctx->SetSourcePathSuffix(attr.second);
            } else {
                WriteAttr(compNode, attr.first, attr.second);
            }
        }
        for (auto conn : connections) {
            conn.ConvertToGameFormat(connsNode);
        }
    }

    unsigned long Component::getNumberOfConnections() {
        return connections.size();
    }
}