如何将Fasta文件中的某些行提取到向量中

时间:2019-01-22 00:17:43

标签: c++ fasta

我有一个fasta文件,应该从中生成kmers。我正在尝试将“ <”符号后面的第二个字符串的字符放入向量中。

例如,如果fasta文件说

>Compsosisymbrium reconditcladus
TGTGTTAGAGGGACGAGTCACCATGTACCAAAA
>Pseudogranum aridacinus
ATTATCGTTGTTGCTAGCCA

等等等

我怎么放

TGTGTTAGAGGGACGAGTCACCATGTACCAAAA

ATTATCGTTGTTGCTAGCCA

转换为向量,以便我可以开始生成kmers?对于我的代码,我把 将TGTGTTAGAGGGACGAGTCACCATGTACCAAAA和ATTATCGTTGTTGCTAGCCA插入字符串seq。

while(getline(file,sp)){
    //string contents;
        getline(file,seq);
        cout << sp << endl;
        cout << seq << "\n";

        cout << "Test: sequence size is " << seq.size()<< endl;

    }
    vector <char>kList;//an empty vector
    //store the characters into the vector
        for (int i = 0; i<=seq.size()+1;i++){
            kList.push_back(seq.at(i));
        }
    //display the seq contents in the kList vector
    cout << "Test: the contents is ";
    for(int i = 0;i<=kList.size();i++){
        cout << kList[i];
    }

}

0 个答案:

没有答案