annotate PsiCLASS-1.0.2/SubexonCorrelation.hpp @ 0:903fc43d6227 draft default tip

Uploaded
author lsong10
date Fri, 26 Mar 2021 16:52:45 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
1 #ifndef _MOURISL_CLASSES_SUBEXONCORRELATION_HEADER
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
2 #define _MOURISL_CLASSES_SUBEXONCORRELATION_HEADER
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
3
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
4 #include "SubexonGraph.hpp"
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
5
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
6 #include <stdio.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
7 #include <math.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
8
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
9 class SubexonCorrelation
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
10 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
11 private:
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
12 struct _subexon *lastSubexons ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
13 std::vector<FILE *> fileList ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
14 int offset ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
15 int prevSeCnt ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
16 int seCnt ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
17
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
18 double **correlation ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
19
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
20 int OverlapSize( int s0, int e0, int s1, int e1 )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
21 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
22 int s = -1, e = -1 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
23 if ( e0 < s1 || s0 > e1 )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
24 return 0 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
25 s = s0 > s1 ? s0 : s1 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
26 e = e0 < e1 ? e0 : e1 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
27 return e - s + 1 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
28 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
29 public:
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
30 SubexonCorrelation()
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
31 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
32 offset = 0 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
33 lastSubexons = NULL ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
34 correlation = NULL ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
35 prevSeCnt = 0 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
36 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
37
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
38 ~SubexonCorrelation()
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
39 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
40 int cnt = fileList.size() ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
41 int i ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
42 for ( i = 0 ; i < cnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
43 fclose( fileList[i] ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
44 delete[] lastSubexons ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
45 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
46
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
47 void Initialize( char *f )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
48 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
49 FILE *fpSl ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
50 fpSl = fopen( f, "r" ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
51 char buffer[1024] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
52 while ( fgets( buffer, sizeof( buffer ), fpSl ) != NULL )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
53 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
54 int len = strlen( buffer ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
55 if ( buffer[len - 1] == '\n' )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
56 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
57 buffer[len - 1] = '\0' ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
58 --len ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
59
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
60 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
61 FILE *fp = fopen( buffer, "r" ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
62 fileList.push_back( fp ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
63 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
64
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
65 lastSubexons = new struct _subexon[ fileList.size() ] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
66 int i, cnt ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
67 cnt = fileList.size() ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
68 for ( i = 0 ; i < cnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
69 lastSubexons[i].chrId = -1 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
70
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
71 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
72
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
73 // We assume the subexons only contains the subexons we are interested in.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
74 // And we assume that each time we call this function, the subexons we are interested are
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
75 // sorted in order.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
76 void ComputeCorrelation( struct _subexon *subexons, int cnt, Alignments &alignments )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
77 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
78 int sampleCnt = fileList.size() ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
79 if ( sampleCnt <= 1 )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
80 return ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
81 int i, j, k ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
82 seCnt = cnt ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
83
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
84 // Obtain the depth matrix.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
85 double **depth ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
86 depth = new double* [sampleCnt] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
87 for ( i = 0 ; i < sampleCnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
88 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
89 depth[i] = new double[ cnt ] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
90 memset( depth[i], 0, sizeof( double ) * cnt ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
91 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
92
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
93 char buffer[2048] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
94 for ( i = 0 ; i < sampleCnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
95 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
96 struct _subexon se ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
97 bool useLastSubexon = false ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
98 if ( lastSubexons[i].chrId != -1 )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
99 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
100 se = lastSubexons[i] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
101 useLastSubexon = true ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
102 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
103 else
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
104 se.chrId = -1 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
105
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
106 // Locate the subexon
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
107 while ( 1 )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
108 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
109 if ( se.chrId < subexons[0].chrId
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
110 || ( se.chrId == subexons[0].chrId && se.end < subexons[0].start ) )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
111 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
112 if ( fgets( buffer, sizeof( buffer ), fileList[i] ) == NULL )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
113 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
114 buffer[0] = '\0' ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
115 break ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
116 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
117 if ( buffer[0] == '#' )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
118 continue ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
119
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
120 SubexonGraph::InputSubexon( buffer, alignments, se ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
121 --se.start ; --se.end ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
122 useLastSubexon = false ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
123 continue ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
124 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
125 break ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
126 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
127 if ( buffer[0] == '\0' )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
128 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
129 lastSubexons[i] = se ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
130 continue ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
131 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
132
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
133 // Process the subexon.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
134 int tag = 0 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
135 while ( 1 )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
136 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
137 lastSubexons[i] = se ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
138
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
139 if ( useLastSubexon == false )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
140 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
141 SubexonGraph::InputSubexon( buffer, alignments, se ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
142 --se.start ; --se.end ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
143 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
144
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
145 if ( se.chrId > subexons[cnt - 1].chrId || se.start > subexons[cnt - 1].end )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
146 break ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
147
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
148 while ( 1 )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
149 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
150 if ( tag > cnt || subexons[tag].end >= se.start )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
151 break ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
152 ++tag ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
153 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
154
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
155 for ( j = tag ; j < cnt && subexons[j].start <= se.end ; ++j )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
156 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
157 int overlap = OverlapSize( se.start, se.end, subexons[j].start, subexons[j].end ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
158 depth[i][j] += overlap * se.avgDepth ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
159 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
160
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
161 if ( fgets( buffer, sizeof( buffer ), fileList[i] ) == NULL )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
162 break ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
163 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
164 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
165 // Normalize the depth
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
166 for ( i = 0 ; i < sampleCnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
167 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
168 for ( j = 0 ; j < cnt ; ++j )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
169 depth[i][j] /= ( subexons[j].end - subexons[j].start + 1 ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
170 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
171
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
172 // Compute the correlation.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
173 double *avg = new double[cnt] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
174 double *var = new double[cnt] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
175 if ( correlation != NULL )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
176 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
177 for ( i = 0 ; i < prevSeCnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
178 delete[] correlation[i] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
179 delete[] correlation ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
180 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
181
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
182 correlation = new double*[cnt] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
183 for ( i = 0 ; i < cnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
184 correlation[i] = new double[cnt] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
185
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
186 memset( avg, 0, sizeof( double ) * cnt ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
187 memset( var, 0, sizeof( double ) * cnt ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
188 for ( i = 0 ; i < cnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
189 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
190 //avg[i] = 0 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
191 //var[i] = 0 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
192 memset( correlation[i], 0, sizeof( double ) * cnt ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
193 correlation[i][i] = 1 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
194 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
195
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
196 for ( i = 0 ; i < sampleCnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
197 for ( j = 0 ; j < cnt ; ++j )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
198 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
199 avg[j] += depth[i][j] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
200 var[j] += depth[i][j] * depth[i][j] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
201 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
202 for ( i = 0 ; i < cnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
203 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
204 avg[i] /= sampleCnt ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
205 var[i] = var[i] / sampleCnt - avg[i] * avg[i] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
206 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
207
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
208 for ( i = 0 ; i < sampleCnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
209 for ( j = 0 ; j < cnt ; ++j )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
210 for ( k = j + 1 ; k < cnt ; ++k )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
211 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
212 //if ( subexons[j].geneId == subexons[k].geneId )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
213 correlation[j][k] += depth[i][j] * depth[i][k] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
214 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
215 for ( j = 0 ; j < cnt ; ++j )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
216 for ( k = j + 1 ; k < cnt ; ++k )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
217 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
218 if ( var[j] > 1e-6 && var[k] > 1e-6 )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
219 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
220 correlation[j][k] = ( correlation[j][k] / sampleCnt - avg[j] * avg[k] ) / sqrt( var[j] * var[k] ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
221 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
222 else
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
223 correlation[j][k] = 0 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
224 //printf( "%d %d %d\n", j, k, cnt ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
225 correlation[k][j] = correlation[j][k] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
226 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
227 //printf( "%lf\n", correlation[0][1] ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
228 // Release the memory.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
229 for ( i = 0 ; i < sampleCnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
230 delete[] depth[i] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
231 delete[] depth ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
232 delete[] avg ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
233 delete[] var ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
234
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
235 prevSeCnt = cnt ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
236 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
237
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
238 double Query( int i, int j )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
239 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
240 if ( fileList.size() > 1 )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
241 return correlation[i][j] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
242 else
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
243 return 0 ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
244 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
245
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
246 void Assign( const SubexonCorrelation &c )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
247 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
248 int i ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
249 fileList = c.fileList ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
250 if ( fileList.size() <= 1 )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
251 return ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
252
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
253 if ( correlation != NULL )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
254 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
255 for ( i = 0 ; i < seCnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
256 delete[] correlation[i] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
257 delete[] correlation ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
258 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
259
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
260 seCnt = c.seCnt ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
261 correlation = new double*[seCnt] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
262 for ( i = 0 ; i < seCnt ; ++i )
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
263 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
264 correlation[i] = new double[seCnt] ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
265 memcpy( correlation[i], c.correlation[i], sizeof( double ) * seCnt ) ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
266 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
267 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
268 } ;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
269
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
270 #endif