当前位置: 首页>>代码示例>>C++>>正文


C++ Mapping类代码示例

本文整理汇总了C++中Mapping的典型用法代码示例。如果您正苦于以下问题:C++ Mapping类的具体用法?C++ Mapping怎么用?C++ Mapping使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Mapping类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exit

void Aligner::align_internal(Alignment& alignment, vector<Alignment>* multi_alignments, Graph& g,
                             int64_t pinned_node_id, bool pin_left, int32_t max_alt_alns, bool print_score_matrices) {

    // check input integrity
    if (pin_left && !pinned_node_id) {
        cerr << "error:[Aligner] cannot choose pinned end in non-pinned alignment" << endl;
        exit(EXIT_FAILURE);
    }
    if (multi_alignments && !pinned_node_id) {
        cerr << "error:[Aligner] multiple traceback is not valid in local alignment, only pinned and global" << endl;
        exit(EXIT_FAILURE);
    }
    if (!(multi_alignments) && max_alt_alns != 1) {
        cerr << "error:[Aligner] cannot specify maximum number of alignments in single alignment" << endl;
        exit(EXIT_FAILURE);
    }


    // alignment pinning algorithm is based on pinning in bottom right corner, if pinning in top
    // left we need to reverse all the sequences first and translate the alignment back later

    // create reversed objects if necessary
    Graph reversed_graph;
    string reversed_sequence;
    if (pin_left) {
        reversed_sequence.resize(alignment.sequence().length());

        reverse_copy(alignment.sequence().begin(), alignment.sequence().end(), reversed_sequence.begin());
        reverse_graph(g, reversed_graph);
    }

    // choose forward or reversed objects
    Graph* align_graph;
    string* align_sequence;
    if (pin_left) {
        align_graph = &reversed_graph;
        align_sequence = &reversed_sequence;
    }
    else {
        align_graph = &g;
        align_sequence = alignment.mutable_sequence();
    }

    // convert into gssw graph and get the counterpart to pinned node (if pinning)
    gssw_node* pinned_node = nullptr;
    gssw_graph* graph = create_gssw_graph(*align_graph, pinned_node_id, &pinned_node);

    if (pinned_node_id & !pinned_node) {
        cerr << "error:[Aligner] pinned node for pinned alignment is not in graph" << endl;
        exit(EXIT_FAILURE);
    }

    // perform dynamic programming
    gssw_graph_fill(graph, (*align_sequence).c_str(),
                    nt_table, score_matrix,
                    gap_open, gap_extension, 15, 2);

    // traceback either from pinned position or optimal local alignment
    if (pinned_node) {
        // trace back pinned alignment
        gssw_graph_mapping** gms = gssw_graph_trace_back_pinned_multi (graph,
                                   pinned_node,
                                   max_alt_alns,
                                   (*align_sequence).c_str(),
                                   (*align_sequence).size(),
                                   nt_table,
                                   score_matrix,
                                   gap_open,
                                   gap_extension);

        if (pin_left) {
            // translate graph and mappings into original node space
            unreverse_graph(reversed_graph);
            for (int32_t i = 0; i < max_alt_alns; i++) {
                unreverse_graph_mapping(gms[i]);
            }
        }

        // convert optimal alignment and store it in the input Alignment object (in the multi alignment,
        // this will have been set to the first in the vector)
        if (gms[0]->score > 0) {
            // have a mapping, can just convert normally
            gssw_mapping_to_alignment(graph, gms[0], alignment, print_score_matrices);
        }
        else {
            // gssw will not identify mappings with 0 score, infer location based on pinning

            Mapping* mapping = alignment.mutable_path()->add_mapping();
            mapping->set_rank(1);

            // locate at the end of the node
            Position* position = mapping->mutable_position();
            position->set_node_id(pinned_node_id);
            position->set_offset(pin_left ? 0 : pinned_node->len);

            // soft clip
            Edit* edit = mapping->add_edit();
            edit->set_to_length(alignment.sequence().length());
            edit->set_sequence(alignment.sequence());
        }
//.........这里部分代码省略.........
开发者ID:JervenBolleman,项目名称:vg,代码行数:101,代码来源:gssw_aligner.cpp

示例2: compute_from_edit

void Pileups::compute_from_edit(NodePileup& pileup, int64_t& node_offset,
                                int64_t& read_offset,
                                const Node& node, const Alignment& alignment,
                                const Mapping& mapping, const Edit& edit) {
    string seq = edit.sequence();
    bool is_reverse = mapping.is_reverse();
    
    // ***** MATCH *****
    if (edit.from_length() == edit.to_length()) {
        assert (edit.from_length() > 0);
        make_match(seq, edit.from_length(), is_reverse);
        assert(seq.length() == edit.from_length());            
        int64_t delta = is_reverse ? -1 : 1;
        for (int64_t i = 0; i < edit.from_length(); ++i) {
            BasePileup* base_pileup = get_create_base_pileup(pileup, node_offset);
            // reference_base if empty
            if (base_pileup->num_bases() == 0) {
                base_pileup->set_ref_base(node.sequence()[node_offset]);
            } else {
                assert(base_pileup->ref_base() == node.sequence()[node_offset]);
            }
            // add base to bases field (converting to ,. if match)
            char base = seq[i];
            if (!edit.sequence().empty() &&
                base_equal(seq[i], node.sequence()[node_offset], is_reverse)) {
                base = is_reverse ? ',' : '.';
            }
            *base_pileup->mutable_bases() += base;
            // add quality if there
            if (!alignment.quality().empty()) {
                *base_pileup->mutable_qualities() += alignment.quality()[read_offset];
            }
            // pileup size increases by 1
            base_pileup->set_num_bases(base_pileup->num_bases() + 1);
            // move right along read, and left/right depending on strand on reference
            node_offset += delta;
            ++read_offset;
        }
    }
    // ***** INSERT *****
    else if (edit.from_length() < edit.to_length()) {
        make_insert(seq, is_reverse);
        assert(edit.from_length() == 0);
        // we define insert (like sam) as insertion between current and next
        // position (on forward node coordinates). this means an insertion before
        // offset 0 is invalid! 
        int64_t insert_offset =  is_reverse ? node_offset : node_offset - 1;
        if (insert_offset >= 0) {        
            BasePileup* base_pileup = get_create_base_pileup(pileup, insert_offset);
            // reference_base if empty
            if (base_pileup->num_bases() == 0) {
                base_pileup->set_ref_base(node.sequence()[insert_offset]);
            } else {
                assert(base_pileup->ref_base() == node.sequence()[insert_offset]);
            }
            // add insertion string to bases field
            // todo: should we reverse complement this if mapping is reversed ??? 
            base_pileup->mutable_bases()->append(seq);
            if (!alignment.quality().empty()) {
                *base_pileup->mutable_qualities() += alignment.quality()[read_offset];
            }
            // pileup size increases by 1
            base_pileup->set_num_bases(base_pileup->num_bases() + 1);
        }
        else {
            // todo: need to either forget about these, or extend pileup format.
            // easy solution: change insert to come before position, and just add
            // optional pileup at n+1st base of node.  would like to figure out
            // how samtools does it first...
            /*
            stringstream ss;
            ss << "Warning: pileup does not support insertions before 0th base in node."
               << " Offending edit: " << pb2json(edit) << endl;
#pragma omp critical(cerr)
            cerr << ss.str();
            */
        }
        // move right along read (and stay put on reference)
        read_offset += edit.to_length();
    }
    // ***** DELETE *****
    else {
        assert(edit.to_length() == 0);
        assert(edit.sequence().empty());
        int64_t del_start = !is_reverse ? node_offset :
            node_offset - edit.from_length() + 1;
        seq = node.sequence().substr(del_start, edit.from_length());
        make_delete(seq, is_reverse);
        BasePileup* base_pileup = get_create_base_pileup(pileup, node_offset);
        // reference_base if empty
        if (base_pileup->num_bases() == 0) {
            base_pileup->set_ref_base(node.sequence()[node_offset]);
        } else {
            assert(base_pileup->ref_base() == node.sequence()[node_offset]);
        }
        // add deletion string to bases field
        // todo: should we reverse complement this if mapping is reversed ??? 
        base_pileup->mutable_bases()->append(seq);
        if (!alignment.quality().empty()) {
            *base_pileup->mutable_qualities() += alignment.quality()[read_offset];
//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:vg,代码行数:101,代码来源:pileup.cpp

示例3: kernelPaintParticles3D

__global__ void
kernelPaintParticles3D(ParBox pb,
                       DataBox<PitchedBox<float3_X, DIM2> > image,
                       DataSpace<DIM2> transpose,
                       int slice,
                       uint32_t globalOffset,
                       uint32_t sliceDim,
                       Mapping mapper)
{
    typedef typename ParBox::FrameType FRAME;
    typedef typename MappingDesc::SuperCellSize Block;
    __shared__ FRAME *frame;
    __shared__ bool isValid;
    __syncthreads(); /*wait that all shared memory is initialised*/
    bool isImageThread = false;

    const DataSpace<simDim> threadId(threadIdx);
    const DataSpace<DIM2> localCell(threadId[transpose.x()], threadId[transpose.y()]);
    const DataSpace<simDim> block = mapper.getSuperCellIndex(DataSpace<simDim > (blockIdx));
    const DataSpace<simDim> blockOffset((block - 1) * Block::getDataSpace());


    int localId = threadIdx.z * Block::x * Block::y + threadIdx.y * Block::x + threadIdx.x;


    if (localId == 0)
        isValid = false;
    __syncthreads();

    //\todo: guard size should not be set to (fixed) 1 here
    const DataSpace<simDim> realCell(blockOffset + threadId); //delete guard from cell idx

#if(SIMDIM==DIM3)
    uint32_t globalCell = realCell[sliceDim] + globalOffset;

    if (globalCell == slice)
#endif
    {
        atomicExch((int*) &isValid, 1); /*WAW Error in cuda-memcheck racecheck*/
        isImageThread = true;
    }
    __syncthreads();

    if (!isValid)
        return;

    /*index in image*/
    DataSpace<DIM2> imageCell(
                              realCell[transpose.x()],
                              realCell[transpose.y()]);


    // counter is always DIM2
    typedef DataBox < PitchedBox< float_X, DIM2 > > SharedMem;
    extern __shared__ float_X shBlock[];
    __syncthreads(); /*wait that all shared memory is initialised*/

    const DataSpace<simDim> blockSize(blockDim);
    SharedMem counter(PitchedBox<float_X, DIM2 > ((float_X*) shBlock,
                                                  DataSpace<DIM2 > (),
                                                  blockSize[transpose.x()] * sizeof (float_X)));

    if (isImageThread)
    {
        counter(localCell) = float_X(0.0);
    }


    if (localId == 0)
    {
        frame = &(pb.getFirstFrame(block, isValid));
    }
    __syncthreads();

    while (isValid) //move over all Frames
    {
        PMACC_AUTO(particle,(*frame)[localId]);
        if (particle[multiMask_] == 1)
        {
            int cellIdx = particle[localCellIdx_];
            // we only draw the first slice of cells in the super cell (z == 0)
            const DataSpace<simDim> particleCellId(DataSpaceOperations<simDim>::template map<Block > (cellIdx));
#if(SIMDIM==DIM3)
            uint32_t globalParticleCell = particleCellId[sliceDim] + globalOffset + blockOffset[sliceDim];
            if (globalParticleCell == slice)
#endif
            {
                const DataSpace<DIM2> reducedCell(particleCellId[transpose.x()], particleCellId[transpose.y()]);
                atomicAddWrapper(&(counter(reducedCell)), particle[weighting_] / NUM_EL_PER_PARTICLE);
            }
        }
        __syncthreads();

        if (localId == 0)
        {
            frame = &(pb.getNextFrame(*frame, isValid));
        }
        __syncthreads();
    }

//.........这里部分代码省略.........
开发者ID:CodeLemon,项目名称:picongpu,代码行数:101,代码来源:Visualisation.hpp

示例4: gssw_graph_print_score_matrices

void Aligner::gssw_mapping_to_alignment(gssw_graph* graph,
                                        gssw_graph_mapping* gm,
                                        Alignment& alignment,
                                        bool print_score_matrices) {
    alignment.clear_path();
    alignment.set_score(gm->score);
    alignment.set_query_position(0);
    Path* path = alignment.mutable_path();
    //alignment.set_cigar(graph_cigar(gm));

    gssw_graph_cigar* gc = &gm->cigar;
    gssw_node_cigar* nc = gc->elements;
    int to_pos = 0;
    int from_pos = gm->position;
    //cerr << "gm->position " << gm->position << endl;
    string& to_seq = *alignment.mutable_sequence();
    //cerr << "-------------" << endl;

    if (print_score_matrices) {
        gssw_graph_print_score_matrices(graph, to_seq.c_str(), to_seq.size(), stderr);
        //cerr << alignment.DebugString() << endl;
    }

    for (int i = 0; i < gc->length; ++i, ++nc) {

        if (i > 0) from_pos = 0; // reset for each node after the first
        // check that the current alignment has a non-zero length
        gssw_cigar* c = nc->cigar;
        int l = c->length;
        if (l == 0) continue;
        gssw_cigar_element* e = c->elements;

        Node* from_node = (Node*) nc->node->data;
        string& from_seq = *from_node->mutable_sequence();
        Mapping* mapping = path->add_mapping();
        mapping->mutable_position()->set_node_id(nc->node->id);
        mapping->mutable_position()->set_offset(from_pos);
        mapping->set_rank(path->mapping_size());

        //cerr << from_node->id() << ":" << endl;

        for (int j=0; j < l; ++j, ++e) {
            Edit* edit;
            int32_t length = e->length;
            //cerr << e->length << e->type << endl;

            switch (e->type) {
            case 'M':
            case 'X':
            case 'N': {
                // do the sequences match?
                // emit a stream of "SNPs" and matches
                int h = from_pos;
                int last_start = from_pos;
                int k = to_pos;
                for ( ; h < from_pos + length; ++h, ++k) {
                    //cerr << h << ":" << k << " " << from_seq[h] << " " << to_seq[k] << endl;
                    if (from_seq[h] != to_seq[k]) {
                        // emit the last "match" region
                        if (h-last_start > 0) {
                            edit = mapping->add_edit();
                            edit->set_from_length(h-last_start);
                            edit->set_to_length(h-last_start);
                        }
                        // set up the SNP
                        edit = mapping->add_edit();
                        edit->set_from_length(1);
                        edit->set_to_length(1);
                        edit->set_sequence(to_seq.substr(k,1));
                        last_start = h+1;
                    }
                }
                // handles the match at the end or the case of no SNP
                if (h-last_start > 0) {
                    edit = mapping->add_edit();
                    edit->set_from_length(h-last_start);
                    edit->set_to_length(h-last_start);
                }
                to_pos += length;
                from_pos += length;
            }
            break;
            case 'D':
                edit = mapping->add_edit();
                edit->set_from_length(length);
                edit->set_to_length(0);
                from_pos += length;
                break;
            case 'I':
                edit = mapping->add_edit();
                edit->set_from_length(0);
                edit->set_to_length(length);
                edit->set_sequence(to_seq.substr(to_pos, length));
                to_pos += length;
                break;
            case 'S':
                // note that soft clips and insertions are semantically equivalent
                // and can only be differentiated by their position in the read
                // with soft clips coming at the start or end
                edit = mapping->add_edit();
//.........这里部分代码省略.........
开发者ID:JervenBolleman,项目名称:vg,代码行数:101,代码来源:gssw_aligner.cpp

示例5: Error

void CallStmt::ExpandFunction(FunctionDef *func, Fragment *fragment)
{
	size_t argCount = func->GetArgCount();

	// check number of parameters
	if (argCount != fParams.size())
	{
		Error(kErr_ParamCount).Raise(&fLocation);
		return;
	}

	/* statement should look like this:
	 *
	 * CallStmt
	 *   |
	 * InlineStmt
	 *   |
	 * ScopeStmt
	 *   |
	 * BlockStmt
	 *   /        |       \
	 * DeclareStmt...   body of function
	 */
	BlockStmt *block = new BlockStmt();
	SetBody( new InlineStmt(new ScopeStmt(block), func));

	Mapping mapping;

	for(size_t i=0; i<argCount; i++)
	{
		const Expr* arg = fParams[i];
		int var = func->GetArgVar(i);
		int val;

		switch(func->GetArgType(i))
		{
			case FunctionDef::kConstantArg:
				if (!arg->Evaluate(val))
				{
					Error(kErr_ParamType, "constant").Raise(&arg->GetLoc());
					return;
				}
				mapping.Add(var, new AtomExpr(kRCX_ConstantType, val, fLocation));
				break;
			case FunctionDef::kIntegerArg:
				val = gProgram->NextVirtualVar();
				mapping.Add(var, new AtomExpr(kRCX_VariableType, val, fLocation));
				{
					DeclareStmt *ds = new DeclareStmt(func->GetArgName(i), val, fLocation, 1, false, true);
					ds->SetInitialValue(arg->Clone(0));
					block->Add(ds);
				}
				break;
			case FunctionDef::kReferenceArg:
				val = arg->GetLValue();
				if (val == kIllegalVar)
				{
					Error(kErr_ParamType, "variable").Raise(&arg->GetLoc());
					return;
				}
				mapping.Add(var, new AtomExpr(kRCX_VariableType, val, fLocation));
				break;
			case FunctionDef::kConstRefArg:
				mapping.Add(var, arg->Clone(0));
				break;
			case FunctionDef::kSensorArg:
				if (RCX_VALUE_TYPE(arg->GetStaticEA()) != kRCX_InputValueType)
				{
					Error(kErr_ParamType, "sensor").Raise(&arg->GetLoc());
					return;
				}
				mapping.Add(var, arg->Clone(0));
				break;
                        case FunctionDef::kPointerArg:
                                if (!arg->LValueIsPointer())
                                {
                                    Error(kErr_ParamType, "pointer").Raise(&arg->GetLoc());
                                    return;
                                }
                                mapping.Add(var, arg->Clone(0));
                                break;
                        case FunctionDef::kConstPtrArg:
                                if (!arg->LValueIsPointer())
                                {
                                    Error(kErr_ParamType, "pointer").Raise(&arg->GetLoc());
                                    return;
                                }
                                val = gProgram->NextVirtualVar();
                                {
                                    DeclareStmt *ds = new DeclareStmt(func->GetArgName(i), val, fLocation, 1, true, true);
                                    ds->SetInitialValue(arg->Clone(0));
                                    block->Add(ds);
                                }
                                mapping.Add(var, new AtomExpr(kRCX_VariableType, val, fLocation, true));
                                break;
			default:
				Error(kErr_ParamType, "???").Raise(&fParams[i]->GetLoc());
				return;
		}
	}
//.........这里部分代码省略.........
开发者ID:jverne,项目名称:nqc,代码行数:101,代码来源:CallStmt.cpp

示例6: kernelPaintFields

__global__ void kernelPaintFields(
                                  EBox fieldE,
                                  BBox fieldB,
                                  JBox fieldJ,
                                  DataBox<PitchedBox<float3_X, DIM2> > image,
                                  DataSpace<DIM2> transpose,
                                  const int slice,
                                  const uint32_t globalOffset,
                                  const uint32_t sliceDim,
                                  Mapping mapper)
{
    typedef typename MappingDesc::SuperCellSize Block;
    const DataSpace<simDim> threadId(threadIdx);
    const DataSpace<simDim> block = mapper.getSuperCellIndex(DataSpace<simDim > (blockIdx));
    const DataSpace<simDim> cell(block * Block::getDataSpace() + threadId);
    const DataSpace<simDim> blockOffset((block - mapper.getGuardingSuperCells()) * Block::getDataSpace());


    const DataSpace<simDim> realCell(cell - MappingDesc::SuperCellSize::getDataSpace() * mapper.getGuardingSuperCells()); //delete guard from cell idx
    const DataSpace<DIM2> imageCell(
                                    realCell[transpose.x()],
                                    realCell[transpose.y()]);
    const DataSpace<simDim> realCell2(blockOffset + threadId); //delete guard from cell idx

#if (SIMDIM==DIM3)
    uint32_t globalCell = realCell2[sliceDim] + globalOffset;

    if (globalCell != slice)
        return;
#endif
    // set fields of this cell to vars
    typename BBox::ValueType field_b = fieldB(cell);
    typename EBox::ValueType field_e = fieldE(cell);
    typename JBox::ValueType field_j = fieldJ(cell);

#if(SIMDIM==DIM3)
    field_j = float3_X(
                       field_j.x() * CELL_HEIGHT * CELL_DEPTH,
                       field_j.y() * CELL_WIDTH * CELL_DEPTH,
                       field_j.z() * CELL_WIDTH * CELL_HEIGHT
                       );
#elif (SIMDIM==DIM2)
    field_j = float3_X(
                       field_j.x() * CELL_HEIGHT,
                       field_j.y() * CELL_WIDTH,
                       field_j.z() * CELL_WIDTH * CELL_HEIGHT
                       );
#endif

    // reset picture to black
    //   color range for each RGB channel: [0.0, 1.0]
    float3_X pic = float3_X(0., 0., 0.);

    // typical values of the fields to normalize them to [0,1]
    //
    pic.x() = visPreview::preChannel1(field_b / typicalFields<EM_FIELD_SCALE_CHANNEL1>::get().x(),
                                      field_e / typicalFields<EM_FIELD_SCALE_CHANNEL1>::get().y(),
                                      field_j / typicalFields<EM_FIELD_SCALE_CHANNEL1>::get().z());
    pic.y() = visPreview::preChannel2(field_b / typicalFields<EM_FIELD_SCALE_CHANNEL2>::get().x(),
                                      field_e / typicalFields<EM_FIELD_SCALE_CHANNEL2>::get().y(),
                                      field_j / typicalFields<EM_FIELD_SCALE_CHANNEL2>::get().z());
    pic.z() = visPreview::preChannel3(field_b / typicalFields<EM_FIELD_SCALE_CHANNEL3>::get().x(),
                                      field_e / typicalFields<EM_FIELD_SCALE_CHANNEL3>::get().y(),
                                      field_j / typicalFields<EM_FIELD_SCALE_CHANNEL3>::get().z());
    //visPreview::preChannel1Col::addRGB(pic,
    //                                   visPreview::preChannel1(field_b * typicalFields<EM_FIELD_SCALE_CHANNEL1>::get().x(),
    //                                                           field_e * typicalFields<EM_FIELD_SCALE_CHANNEL1>::get().y(),
    //                                                           field_j * typicalFields<EM_FIELD_SCALE_CHANNEL1>::get().z()),
    //                                   visPreview::preChannel1_opacity);
    //visPreview::preChannel2Col::addRGB(pic,
    //                                   visPreview::preChannel2(field_b * typicalFields<EM_FIELD_SCALE_CHANNEL2>::get().x(),
    //                                                           field_e * typicalFields<EM_FIELD_SCALE_CHANNEL2>::get().y(),
    //                                                           field_j * typicalFields<EM_FIELD_SCALE_CHANNEL2>::get().z()),
    //                                   visPreview::preChannel2_opacity);
    //visPreview::preChannel3Col::addRGB(pic,
    //                                   visPreview::preChannel3(field_b * typicalFields<EM_FIELD_SCALE_CHANNEL3>::get().x(),
    //                                                           field_e * typicalFields<EM_FIELD_SCALE_CHANNEL3>::get().y(),
    //                                                           field_j * typicalFields<EM_FIELD_SCALE_CHANNEL3>::get().z()),
    //                                   visPreview::preChannel3_opacity);


    // draw to (perhaps smaller) image cell
    image(imageCell) = pic;
}
开发者ID:CodeLemon,项目名称:picongpu,代码行数:84,代码来源:Visualisation.hpp

示例7: ASSERT_D

/**
   take in a configuration xml document and a system
   context and initialize the transport
*/
int
RpcHttpTransport::init(
    const DOMNode* config,
    RefCountedPtr<SysContext>& ctx,
    iRpcServer* masterServer)
{
    int res = -1;

    ASSERT_D(status() == keRpcNoState);

    REFCOUNTED_CAST(iSysComponent, StdLogger, ctx->getComponent( StdLogger::getRegistryName()), _logger);

    RefCountedPtr<ThdPool> pool;
    REFCOUNTED_CAST(iSysComponent, ThdPool, ctx->getComponent( ThdPool::getRegistryName()), pool);
    ASSERT_D(pool != NULL);

    // inititalize socket environment
    if (( config != NULL ) && ( config->getNodeType() == DOMNode::ELEMENT_NODE ))
    {
        const DOMElement* configElem = (const DOMElement*)config;

        String val;
        Mapping attrs;

        // first configure the server attributes
        DOMNodeList* nodes = DomUtils::getNodeList( configElem, RPC_LISTEN_PORT );
        if ( DomUtils::getNodeValue( (const DOMElement*)nodes->item( 0 ), &val, &attrs ) )
        {
            Mapping::const_iterator it = attrs.find( RPC_BACKLOG_ATTR );
            if( it != attrs.end() )
            {
                _port = StringUtils::toInt( val );
                _backlog = StringUtils::toInt( (*it).second );
            }
            else
            {
                CBLOGERR(_logger,
                         NTEXT("RpcHttpClientTransport::init: can't find attributes to server listener, using defaults"));
            }
        }


        // now configure the client attributes
        attrs.clear();
        nodes = DomUtils::getNodeList( configElem, RPC_PROXY_NAME );
        if ( DomUtils::getNodeValue( (const DOMElement*)nodes->item( 0 ), &val, &attrs ) )
        {
            Mapping::const_iterator it = attrs.find( RPC_PROXY_PORTATTR );
            if( it != attrs.end() )
            {
                _proxy = val;
                _proxyPort = StringUtils::toInt( (*it).second );
            }
            else
            {
                CBLOGERR(_logger,
                         NTEXT("RpcHttpClientTransport::init: can't find attributes to configure Proxy Port"));
            }
        }

        attrs.clear();
        nodes = DomUtils::getNodeList( configElem, RPC_CLIENT_RETRIES );
        if ( DomUtils::getNodeValue( (const DOMElement*)nodes->item( 0 ), &val, &attrs ) )
        {
            Mapping::const_iterator it = attrs.find( RPC_CLIENT_TOATTR );
            if( it != attrs.end() )
            {
                _retries = StringUtils::toInt( val );
                _sleepInterval = StringUtils::toInt( (*it).second );
            }
            else
            {
                CBLOGERR(_logger,
                         NTEXT("RpcHttpClientTransport::init: can't find attributes to configure client communications parameters"));
            }
        }

        // setup the rpc address for this server
        String address;
        address = Net::getHostName();
        address += COLON;
        address += StringUtils::toString( _port );

        _transportAddress.setTransport( RPC_HTTP_NAME );
        _transportAddress.setAddress( address );

        // all is well set the initial state
        res = 0;
        _state = keRpcInitted;
    }

    if ( res == 0 )
    {
        RefCountedPtr<MyThdFn> wfn(new MyThdFn( *this, &RpcHttpTransport::myWorkerFunction ));
        pool->add( 1, (RefCountedPtr<iRunnable> &)wfn );

//.........这里部分代码省略.........
开发者ID:CSanchezAustin,项目名称:cslib,代码行数:101,代码来源:RpcHttpTransport.cpp

示例8: SetLastError

bool NVMeshMender::MungeD3DX(  const NVMeshMender::VAVector& input, 
			               NVMeshMender::VAVector& output, 
					       const float bSmoothCreaseAngleRadians,
					       const float* pTextureMatrix,
					       const Option _FixTangents,
					       const Option _FixCylindricalTexGen,
                           const Option _WeightNormalsByFaceSize )
{
    typedef std::map< std::string, unsigned int > Mapping;
	typedef std::set< Edge > EdgeSet;
    typedef std::vector< std::set< unsigned int > > IdenticalVertices;

    IdenticalVertices IdenticalVertices_;

    Mapping inmap;
    Mapping outmap;

    for ( unsigned int a = 0; a < input.size(); ++a )
    {
        inmap[ input[ a ].Name_ ] = a;
    }

    for ( unsigned int b = 0; b < output.size(); ++b )
    {
        output[ b ].intVector_.clear();
        output[ b ].floatVector_.clear();
        outmap[ output[ b ].Name_ ] = b;
    }

    for ( unsigned int c = 0; c < output.size(); ++c )
    {
        // for every output that has a match in the input, just copy it over
        Mapping::iterator in = inmap.find( output[ c ].Name_ );
        if ( in != inmap.end() )
        {
            // copy over existing indices, position, or whatever
            output[ c ] = input[ (*in).second ];
        }
    }

    Mapping::iterator want = outmap.find( "indices" );
    Mapping::iterator have = inmap.find( "indices" );

    if ( have == inmap.end() )
    {
        SetLastError( "Missing indices from input" );
        return false;
    }
    if ( want == outmap.end() )
    {
        SetLastError( "Missing indices from output" );
        return false;
    }

    // Go through all required outputs & generate as necessary
    want = outmap.find( "position" );
    have = inmap.find( "position" );

    if ( have == inmap.end() )
    {
        SetLastError( "Missing position from input" );
        return false;
    }
    if ( want == outmap.end() )
    {
        SetLastError( "Missing position from output" );
        return false;
    }

    Mapping::iterator pos = outmap.find( "position" );
    VertexAttribute::FloatVector& positions = output[ (*pos).second ].floatVector_;
    D3DXVECTOR3* pPositions = (D3DXVECTOR3*)( &( positions[ 0 ] ) );

    std::set< unsigned int > EmptySet;

    for ( unsigned int i = 0; i < positions.size(); i += 3 )
    {
        IdenticalVertices_.push_back( EmptySet );
    }

	// initialize all attributes
	for ( unsigned int att = 0; att < output.size(); ++att )
	{
		if ( output[ att ].Name_ != "indices" )
		{
			if ( output[ att ].floatVector_.size() == 0 )
			{
				output[ att ].floatVector_ = positions;
			}
		}
	}

    Mapping::iterator ind = outmap.find( "indices" );
    VertexAttribute::IntVector& indices = output[ (*ind).second ].intVector_;
    int* pIndices = (int*)( &( indices[ 0 ] ) );

    D3DXVECTOR3* pNormals = 0;
    D3DXVECTOR3* pBiNormals = 0;
    D3DXVECTOR3* pTangents = 0;
    D3DXVECTOR3* pTex0 = 0;
//.........这里部分代码省略.........
开发者ID:Fliper12,项目名称:darkbasicpro,代码行数:101,代码来源:NVMeshMenderD3DX.cpp

示例9: store

bool ConfigDialog::store(Mapping& archive)
{
    archive.write("showViewMarker", viewMarkerCheck.isChecked());
    archive.write("directory", directoryEntry.string());
    archive.write("basename", basenameEntry.string());
    archive.write("checkStartTime", startTimeCheck.isChecked());
    archive.write("startTime", startTimeSpin.value());
    archive.write("checkFinishTime", finishTimeCheck.isChecked());
    archive.write("finishTime", finishTimeSpin.value());
    archive.write("fps", fpsSpin.value());
    archive.write("setSize", imageSizeCheck.isChecked());
    archive.write("width", imageWidthSpin.value());
    archive.write("height", imageHeightSpin.value());
    archive.write("mouseCursor", mouseCursorCheck.isChecked());
    return true;
}
开发者ID:kayusawa,项目名称:choreonoid,代码行数:16,代码来源:MovieRecorder.cpp

示例10: restore

void ConfigDialog::restore(const Mapping& archive)
{
    viewMarkerCheck.setChecked(archive.get("showViewMarker", viewMarkerCheck.isChecked()));
    directoryEntry.setText(archive.get("directory", directoryEntry.string()));
    basenameEntry.setText(archive.get("basename", basenameEntry.string()));
    startTimeCheck.setChecked(archive.get("checkStartTime", startTimeCheck.isChecked()));
    startTimeSpin.setValue(archive.get("startTime", startTimeSpin.value()));
    finishTimeCheck.setChecked(archive.get("checkFinishTime", finishTimeCheck.isChecked()));
    finishTimeSpin.setValue(archive.get("finishTime", finishTimeSpin.value()));
    fpsSpin.setValue(archive.get("fps", fpsSpin.value()));
    imageSizeCheck.setChecked(archive.get("setSize", imageSizeCheck.isChecked()));
    imageWidthSpin.setValue(archive.get("width", imageWidthSpin.value()));
    imageHeightSpin.setValue(archive.get("height", imageHeightSpin.value()));
    mouseCursorCheck.setChecked(archive.get("mouseCursor", mouseCursorCheck.isChecked()));
}
开发者ID:kayusawa,项目名称:choreonoid,代码行数:15,代码来源:MovieRecorder.cpp

示例11: restoreState

bool Task::restoreState(AbstractTaskSequencer* sequencer, const Mapping& archive)
{
    sequencer->setCurrentPhase(archive.get("phaseIndex", 0));
    return true;
}
开发者ID:arntanguy,项目名称:choreonoid,代码行数:5,代码来源:Task.cpp

示例12: storeState

bool Task::storeState(AbstractTaskSequencer* sequencer, Mapping& archive)
{
    archive.write("phaseIndex", sequencer->currentPhaseIndex());
    return true;
}
开发者ID:arntanguy,项目名称:choreonoid,代码行数:5,代码来源:Task.cpp

示例13: if

    Alignment Filter::depth_filter(Alignment& aln){
        if (use_avg && window_length != 0){

        }
        else if (use_avg != 0){

        }
        else{

        }

        Path path = aln.path();
        //TODO handle reversing mappings
        vector<int>* qual_window;
        if (window_length > 0){
            qual_window = new vector<int>();
        }

        for (int i = 0; i < path.mapping_size(); i++){
            Mapping mapping = path.mapping(i);
            Position start_pos = mapping.position();
            int64_t start_node = start_pos.node_id();
            int64_t start_offset = start_pos.offset();
            int64_t curr_offset_in_graph = 0;
            int64_t curr_offset_in_alignment = 0;
            stringstream pst;

            pst << start_node << "_" << curr_offset_in_graph;
            string p_hash = pst.str();
            for (int j = 0; j < mapping.edit_size(); j++){
                Edit ee = mapping.edit(j);
                if (ee.from_length() == ee.to_length() && ee.sequence() == ""){
                    if (!filter_matches){
                        continue;
                    }
                }
                stringstream est;
                est <<  ee.from_length() << "_" << ee.to_length() << "_" + ee.sequence();
                string e_hash = est.str();
#pragma omp critical(write)
                pos_to_edit_to_depth[p_hash][e_hash] += 1;
                /**
                 * If an edit fails the filter, either return a new empty alignment
                 * OR
                 * return a new alignment identical to the old one EXCEPT where
                 * the offending edit has been replaced by a match to the reference.
                 */
                if (pos_to_edit_to_depth[p_hash][e_hash] < min_depth){
                    if (!remove_failing_edits){
                        return inverse ? aln : Alignment();
                    }

                    else {
                        Alignment edited_aln = Alignment(aln);
                        edited_aln.mutable_path()->mutable_mapping(i)->mutable_edit(j)->set_sequence("");
                        edited_aln.mutable_path()->mutable_mapping(i)->mutable_edit(j)->set_from_length(ee.from_length());
                        edited_aln.mutable_path()->mutable_mapping(i)->mutable_edit(j)->set_to_length(ee.from_length());
                        return edited_aln;
                    }
                }
            }
            return inverse ? Alignment() : aln;
        }


    }
开发者ID:cmarkello,项目名称:vg,代码行数:66,代码来源:filter.cpp

示例14: merge_alignments

// merge that properly handles long indels
// assumes that alignments should line up end-to-end
Alignment merge_alignments(const vector<Alignment>& alns, bool debug) {

    if (alns.size() == 0) {
        Alignment aln;
        return aln;
    } else if (alns.size() == 1) {
        return alns.front();
    }

    // where possible get node and target lengths
    // to validate after merge
    /*
    map<int64_t, map<size_t, set<const Alignment*> > > node_lengths;
    map<int64_t, map<size_t, set<const Alignment*> > > to_lengths;
    for (auto& aln : alns) {
        auto& path = aln.path();
        // find a mapping that overlaps the whole node
        // note that edits aren't simplified
        // so deletions are intact
        for (size_t i = 0; i < path.mapping_size(); ++i) {
            auto& m = path.mapping(i);
            if (m.position().offset() == 0) {
                // can we see if the next mapping is on the following node
                if (i < path.mapping_size()-1 && path.mapping(i+1).position().offset() == 0
                    && mapping_from_length(path.mapping(i+1)) && mapping_from_length(m)) {
                    // we cover the node, record the to_length and from_length
                    set<const Alignment*>& n = node_lengths[m.position().node_id()][from_length(m)];
                    n.insert(&aln);
                    set<const Alignment*>& t = to_lengths[m.position().node_id()][to_length(m)];
                    t.insert(&aln);
                }
            }
        }
    }
    // verify our input by checking for disagreements
    for (auto& n : node_lengths) {
        auto& node_id = n.first;
        if (n.second.size() > 1) {
            cerr << "disagreement in node lengths for " << node_id << endl;
            for (auto& l : n.second) {
                cerr << "alignments that report length of " << l.first << endl;
                for (auto& a : l.second) {
                    cerr << pb2json(*a) << endl;
                }
            }
        } else {
            //cerr << n.second.begin()->second.size() << " alignments support "
            //     << n.second.begin()->first << " as length for " << node_id << endl;
        }
    }
    */
    
    // parallel merge algorithm
    // for each generation
    // merge 0<-0+1, 1<-2+3, ...
    // until there is only one alignment
    vector<Alignment> last = alns;

    // get the alignments ready for merge
#pragma omp parallel for
    for (size_t i = 0; i < last.size(); ++i) {
        Alignment& aln = last[i];
        //cerr << "on " << i << "th aln" << endl
        //     << pb2json(aln) << endl;
        if (!aln.has_path()) {
            Mapping m;
            Edit* e = m.add_edit();
            e->set_to_length(aln.sequence().size());
            e->set_sequence(aln.sequence());
            *aln.mutable_path()->add_mapping() = m;
        }
    }

    while (last.size() > 1) {
        //cerr << "last size " << last.size() << endl;
        size_t new_count = last.size()/2;
        //cerr << "new count b4 " << new_count << endl;
        new_count += last.size() % 2; // force binary
        //cerr << "New count = " << new_count << endl;
        vector<Alignment> curr; curr.resize(new_count);
#pragma omp parallel for
        for (size_t i = 0; i < curr.size(); ++i) {
            //cerr << "merging " << 2*i << " and " << 2*i+1 << endl;
            // take a pair from the old alignments
            // merge them into this one
            if (2*i+1 < last.size()) {
                auto& a1 = last[2*i];
                auto& a2 = last[2*i+1];
                curr[i] = merge_alignments(a1, a2, debug);
                // check that the merge did the right thing
                /*
                auto& a3 = curr[i];
                for (size_t j = 0; j < a3.path().mapping_size()-1; ++j) {
                    // look up reported node length
                    // and compare to what we saw
                    // skips last mapping
                    auto& m = a3.path().mapping(j);
                    if (from_length(m) == to_length(m)
//.........这里部分代码省略.........
开发者ID:ktym,项目名称:vg,代码行数:101,代码来源:alignment.cpp

示例15: operator

    DINLINE void operator()(ParBoxIons ionBox,
                                          ParBoxElectrons electronBox,
                                          FrameIonizer frameIonizer,
                                          Mapping mapper) const
    {

        /* "particle box" : container/iterator where the particles live in
         * and where one can get the frame in a super cell from
         */
        typedef typename ParBoxElectrons::FrameType ELECTRONFRAME;
        typedef typename ParBoxIons::FrameType IONFRAME;
        typedef typename ParBoxIons::FramePtr IonFramePtr;
        typedef typename ParBoxElectrons::FramePtr ElectronFramePtr;

        /* specify field to particle interpolation scheme */
        typedef typename PMacc::traits::Resolve<
            typename GetFlagType<IONFRAME,interpolation<> >::type
        >::type InterpolationScheme;

        /* margins around the supercell for the interpolation of the field on the cells */
        typedef typename GetMargin<InterpolationScheme>::LowerMargin LowerMargin;
        typedef typename GetMargin<InterpolationScheme>::UpperMargin UpperMargin;

        /* relevant area of a block */
        typedef SuperCellDescription<
            typename MappingDesc::SuperCellSize,
            LowerMargin,
            UpperMargin
            > BlockDescription_;

        /* for not mixing operations::assign up with the nvidia functor assign */
        namespace partOp = PMacc::particles::operations;

        /* definitions for domain variables, like indices of blocks and threads */
        typedef typename BlockDescription_::SuperCellSize SuperCellSize;
        /* multi-dimensional offset vector from local domain origin on GPU in units of super cells */
        const DataSpace<simDim> block(mapper.getSuperCellIndex(DataSpace<simDim > (blockIdx)));

        /* multi-dim vector from origin of the block to a cell in units of cells */
        const DataSpace<simDim > threadIndex(threadIdx);
        /* conversion from a multi-dim cell coordinate to a linear coordinate of the cell in its super cell */
        const int linearThreadIdx = DataSpaceOperations<simDim>::template map<SuperCellSize > (threadIndex);

        /* multi-dim offset from the origin of the local domain on GPU
         * to the origin of the block of the in unit of cells
         */
        const DataSpace<simDim> blockCell = block * SuperCellSize::toRT();

        /* subtract guarding cells to only have the simulation volume */
        const DataSpace<simDim> localCellIndex = (block * SuperCellSize::toRT() + threadIndex) - mapper.getGuardingSuperCells() * SuperCellSize::toRT();

        /* typedef for the functor that writes new macro electrons into electron frames during runtime */
        typedef typename particles::ionization::WriteElectronIntoFrame WriteElectronIntoFrame;


        PMACC_SMEM( ionFrame, IonFramePtr );
        PMACC_SMEM( electronFrame,ElectronFramePtr );
        PMACC_SMEM( maxParticlesInFrame, lcellId_t );


        /* find last frame in super cell
         * define maxParticlesInFrame as the maximum frame size
         */
        if (linearThreadIdx == 0)
        {
            ionFrame = ionBox.getLastFrame(block);
            maxParticlesInFrame = PMacc::math::CT::volume<SuperCellSize>::type::value;
        }

        __syncthreads();
        if (!ionFrame.isValid())
            return; //end kernel if we have no frames

        /* caching of E- and B- fields and initialization of random generator if needed */
        frameIonizer.init(blockCell, linearThreadIdx, localCellIndex);

        /* Declare counter in shared memory that will later tell the current fill level or
         * occupation of the newly created target electron frames.
         */
        PMACC_SMEM( newFrameFillLvl, int );

        /* Declare local variable oldFrameFillLvl for each thread */
        int oldFrameFillLvl;

        /* Initialize local (register) counter for each thread
         * - describes how many new macro electrons should be created
         */
        unsigned int newMacroElectrons = 0;

        /* Declare local electron ID
         * - describes at which position in the new frame the new electron is to be created
         */
        int electronId;

        /* Master initializes the frame fill level with 0 */
        if (linearThreadIdx == 0)
        {
            newFrameFillLvl = 0;
            electronFrame = nullptr;
        }
//.........这里部分代码省略.........
开发者ID:Fettpet,项目名称:picongpu,代码行数:101,代码来源:ionization.hpp


注:本文中的Mapping类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。