Debian Codegraph @

inc/core/AgnComparison.h

raw
1 /**
2
3 Copyright (c) 2010-2014, Daniel S. Standage and CONTRIBUTORS
4
5 The AEGeAn Toolkit is distributed under the ISC License. See
6 the 'LICENSE' file in the AEGeAn source code distribution or
7 online at https://github.com/standage/AEGeAn/blob/master/LICENSE.
8
9 **/
10 #ifndef AEGEAN_COMPARISON
11 #define AEGEAN_COMPARISON
12
13 #include <stdbool.h>
14 #include <stdio.h>
15 #include "core/types_api.h"
16
17 /**
18 * @module AgnComparison
19 *
20 * Data structures and functions related to comparative assessment of
21 * gene/transcript annotations.
22 */ //;
23
24 /**
25 * @type This struct is used to aggregate counts and statistics regarding the
26 * structural-level comparison (i.e., at the level of whole CDS segments, whole
27 * exons, and whole UTRs) and analysis of gene structure. See header file for
28 * details.
29 */
30 struct AgnCompStatsBinary
31 {
32 GtUword correct;
33 GtUword missing;
34 GtUword wrong;
35 double sn;
36 double sp;
37 double f1;
38 double ed;
39 char sns[7];
40 char sps[7];
41 char f1s[7];
42 char eds[16];
43 };
44 typedef struct AgnCompStatsBinary AgnCompStatsBinary;
45
46 /**
47 * @type This struct is used to aggregate counts and statistics regarding the
48 * nucleotide-level comparison and analysis of gene structure. See header file
49 * for details.
50 */
51 struct AgnCompStatsScaled
52 {
53 GtUword tp;
54 GtUword fn;
55 GtUword fp;
56 GtUword tn;
57 double mc;
58 double cc;
59 double sn;
60 double sp;
61 double f1;
62 double ed;
63 char mcs[7];
64 char ccs[7];
65 char sns[7];
66 char sps[7];
67 char f1s[7];
68 char eds[16];
69 };
70 typedef struct AgnCompStatsScaled AgnCompStatsScaled;
71
72 /**
73 * @type This struct aggregates all the counts and stats that go into a
74 * comparison, including structural-level and nucleotide-level counts and stats.
75 * See header file for details.
76 */
77 struct AgnComparison
78 {
79 AgnCompStatsScaled cds_nuc_stats;
80 AgnCompStatsScaled utr_nuc_stats;
81 AgnCompStatsBinary cds_struc_stats;
82 AgnCompStatsBinary exon_struc_stats;
83 AgnCompStatsBinary utr_struc_stats;
84 GtUword overall_matches;
85 GtUword overall_length;
86 };
87 typedef struct AgnComparison AgnComparison;
88
89 /**
90 * @type This enumerated type refers to all the possible outcomes when
91 * annotations from two different sources are compared:
92 * ``AGN_COMP_CLASS_UNCLASSIFIED``, ``AGN_COMP_CLASS_PERFECT_MATCH``,
93 * ``AGN_COMP_CLASS_MISLABELED``, ``AGN_COMP_CLASS_CDS_MATCH``,
94 * ``AGN_COMP_CLASS_EXON_MATCH``, ``AGN_COMP_CLASS_UTR_MATCH``, and
95 * ``AGN_COMP_CLASS_NON_MATCH``.
96 */
97 enum AgnCompClassification
98 {
99 AGN_COMP_CLASS_UNCLASSIFIED,
100 AGN_COMP_CLASS_PERFECT_MATCH,
101 AGN_COMP_CLASS_MISLABELED,
102 AGN_COMP_CLASS_CDS_MATCH,
103 AGN_COMP_CLASS_EXON_MATCH,
104 AGN_COMP_CLASS_UTR_MATCH,
105 AGN_COMP_CLASS_NON_MATCH
106 };
107 typedef enum AgnCompClassification AgnCompClassification;
108
109 /**
110 * @type This struct contains various counts to be reported in the summary
111 * report.
112 */
113 struct AgnCompInfo
114 {
115 GtUword num_loci;
116 GtUword unique_refr_loci;
117 GtUword unique_pred_loci;
118 GtUword refr_genes;
119 GtUword pred_genes;
120 GtUword refr_transcripts;
121 GtUword pred_transcripts;
122 GtUword num_comparisons;
123 };
124 typedef struct AgnCompInfo AgnCompInfo;
125
126 /**
127 * @type When reporting the results of a comparative analysis, it may be useful
128 * to (as is done by ParsEval) show some basic information about clique pairs
129 * that fall under each classification category. The counts in this struct are
130 * necessary to calculate those summary characteristics.
131 */
132 struct AgnCompClassDesc
133 {
134 GtUword comparison_count;
135 GtUword total_length;
136 GtUword refr_cds_length;
137 GtUword pred_cds_length;
138 GtUword refr_exon_count;
139 GtUword pred_exon_count;
140 };
141 typedef struct AgnCompClassDesc AgnCompClassDesc;
142
143 /**
144 * @type This struct is used to aggregate descriptions for all of the
145 * classification categories.
146 */
147 struct AgnCompClassSummary
148 {
149 AgnCompClassDesc perfect_matches;
150 AgnCompClassDesc perfect_mislabeled;
151 AgnCompClassDesc cds_matches;
152 AgnCompClassDesc exon_matches;
153 AgnCompClassDesc utr_matches;
154 AgnCompClassDesc non_matches;
155 };
156 typedef struct AgnCompClassSummary AgnCompClassSummary;
157
158 /**
159 * @type Aggregate various data related to comparison of annotations.
160 */
161 struct AgnComparisonData
162 {
163 AgnCompClassSummary summary;
164 AgnCompInfo info;
165 AgnComparison stats;
166 };
167 typedef struct AgnComparisonData AgnComparisonData;
168
169 /**
170 * @function Function used to combine similarity stats from many different
171 * comparisons into a single aggregate summary.
172 */
173 void agn_comparison_aggregate(AgnComparison *agg_cmp, AgnComparison *cmp);
174
175 /**
176 * @function Add counts and stats from ``data`` to ``agg_data``.
177 */
178 void agn_comparison_data_aggregate(AgnComparisonData *agg_data,
179 AgnComparisonData *data);
180
181 /**
182 * @function Initialize counts and stats to default values.
183 */
184 void agn_comparison_data_init(AgnComparisonData *data);
185
186 /**
187 * @function Initialize comparison stats to default values.
188 */
189 void agn_comparison_init(AgnComparison *comparison);
190
191 /**
192 * @function Print the comparison stats to the given file.
193 */
194 void agn_comparison_print(AgnComparison *stats, FILE *outstream);
195
196 /**
197 * @function Calculate stats from the given counts.
198 */
199 void agn_comparison_resolve(AgnComparison *comparison);
200
201 /**
202 * @function Returns true if c1 and c2 contain identical values, false
203 * otherwise.
204 */
205 bool agn_comparison_test(AgnComparison *c1, AgnComparison *c2);
206
207 /**
208 * @function Add values from ``desc`` to ``agg_desc``.
209 */
210 void agn_comp_class_desc_aggregate(AgnCompClassDesc *agg_desc,
211 AgnCompClassDesc *desc);
212
213 /**
214 * @function Initialize to default values.
215 */
216 void agn_comp_class_desc_init(AgnCompClassDesc *desc);
217
218 /**
219 * @function Add values from ``summ`` to ``agg_summ``.
220 */
221 void agn_comp_class_summary_aggregate(AgnCompClassSummary *agg_summ,
222 AgnCompClassSummary *summ);
223
224 /**
225 * @function Initialize to default values.
226 */
227 void agn_comp_class_summary_init(AgnCompClassSummary *summ);
228
229 /**
230 * @function Add values from ``info`` to ``agg_info``.
231 */
232 void agn_comp_info_aggregate(AgnCompInfo *agg_info, AgnCompInfo *info);
233
234 /**
235 * @function Initialize to default values.
236 */
237 void agn_comp_info_init(AgnCompInfo *info);
238
239 /**
240 * @function Function used to combine similarity stats from many different
241 * comparisons into a single aggregate summary.
242 */
243 void agn_comp_stats_binary_aggregate(AgnCompStatsBinary *agg_stats,
244 AgnCompStatsBinary *stats);
245
246 /**
247 * @function Initialize comparison counts/stats to default values.
248 */
249 void agn_comp_stats_binary_init(AgnCompStatsBinary *stats);
250
251 /**
252 * @function Print the comparison stats to the given file.
253 */
254 void agn_comp_stats_binary_print(AgnCompStatsBinary *stats, FILE *outstream);
255
256 /**
257 * @function Calculate stats from the given counts.
258 */
259 void agn_comp_stats_binary_resolve(AgnCompStatsBinary *stats);
260
261 /**
262 * @function Returns true if s1 and s2 contain identical values, false
263 * otherwise.
264 */
265 bool agn_comp_stats_binary_test(AgnCompStatsBinary *s1, AgnCompStatsBinary *s2);
266
267 /**
268 * @function Function used to combine similarity stats from many different
269 * comparisons into a single aggregate summary.
270 */
271 void agn_comp_stats_scaled_aggregate(AgnCompStatsScaled *agg_stats,
272 AgnCompStatsScaled *stats);
273
274 /**
275 * @function Initialize comparison counts/stats to default values.
276 */
277 void agn_comp_stats_scaled_init(AgnCompStatsScaled *stats);
278
279 /**
280 * @function Print the comparison stats to the given file.
281 */
282 void agn_comp_stats_scaled_print(AgnCompStatsScaled *stats, FILE *outstream);
283
284 /**
285 * @function Calculate stats from the given counts.
286 */
287 void agn_comp_stats_scaled_resolve(AgnCompStatsScaled *stats);
288
289 /**
290 * @function Returns true if s1 and s2 contain identical values, false
291 * otherwise.
292 */
293 bool agn_comp_stats_scaled_test(AgnCompStatsScaled *s1, AgnCompStatsScaled *s2);
294
295 #endif