1 /****************************************************************\
2 *                                                                *
3 *  Library for PCR simulation                                    *
4 *                                                                *
5 *  Guy St.C. Slater..   mailto:guy@ebi.ac.uk                     *
6 *  Copyright (C) 2000-2009.  All Rights Reserved.                *
7 *                                                                *
8 *  This source code is distributed under the terms of the        *
9 *  GNU General Public License, version 3. See the file COPYING   *
10 *  or http://www.gnu.org/licenses/gpl.txt for details            *
11 *                                                                *
12 *  If you use this code, please keep this notice intact.         *
13 *                                                                *
14 \****************************************************************/
15 
16 #ifndef INCLUDED_PCR_H
17 #define INCLUDED_PCR_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif /* __cplusplus */
22 
23 #include <glib.h>
24 #include "fsm.h"
25 #include "sequence.h"
26 #include "wordhood.h"
27 #include "slist.h"
28 
29 typedef struct {
30     SList *owned_probe_list;
31     SList *borrowed_sensor_list;
32 } PCR_Sensor;
33 /* pcr->fsm nodes contain PCR_Sensor objects.
34  *
35  * This is to allow both cases where:
36  *  (a) Multiple probes are present with the same sequence
37  *  (b) One probe is a subsequence of another
38  */
39 
40 typedef struct {
41     struct PCR_Primer *pcr_primer;
42       Sequence_Strand  strand;
43                  gint  mismatch;
44 } PCR_Probe;
45 /* A derived primer to facilitate approximate primer matching */
46 
47 typedef struct {
48     PCR_Probe *pcr_probe;
49          gint  position; /* Position at probe end */
50          gint  mismatch;
51 } PCR_Match;
52 /* A primer annealed to a position on a sequence */
53 
54 typedef struct PCR_Primer {
55     struct PCR_Experiment *pcr_experiment;
56                      gint  length;
57                      gint  probe_len;
58                     gchar *forward;
59                     gchar *revcomp;
60                 GPtrArray *probe_list;
61 } PCR_Primer;
62 
63 typedef struct PCR_Experiment {
64     struct PCR *pcr;
65          gchar *id;
66     PCR_Primer *primer_a;
67     PCR_Primer *primer_b;
68           gint  min_product_len;
69           gint  max_product_len;
70          SList *match_list;
71           gint  product_count;
72 } PCR_Experiment;
73 /* A pair of primers to be simulated in a PCR reaction */
74 
75 typedef gboolean (*PCR_ReportFunc)(Sequence *sequence,
76                 PCR_Match *match_a, PCR_Match *match_b,
77                 gint product_length, gpointer user_data);
78 /* Return TRUE to stop the simulation */
79 
80 typedef struct PCR {
81           SListSet *slist_set; /* Lists of PCR_Probes */
82                FSM *fsm;
83          GPtrArray *experiment_list;
84               gint  mismatch_threshold;
85               gint  seed_length;
86           WordHood *wordhood;
87     PCR_ReportFunc  report_func;
88           gboolean  is_prepared;
89              gsize  experiment_memory_usage;
90               gint  sensor_count;
91          GMemChunk *sensor_mem_chunk;
92           gpointer  user_data;
93       GStringChunk *string_chunk;
94          GMemChunk *probe_mem_chunk;
95          GMemChunk *match_mem_chunk;
96          PCR_Match *match_recycle;
97 } PCR;
98 
99  PCR *PCR_create(PCR_ReportFunc report_func,
100                  gpointer user_data, gint mismatch_threshold,
101                  gint seed_length);
102 void  PCR_destroy(PCR *pcr);
103 
104 gsize PCR_add_experiment(PCR *pcr, gchar *id,
105                          gchar *primer_a, gchar *primer_b,
106                          gint min_product_len, gint max_product_len);
107 /* Returns the memory currently being used by PCR */
108 
109 void PCR_prepare(PCR *pcr);
110 /* Called after last call to PCR_add_primer_pair() */
111 
112 void PCR_simulate(PCR *pcr, Sequence *sequence);
113 
114 #ifdef __cplusplus
115 }
116 #endif /* __cplusplus */
117 
118 #endif /* INCLUDED_IPCRESS_H */
119 
120