1 2%{ 3#include "dyna.h" 4 5#define SyExonModelLISTLENGTH 128 6#define SyExonScoreLISTLENGTH 128 7 8%} 9 10struct SyExon 11Probability exit_prob 12Probability stay_prob 13Probability prev_prob 14 15struct SyExonScoreUnit 16Score exit_score 17Score stay_score 18 19struct SyExonModel 20SyExon ** exon !list 21 22struct SyExonScore 23SyExonScoreUnit ** exon !list 24 25 26 27%{ 28 29#include "syexonmodel.h" 30 31SyExonScore * SyExonScore_flat_model(int start,int end,Probability exit,Probability final_stay) 32{ 33 SyExonScore * out; 34 SyExonModel * m; 35 36 m = SyExonModel_flat_model(start,end,exit,final_stay); 37 38 out = SyExonScore_from_SyExonModel(m); 39 40 free_SyExonModel(m); 41 42 return out; 43} 44 45 46SyExonModel * SyExonModel_flat_model(int start,int end,Probability exit,Probability final_stay) 47{ 48 int i; 49 SyExon * e; 50 SyExonModel * out; 51 Probability prev; 52 53 out = SyExonModel_alloc_len(end); 54 prev = 0.0; 55 56 for(i=0;i<end;i++) { 57 e = SyExon_alloc(); 58 add_SyExonModel(out,e); 59 if( i < start ) { 60 e->exit_prob = 0.0; 61 e->stay_prob = 0.0; 62 e->prev_prob = prev; 63 prev = 1.0; 64 } else { 65 e->exit_prob = exit; 66 e->stay_prob = 0.0; 67 e->prev_prob = prev; 68 prev = 1.0-exit; 69 } 70 71 if( i+3 > end ) { 72 e->stay_prob = final_stay; 73 } 74 } 75 76 return out; 77} 78 79 80SyExonScore * SyExonScore_from_SyExonModel(SyExonModel * sym) 81{ 82 int i; 83 84 SyExonScore * out; 85 86 out = SyExonScore_alloc_len(sym->len); 87 88 for(i=0;i<sym->len;i++) { 89 add_SyExonScore(out,SyExonScoreUnit_from_SyExon(sym->exon[i])); 90 } 91 92 return out; 93} 94 95 96SyExonScoreUnit * SyExonScoreUnit_from_SyExon(SyExon * sye) 97{ 98 SyExonScoreUnit * out; 99 100 out = SyExonScoreUnit_alloc(); 101 102 out->exit_score = Probability2Score(sye->exit_prob); 103 out->stay_score = Probability2Score(sye->stay_prob); 104 105 return out; 106} 107 108 109void dump_SyExonScore(SyExonScore * sc,FILE *ofp) 110{ 111 int i; 112 113 for(i=0;i<sc->len;i++) { 114 fprintf(ofp,"%d exit %d stay %d\n",i,sc->exon[i]->exit_score,sc->exon[i]->stay_score); 115 } 116 117} 118 119 120 121