-1

だから私は(C ++)でプロジェクトに取り組んでおり、テキストファイルから読み取られたDNAシーケンスのヌクレオチドの確率を計算する必要があります。シーケンスの平均長、分散、偏差など、ファイルに関する他の情報はすでに把握しています。

例... "atgatatgagc"

'a'ポップアップや't' .. などの可能性の高いフードを与えることができます

ヒントや提案はありますか?

4

3 に答える 3

4
char letter='a';
string str="abcd"; 
cout << (double) std::count(str.begin(), str.end(), letter) / str.size();
于 2012-09-01T08:09:35.363 に答える
2

より多くの情報がなく、各文字の確率が等しいと仮定すると、4つの可能な文字、、、およびを仮定すると、文字が「ポップアップ」する確率Aは1/4Tです。GC

于 2012-09-01T08:01:02.077 に答える
0

Leonid Volnitsky コードのわずかな変更:

 #include <iostream>
#include <algorithm>
#include <string>
using namespace std ;



int main(void)
{

    char character_A='A';
    char character_C='C';
    char character_G='G';
    char character_T='T';

    string DNA_Sequence="ACAAGATGCCATTGTCCCCCGGCCTCCTGCTGCTGCTGCTCTCCGGGGCCACGGCCACCGCTGCCCTGCCCCTGGAGGGTGGCCCCACCGGCCGAGACAGCGAGCATATGCAGGAAGCGGCAGGAATAAGGAAAAGCAGCCTCCTGACTTTCCTCGCTTGGTGGTTTGAGTGGACCTCCCAGGCCAGTGCCGGGCCCCTCATAGGAGAGGAAGCTCGGGAGGTGGCCAGGCGGCAGGAAGGCGCACCCCCCCAGCAATCCGCGCGCCGGGACAGAATGCCCTGCAGGAACTTCTTCTGGAAGACCTTCTCCTCCTGCAAATAAAACCTCACCCATGAATGCTCACGCAAGTTTAATTACAGACCTGAA"; 

    int occurrences_A=std::count(DNA_Sequence.begin(), DNA_Sequence.end(), character_A);
    double probability_A =(double) occurrences_A/ DNA_Sequence.size();

    int occurrences_C=std::count(DNA_Sequence.begin(), DNA_Sequence.end(), character_C);
    double probability_C =(double) occurrences_C/ DNA_Sequence.size();

    int occurrences_G=std::count(DNA_Sequence.begin(), DNA_Sequence.end(), character_G);
    double probability_G =(double) occurrences_G/ DNA_Sequence.size();

    int occurrences_T=std::count(DNA_Sequence.begin(), DNA_Sequence.end(), character_T);
    double probability_T =(double) occurrences_T/ DNA_Sequence.size();


    cout<<"In the DNA sequence  \n\n["<<DNA_Sequence <<"]    \n\n\n" ;
    cout<<"The probability of ["<<character_A <<"] in the sequence   = "<<probability_A <<"  ("<<probability_A*100 <<"%)  ("<<occurrences_A<<" A's)  \n" ;
    cout<<"The probability of ["<<character_C <<"] in the sequence   = "<<probability_C <<"  ("<<probability_C*100 <<"%)  ("<<occurrences_C<<" C's)  \n" ;
    cout<<"The probability of ["<<character_G <<"] in the sequence   = "<<probability_G <<"  ("<<probability_G*100 <<"%)  ("<<occurrences_G<<" G's)  \n" ;
    cout<<"The probability of ["<<character_T <<"] in the sequence   = "<<probability_T <<"  ("<<probability_T*100 <<"%)  ("<<occurrences_T<<" T's)  \n\n" ;

    cout<<"Cross check : "<<(probability_A*100)<<"% + "<<( probability_C*100)<<"% + "<<( probability_G*100)<<"% + "<<( probability_T*100)<<
        "% = "<< (probability_A*100) + ( probability_C*100) + ( probability_G*100) + ( probability_T*100) <<"% \n";
    cout<<"Sequence size = "<<DNA_Sequence.size()<<"  (A + C + G + T = "<<occurrences_A+occurrences_C+occurrences_G+occurrences_T<<") \n\n";


    cout<<" \nPress any key to continue\n";

    cin.get();

   return 0;
}

出力:

In the DNA sequence

[ACAAGATGCCATTGTCCCCCGGCCTCCTGCTGCTGCTGCTCTCCGGGGCCACGGCCACCGCTGCCCTGCCCCTGGAGGG
TGGCCCCACCGGCCGAGACAGCGAGCATATGCAGGAAGCGGCAGGAATAAGGAAAAGCAGCCTCCTGACTTTCCTCGCTT
GGTGGTTTGAGTGGACCTCCCAGGCCAGTGCCGGGCCCCTCATAGGAGAGGAAGCTCGGGAGGTGGCCAGGCGGCAGGAA
GGCGCACCCCCCCAGCAATCCGCGCGCCGGGACAGAATGCCCTGCAGGAACTTCTTCTGGAAGACCTTCTCCTCCTGCAA
ATAAAACCTCACCCATGAATGCTCACGCAAGTTTAATTACAGACCTGAA]


The probability of [A] in the sequence   = 0.214674  (21.4674%)  (79 A's)
The probability of [C] in the sequence   = 0.334239  (33.4239%)  (123 C's)
The probability of [G] in the sequence   = 0.285326  (28.5326%)  (105 G's)
The probability of [T] in the sequence   = 0.165761  (16.5761%)  (61 T's)

Cross check : 21.4674% + 33.4239% + 28.5326% + 16.5761% = 100%
Sequence size = 368  (A + C + G + T = 368)


Press any key to continue
于 2012-09-01T12:56:46.873 に答える