1

用于模式匹配的 SeqAn 教程提到StringSet' 可以充当干草堆或针头。在尝试StringSet如下使用 a 作为大海捞针时,

StringSet<Dna5String> seqs;

/* do stuff to load sequences into seqs */

Finder<StringSet<Dna5String> > finder(seqs);
Pattern<Dna5String, Simple> pattern(Dna5String("GAATTC"));

if (find(finder, pattern))
{
  std::cout << '[' << beginPosition(finder) << ',' << endPosition(finder)
            << ")\t" << infix(finder) << std::endl;
} else
{
  std::cout << "No match!";
}

我得到错误:

错误:重载运算符 '==' 的使用不明确(操作数类型为 'const const seqan::String, seqan::Alloc >' 和 'const seqan::SimpleType')

任何人都知道这应该如何正确完成?

Dna5String在作品中使用单曲Finder很好。本教程确实展示了如何进行离线搜索(即,使用索引),但这不是我想要的。StringSet如果 SeqAn 中的 Finder-Pattern 工具已经处理它,我宁愿不必手动迭代。

4

1 回答 1

1

你可以试试,

#include <iostream>
#include <seqan/sequence.h>  // CharString, ...
#include <seqan/find.h>
#include <seqan/stream.h>

using namespace seqan;

typedef Iterator<StringSet<Dna5String> >::Type TStringSetIterator;

int main(int, char const **)
{
    StringSet<Dna5String> seqs;
    Dna5String seq1 =
        "TAGGTTTTCCGAAAAGGTAGCAACTTTACGTGATCAAACCTCTGACGGGGTTTTCCCCGTCGAAATTGGGTG"
        "TTTCTTGTCTTGTTCTCACTTGGGGCATCTCCGTCAAGCCAAGAAAGTGCTCCCTGGATTCTGTTGCTAACG"
        "AGTCTCCTCTGCATTCCTGCTTGACTGATTGGGCGGACGGGGTGTCCACCTGACGCTGAGTATCGCCGTCAC"
        "GGTGCCACATGTCTTATCTATTCAGGGATCAGAATTCATTCAGGAAATCAGGAGATGCTACACTTGGGTTAT"
        "CGAAGCTCCTTCCAAGGCGTAGCAAGGGCGACTGAGCGCGTAAGCTCTAGATCTCCTCGTGTTGCAACTACA"
        "CGCGCGGGTCACTCGAAACACATAGTATGAACTTAACGACTGCTCGTACTGAACAATGCTGAGGCAGAAGAT"
        "CGCAGACCAGGCATCCCACTGCTTGAAAAAACTATNNNNCTACCCGCCTTTTTATTATCTCATCAGATCAAG";
    Dna5String seq2 =
        "ACCGACGATTAGCTTTGTCCGAGTTACAACGGTTCAATAATACAAAGGATGGCATAAACCCATTTGTGTGAA"
        "AGTGCCCATCACATTATGATTCTGTCTACTATGGTTAATTCCCAATATACTCTCGAAAAGAGGGTATGCTCC"
        "CACGGCCATTTACGTCACTAAAAGATAAGATTGCTCAAANNNNNNNNNACTGCCAACTTGCTGGTAGCTTCA"
        "GGGGTTGTCCACAGCGGGGGGTCGTATGCCTTTGTGGTATACCTTACTAGCCGCGCCATGGTGCCTAAGAAT"
        "GAAGTAAAACAATTGATGTGAGACTCGACAGCCAGGCTTCGCGCTAAGGACGCAAAGAAATTCCCTACATCA"
        "GACGGCCGCGNNNAACGATGCTATCGGTTAGGACATTGTGCCCTAGTATGTACATGCCTAATACAATTGGAT"
        "CAAACGTTATTCCCACACACGGGTAGAAGAACNNNNATTACCCGTAGGCACTCCCCGATTCAAGTAGCCGCG";

    clear(seqs);
    appendValue(seqs, seq1);
    appendValue(seqs, seq2);

    Pattern<Dna5String, Simple> pattern(Dna5String("GAATTC"));

    //For each sequence in seqs
    for (TStringSetIterator it = begin(seqs); it != end(seqs); ++it)
    {
        std::cout << *it << std::endl;
        //I create a finder for each sequence in seqs
        Finder<Dna5String> finder(*it);
        if (find(finder, pattern)){
            std::cout << '[' << beginPosition(finder) << ',' << endPosition(finder)
                      << ")\t" << infix(finder) << std::endl;
        }else{
            std::cout << "No match!" << std::endl;
        }
    }
    return 0;
}

你得到:

TAGGTTTTCCGAAAAGGTAGCAACTTTACGTGATCAAACCTCTGACGGGGTTTTCCCCGTCGAAATTGGGTGTTTCTTGTCTTGTTCTCACTTGGGGCATCTCCGTCAAGCCAAGAAAGTGCTCCCTGGATTCTGTTGCTAACGAGTCTCCTCTGCATTCCTGCTTGACTGATTGGGCGGACGGGGTGTCCACCTGACGCTGAGTATCGCCGTCACGGTGCCACATGTCTTATCTATTCAGGGATCAGAATTCATTCAGGAAATCAGGAGATGCTACACTTGGGTTATCGAAGCTCCTTCCAAGGCGTAGCAAGGGCGACTGAGCGCGTAAGCTCTAGATCTCCTCGTGTTGCAACTACACGCGCGGGTCACTCGAAACACATAGTATGAACTTAACGACTGCTCGTACTGAACAATGCTGAGGCAGAAGATCGCAGACCAGGCATCCCACTGCTTGAAAAAACTATNNNNCTACCCGCCTTTTTATTATCTCATCAGATCAAG
[247,253) GAATTC
ACCGACGATTAGCTTTGTCCGAGTTACAACGGTTCAATAATACAAAGGATGGCATAAACCCATTTGTGTGAAAGTGCCCATCACATTATGATTCTGTCTACTATGGTTAATTCCCAATATACTCTCGAAAAGAGGGTATGCTCCCACGGCCATTTACGTCACTAAAAGATAAGATTGCTCAAANNNNNNNNNACTGCCAACTTGCTGGTAGCTTCAGGGGTTGTCCACAGCGGGGGGTCGTATGCCTTTGTGGTATACCTTACTAGCCGCGCCATGGTGCCTAAGAATGAAGTAAAACAATTGATGTGAGACTCGACAGCCAGGCTTCGCGCTAAGGACGCAAAGAAATTCCCTACATCAGACGGCCGCGNNNAACGATGCTATCGGTTAGGACATTGTGCCCTAGTATGTACATGCCTAATACAATTGGATCAAACGTTATTCCCACACACGGGTAGAAGAACNNNNATTACCCGTAGGCACTCCCCGATTCAAGTAGCCGCG
不匹配!

编辑,我希望这对你有帮助

....
#include <seqan/index.h>
....

Pattern<Dna5String> pattern(Dna5String("GAATTC"));
Index< StringSet<Dna5String > > myIndex(seqs);
Finder< Index<StringSet<Dna5String > > > finder(myIndex);
while (find(finder, pattern)){
    std::cout << '[' << beginPosition(finder) << ',' << endPosition(finder)
              << ")\t" << infix(finder) << std::endl;
}   
....

你得到,

[< 0 , 247 >,< 0 , 253 >) GAATTC
于 2015-10-05T22:01:34.007 回答