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


C++ Paths::of_node方法代码示例

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


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

示例1: homogenize

void Homogenizer::homogenize(vg::VG* o_graph, xg::XG* xindex, gcsa::GCSA* gcsa_index, gcsa::LCPArray* lcp_index, Paths cached_paths, int kmer_size){

    bool in_mem_path_only = true;

    vector<id_t> tips = find_non_ref_tips(o_graph);

    /* TODO filter by whether a read is on the ref path
    // 2. Cache the reference path(s)
    // (Not sure how to grab these, so for now just grab the first path in the graph)
    map<string, list<Mapping> > cached_paths;
    set<string> kept_paths;
    */
    string ref_path = o_graph->paths.all_path_names()[0];

    //o_graph->unchop();
    /*
    Paths p = o_graph->paths;
    //
    // 3. Remove all paths in the graph, except the reference
    (o_graph->paths).keep_paths(kept_paths);
    */

    /* Generate edges/nodes to add to graph */
    //vector<MaximalExactMatch> find_smems(const string& seq);
    Mapper* mapper;
    mapper= new Mapper(xindex, gcsa_index, lcp_index);

    map<vg::id_t, vector<MaximalExactMatch> > matches;
    map<vg::id_t, string> ref_node_to_clip;
    vector<string> seqs;
    for (int i = 0; i < tips.size(); i++){
        Node* n = o_graph->get_node(tips[i]);
        if (n->sequence().length() < 4 || (o_graph->paths).has_node_mapping(n->id())){
            continue;
        }
        vector<MaximalExactMatch> m = mapper->find_mems_simple(n->sequence().begin(),
                                                               n->sequence().end(),
                                                               200,
                                                               mapper->min_mem_length);
        // Why >1? Because we need to match the node AND somewhere else in the graph.
        if (m.size() > 1){
            cerr << "POTENTIAL NEW EDGE" << endl;
            matches[tips[i]] = m;
            // map<id_t, map<string, set<Mapping*>>> node_mapping;
            // Get paths of tip
            set<string> paths_of_tip = cached_paths.of_node(tips[i]);
            // Find the closest reference node to the tip
            vg::id_t ref_node = -1;

            for (auto m : paths_of_tip){
                cerr << m << endl;
                Path path_of_tip = cached_paths.path(m);
                if (m == ref_path){
                    continue;     
                }
                else{
                    bool on_ref = false;
                    for (int j = 0; j < path_of_tip.mapping_size(); j++){
                        Mapping nearby_mapping = path_of_tip.mapping(j);
                        Position pos = nearby_mapping.position();
                        vg::id_t n_id = pos.node_id();
                        if (o_graph->paths.has_node_mapping(n_id)){
                            ref_node = n_id;
                            on_ref = true;
                        }
                        else if (on_ref == false && n_id != tips[i]){
                            ref_node = n_id;
                        }
                        else{
                            continue;
                        }

                    }
                }
            }
            if (ref_node != -1){
                ref_node_to_clip[ref_node] = n->sequence();
            }
        }
    }

    cerr << ref_node_to_clip.size() << " candidate edges generated. Modifying graph" << endl;

    //need to remove the tips sequences first.
    //cut_tips(tips, o_graph);

    vector<Path> new_p_vec;
    for (auto x : ref_node_to_clip){
        Alignment clip_aln;
        cerr << "Length of softclip: " << x.second.size() << endl;
        clip_aln = mapper->align(x.second);
        if (clip_aln.score() < 30){
            continue;
        }
        cerr << clip_aln.DebugString();
        Path new_aln_p = clip_aln.path();
        //new_p_vec.clear();
        new_p_vec.push_back(new_aln_p);
        //for (int i = 0; i < new_aln_p.mapping_size(); i++){
        //vector<Translation> tras = o_graph->edit(new_p_vec);
//.........这里部分代码省略.........
开发者ID:cmarkello,项目名称:vg,代码行数:101,代码来源:homogenizer.cpp


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