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


C++ KmerCounter::get_reverse_kmer_candidates方法代码示例

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


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

示例1: traverse_path

void IRKE::traverse_path(KmerCounter &kcounter, Kmer_Occurence_Pair seed_kmer, Kmer_visitor &visitor,
                         Kmer_visitor &place_holder, float MIN_CONNECTIVITY_RATIO, unsigned int depth)
{

    if (IRKE_COMMON::MONITOR >= 3) {
        cerr << "traverse_path, depth: " << depth << ", kmer: " << kcounter.get_kmer_string(seed_kmer.first) << endl;
    }


    // check to see if visited already
    if (visitor.exists(seed_kmer.first)) {
        // already visited
        if (IRKE_COMMON::MONITOR >= 3) {
            cout << "\talready visited " << kcounter.get_kmer_string(seed_kmer.first) << endl;
        }

        return;
    }

    // check if at the end of the max recursion, and if so, don't visit it but set a placeholder.
    if (depth > MAX_RECURSION) {
        place_holder.add(seed_kmer.first);
        return;
    }

    visitor.add(seed_kmer.first);

    // try each of the forward paths from the kmer:
    vector<Kmer_Occurence_Pair> forward_candidates = kcounter.get_forward_kmer_candidates(seed_kmer.first);

    for (unsigned int i = 0; i < forward_candidates.size(); i++) {
        Kmer_Occurence_Pair kmer = forward_candidates[i];

        if (kmer.second && exceeds_min_connectivity(kcounter, seed_kmer, kmer, MIN_CONNECTIVITY_RATIO)) {

            traverse_path(kcounter, kmer, visitor, place_holder, MIN_CONNECTIVITY_RATIO, depth + 1);
        }
    }

    // try each of the reverse paths from the kmer:
    vector<Kmer_Occurence_Pair> reverse_candidates = kcounter.get_reverse_kmer_candidates(seed_kmer.first);

    for (unsigned int i = 0; i < reverse_candidates.size(); i++) {
        Kmer_Occurence_Pair kmer = reverse_candidates[i];

        if (kmer.second && exceeds_min_connectivity(kcounter, seed_kmer, kmer, MIN_CONNECTIVITY_RATIO)) {

            traverse_path(kcounter, kmer, visitor, place_holder, MIN_CONNECTIVITY_RATIO, depth + 1);
        }
    }


    return;

}
开发者ID:bowhan,项目名称:trinityrnaseq,代码行数:55,代码来源:IRKE.cpp

示例2: inchworm_step

Path_n_count_pair IRKE::inchworm_step (KmerCounter& kcounter, char direction, Kmer_Occurence_Pair kmer, Kmer_visitor& visitor,
									   Kmer_visitor& eliminator, unsigned int inchworm_round, unsigned int depth, 
									   float MIN_CONNECTIVITY_RATIO, unsigned int max_recurse) {
	
	// cout << "inchworm_step" << endl;
	
	if (IRKE_COMMON::MONITOR >= 2) {
		cerr << "\rinchworm: " << string(1,direction) 
			 << " A:" << INCHWORM_ASSEMBLY_COUNTER << " "
			 << " rnd:" << inchworm_round << " D:" << depth << "         "; 
	}
	
	// check to see if kmer exists.  If not, return empty container
	Path_n_count_pair best_path_n_pair;
	
		
	if ( !kmer.second
		 || visitor.exists(kmer.first) // visited
		 || eliminator.exists(kmer.first) // eliminated
		 
		 ) {
		
		// base case, already visited or kmer doesn't exist.
		//cout << kmer << "already visited or doesn't exist.  ending recursion at depth: " << depth << endl;
		
		return(best_path_n_pair);
		
	}
	
	visitor.add(kmer.first);
	
	if (PACMAN && depth > 0) {
		// cerr << "pacman eliminated kmer: " << kmer << endl;
		eliminator.add(kmer.first);
	}
	
	
	if (depth < max_recurse) {
		
		vector<Kmer_Occurence_Pair> kmer_candidates;
		if (direction == 'F') {
			// forward search
			kmer_candidates = kcounter.get_forward_kmer_candidates(kmer.first);
		}
		else {
			// reverse search
			kmer_candidates = kcounter.get_reverse_kmer_candidates(kmer.first);
		}
		
		bool tie = true;
		unsigned int recurse_cap = max_recurse;
		unsigned int best_path_length = 0;
		while (tie) {
			vector<Path_n_count_pair> paths;
			
			for (unsigned int i = 0; i < kmer_candidates.size(); i++) {
				Kmer_Occurence_Pair kmer_candidate = kmer_candidates[i];
				
				if (kmer_candidate.second // ) {
					&& !visitor.exists(kmer_candidate.first)  // avoid creating already visited kmers since they're unvisited below...
					&& exceeds_min_connectivity(kcounter, kmer, kmer_candidate, MIN_CONNECTIVITY_RATIO) ) {
					//cout << endl << "\ttrying " << kmer_candidate << endl;
					

                    // recursive call here for extension
					Path_n_count_pair p = inchworm_step(kcounter, direction, kmer_candidate, visitor, eliminator, inchworm_round, depth+1, MIN_CONNECTIVITY_RATIO, recurse_cap);
					
					paths.push_back(p);
					
					visitor.erase(kmer_candidate.first); // un-visiting
					
                }
				
			} // end for kmer
			
			
			if (paths.size() > 1) {
				
				sort(paths.begin(), paths.end(), compare);
				
				if (paths[0].second == paths[1].second   // same cumulative coverage values for both paths.
					&&
					// check last kmer to be sure they're different. 
					// Not interested in breaking ties between identically scoring paths that end up at the same kmer.
					paths[0].first[0] != paths[1].first[0]
					
					) {
					
					// got tie, two different paths and two different endpoints:
					if (IRKE_COMMON::MONITOR >= 3) {
						
						
						cerr << "Got tie! " << ", score: " << paths[0].second << ", recurse at: " << recurse_cap << endl;
						vector<unsigned int> v;
						cerr << reconstruct_path_sequence(kcounter, paths[0].first, v) << endl;
						cerr << reconstruct_path_sequence(kcounter, paths[1].first, v) << endl;
						
						
						
					}
//.........这里部分代码省略.........
开发者ID:Biocacahuete,项目名称:trinityrnaseq,代码行数:101,代码来源:IRKE.cpp

示例3: inchworm_step

Path_n_count_pair IRKE::inchworm_step(KmerCounter &kcounter,
                                      char direction,
                                      Kmer_Occurence_Pair kmer,
                                      Kmer_visitor &visitor,
                                      Kmer_visitor &eliminator,
                                      unsigned int inchworm_round,
                                      unsigned int depth,
                                      float MIN_CONNECTIVITY_RATIO,
                                      unsigned int max_recurse)
{

    // cout << "inchworm_step" << endl;

    if (IRKE_COMMON::MONITOR >= 2) {
        cerr << "\rinchworm: " << string(1, direction)
            << " A:" << INCHWORM_ASSEMBLY_COUNTER << " "
            << " rnd:" << inchworm_round << " D:" << depth << "         ";
    }

    // check to see if kmer exists.  If not, return empty container
    Path_n_count_pair best_path_n_pair;
    best_path_n_pair.second = 0; // init

    if ( // !kmer.second ||

        visitor.exists(kmer.first) // visited
            || eliminator.exists(kmer.first) // eliminated

        ) {

        if (IRKE_COMMON::MONITOR >= 3) {
            cerr << "base case, already visited or kmer doesn't exist." << endl;
            cerr << kmer.first << " already visited or doesn't exist.  ending recursion at depth: " << depth << endl;
        }

        return (best_path_n_pair);

    }

    visitor.add(kmer.first);

    if (PACMAN && depth > 0) {
        // cerr << "pacman eliminated kmer: " << kmer << endl;
        eliminator.add(kmer.first);
    }


    if (depth < max_recurse) {

        vector<Kmer_Occurence_Pair> kmer_candidates;
        if (direction == 'F') {
            // forward search
            kmer_candidates = kcounter.get_forward_kmer_candidates(kmer.first);
        }
        else {
            // reverse search
            kmer_candidates = kcounter.get_reverse_kmer_candidates(kmer.first);
        }

        if (IRKE_COMMON::MONITOR >= 3) {
            cerr << "Got " << kmer_candidates.size() << " kmer extension candidates." << endl;
        }

        bool tie = true;
        unsigned int recurse_cap = max_recurse;
        unsigned int best_path_length = 0;
        while (tie) {

            // keep trying to break ties if ties encountered.
            // this is done by increasing the allowed recursion depth until the tie is broken.
            //  Recursion depth set via: recurse_cap and incremented if tie is found


            vector<Path_n_count_pair> paths; // to collect all the paths rooting from this point

            for (unsigned int i = 0; i < kmer_candidates.size(); i++) {
                Kmer_Occurence_Pair kmer_candidate = kmer_candidates[i];

                if (kmer_candidate.second &&

                    !visitor.exists(kmer_candidate
                                        .first)  // avoid creating already visited kmers since they're unvisited below...
                    && exceeds_min_connectivity(kcounter, kmer, kmer_candidate, MIN_CONNECTIVITY_RATIO)) {
                    //cout << endl << "\ttrying " << kmer_candidate << endl;


                    // recursive call here for extension
                    Path_n_count_pair p = inchworm_step(kcounter,
                                                        direction,
                                                        kmer_candidate,
                                                        visitor,
                                                        eliminator,
                                                        inchworm_round,
                                                        depth + 1,
                                                        MIN_CONNECTIVITY_RATIO,
                                                        recurse_cap);

                    if (p.first.size() >= 1) {
                        // only retain paths that include visited nodes.
                        paths.push_back(p);
//.........这里部分代码省略.........
开发者ID:bowhan,项目名称:trinityrnaseq,代码行数:101,代码来源:IRKE.cpp


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