5 * FUNCTION: generate the prior matrix
10 int Prob_matrix::prior_gen(Parameter
* para
) {
11 char t_base
, allele1
, allele2
;
12 // Note, the above parameter should be changed to a more reasonable one
13 for(t_base
=0;t_base
!=4;t_base
++) {
14 for(allele1
=0;allele1
!=4;allele1
++) {
15 for(allele2
=allele1
;allele2
!=4;allele2
++) {
16 if(allele1
== t_base
&& allele2
== t_base
) {
18 p_prior
[t_base
<<4|allele1
<<2|allele2
] = 1;
20 else if (allele1
== t_base
|| allele2
== t_base
) {
21 // refHET: 1 ref 1 alt
22 p_prior
[t_base
<<4|allele1
<<2|allele2
] = para
->het_novel_r
;
24 else if (allele1
== allele2
) {
26 p_prior
[t_base
<<4|allele1
<<2|allele2
] = para
->althom_novel_r
;
29 // altHET: 2 diff alt base
30 p_prior
[t_base
<<4|allele1
<<2|allele2
] = para
->het_novel_r
* para
->althom_novel_r
;
32 if( para
->transition_dominant
&& ((allele1
^t_base
) == 0x3 || (allele2
^t_base
) == 0x3)) {
34 p_prior
[t_base
<<4|allele1
<<2|allele2
] *= 4;
36 //std::cerr<<"ACTG"[t_base]<<"\t"<<"ACTG"[allele1]<<"ACTG"[allele2]<<"\t"<<p_prior[t_base<<4|allele1<<2|allele2]<<endl;
40 for(allele1
=0;allele1
!=4;allele1
++) {
41 for(allele2
=allele1
;allele2
!=4;allele2
++) {
43 p_prior
[0x4<<4|allele1
<<2|allele2
] = (allele1
==allele2
? 1: (2*para
->het_novel_r
)) * 0.25 *0.25;
44 p_prior
[0x5<<4|allele1
<<2|allele2
] = (allele1
==allele2
? 1: (2*para
->het_novel_r
)) * 0.25 *0.25;
45 p_prior
[0x6<<4|allele1
<<2|allele2
] = (allele1
==allele2
? 1: (2*para
->het_novel_r
)) * 0.25 *0.25;
46 p_prior
[0x7<<4|allele1
<<2|allele2
] = (allele1
==allele2
? 1: (2*para
->het_novel_r
)) * 0.25 *0.25;
52 int Call_win::snp_p_prior_gen(double * real_p_prior
, Snp_info
* snp
, Parameter
* para
, char ref
) {
53 if (snp
->is_indel()) {
56 char base
, allele1
, allele2
;
59 for (base
=0; base
!= 4; base
++) {
60 if(snp
->get_freq(base
)>0) {
61 // The base is found in dbSNP
65 if(allele_count
<= 1) {
67 cerr
<<"Previous Extract SNP error."<<endl
;
71 char t_base
= (ref
&0x3); // ????????????????
72 for(allele1
=0;allele1
!=4;allele1
++) {
73 for(allele2
=allele1
;allele2
!=4;allele2
++) {
74 if (! snp
->is_hapmap()) {
75 if(snp
->get_freq(allele1
)>0 && snp
->get_freq(allele2
)>0) {
76 // Here the frequency is just a tag to indicate SNP alleles in non-HapMap sites
77 if(allele1
== allele2
&& allele1
== t_base
) {
79 real_p_prior
[allele1
<<2|allele2
] = 1;
81 else if (allele1
== t_base
|| allele2
== t_base
) {
82 // refHET: 1 ref 1 alt
83 real_p_prior
[allele1
<<2|allele2
] = snp
->is_validated()?para
->het_val_r
:para
->het_unval_r
;
85 else if (allele1
== allele2
) {
86 real_p_prior
[allele1
<<2|allele2
] = snp
->is_validated()?para
->althom_val_r
:para
->althom_unval_r
;
89 // altHET: 2 diff alt base
90 real_p_prior
[allele1
<<2|allele2
] = snp
->is_validated()?para
->het_val_r
:para
->het_unval_r
;
96 if(snp
->get_freq(allele1
)>0 && snp
->get_freq(allele2
)>0) {
97 real_p_prior
[allele1
<<2|allele2
] = (allele1
==allele2
?1:(2*para
->het_val_r
))*snp
->get_freq(allele1
)*snp
->get_freq(allele2
);
100 //cerr<<"ACTG"[t_base]<<"\t"<<"ACTG"[allele1]<<"ACTG"[allele2]<<"\t"<<p_prior[t_base<<4|allele1<<2|allele2]<<endl;