示例#1
0
文件: comptool.cpp 项目: stomk/dop
void CompTool::search_forward_matches(const string seq1_name, const string seq2_name, int* SA, BWT& bwt,
                                      const int kmer_size, const int slide_letters, const int max_num_matches){
    stringstream out_file;
    out_file << seq1_name << "__" << seq2_name << ".match." << kmer_size << ".forward";
    ofstream ofs(out_file.str().c_str());

    ofs << "#" << seq2_name << "\t" << seq1_name << endl;  // header

    for(int i = 0; i < seq2_size_ - kmer_size; i += slide_letters){
        int8_t* query = &seq2_[i];
        int lb, ub;  // lower- and upper-bound of matches in suffix array
        bwt.search(query, kmer_size, lb, ub);
        if(lb <= ub){
            for(int j = lb; j <= ub; j++){
                if(j == lb + max_num_matches) break;
                ofs << i << "\t" << SA[j] << endl;
            }
        }
    }
}
示例#2
0
文件: comptool.cpp 项目: stomk/dop
void CompTool::search_reverse_matches(const string seq1_name, const string seq2_name, int* SA, BWT& bwt,
                                      const int kmer_size, const int slide_letters, const int max_num_matches){
    stringstream out_file;
    out_file << seq1_name << "__" << seq2_name << ".match." << kmer_size << ".reverse";
    ofstream ofs(out_file.str().c_str());

    ofs << "#" << seq2_name << "\t" << seq1_name << endl;  // header

    int8_t* query = new int8_t[kmer_size];
    for(int i = kmer_size-1; i < seq2_size_ - 1; i += slide_letters){
        // convert k-mers to reverse complements
        for(int j = 0; j < kmer_size; j++)
            query[j] = num_char_ - seq2_[i-j];
        int lb, ub;  // lower- and upper-bound of matches in suffix array
        bwt.search(query, kmer_size, lb, ub);
        if(lb <= ub){
            for(int j = lb; j <= ub; j++){
                if(j == lb + max_num_matches) break;
                ofs << i << "\t" << SA[j] << endl;
            }
        }
    }
    delete[] query;
}