source: tags/arb_5.5/PRIMER_DESIGN/PRD_Design.hxx

Last change on this file was 3266, checked in by westram, 20 years ago
  • changed define for arbdb.h to 'ARBDB_H'
  • fixed "array subscript has type `char'"
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1#ifndef PRD_DESIGN_HXX
2#define PRD_DESIGN_HXX
3
4#ifndef   PRD_GLOBALS_HXX
5#include "PRD_Globals.hxx"
6#endif
7#include "PRD_Range.hxx"
8#include "PRD_Node.hxx"
9#include "PRD_Item.hxx"
10#include "PRD_Pair.hxx"
11
12#include <deque>
13
14#ifndef ARBDB_H
15#include <arbdb.h>
16#endif
17
18class PrimerDesign {
19private:
20
21    // zu untersuchendes Genom
22    // sequence of bases/spaces to be examined
23
24    const char* sequence;
25    long int    seqLength;
26
27    // Laenge der Primer (Anzahl der enthaltenen Basen)
28    // count of bases of primers (min/max)
29    Range primer_length;
30
31    // Position der Primer ( [min,max) )
32    // left/right position of primers
33
34    Range primer1;
35    Range primer2;
36
37    // Abstand der Primer (bzgl. der Basen dazwischen, <=0 = ignorieren)
38    // min/max distance of primers (regading number of bases between, <=0 = ignore)
39
40    Range primer_distance;
41
42    // maximale Anzahl zurueckzuliefernder Primerpaare
43    // max. count of returned primer pairs
44
45    int   max_count_primerpairs;
46
47    // GC-Verhaeltniss der Primer in Prozent <=0 = ignorieren
48    // GC-ratio of primers in percent <=0 = ignore
49    // [ ratio = (G+C)/Basen ]
50
51    Range GC_ratio;
52
53    // Temperatur der Primer <=0 = ignorieren
54    // temperature of primers <=0 = ignore
55    // [ temperature = 4*(G+C) + 2*(A+T) ]
56
57    Range temperature;
58
59    // Faktoren zur Gewichtung von CG-Verhaeltniss und Temperatur bei der Bewertung von Primerpaaren
60    // factors to assess the GC-ratio and temperature at the evaluation of primerpairs
61    // [ 0.0 .. 1.0 ]
62
63    double GC_factor;
64    double temperature_factor;
65
66    // wird ein Primer ausserhalb dieser Distanz nocheinmal gefunden wird das Vorkommen ignoriert ( <= 0 = eindeutig )
67    // is a primer found again out of this range its occurence is ignored ( <=0 = explict match )
68
69    int  min_distance_to_next_match;
70
71    // erweitern der IUPAC-Codes beim matching der sequence gegen die primerbaeume ?
72    // expand IUPAC-Codes while matching sequence vs. primertrees ?
73
74    bool expand_IUPAC_Codes;
75
76
77    //
78    // INTERNAL STUFF
79    //
80    static const int FORWARD  =  1;
81    static const int BACKWARD = -1;
82
83    // primertrees
84    Node* root1;
85    Node* root2;
86
87    // primerlists
88    Item* list1;
89    Item* list2;
90
91    // primerpairs
92    Pair* pairs;
93
94    GB_ERROR error;
95    unsigned long int total_node_counter_left;
96    unsigned long int total_node_counter_right;
97    unsigned long int primer_node_counter_left;
98    unsigned long int primer_node_counter_right;
99
100public:
101    PrimerDesign( const char *sequence_, long int seqLength_,
102                  Range       pos1_, Range pos2_, Range length_, Range distance_,
103                  Range       ratio_, Range temperature_, int min_dist_to_next_, bool expand_IUPAC_Codes_,
104                  int         max_count_primerpairs_, double GC_factor_, double temp_factor_ );
105    PrimerDesign( const char *sequence_, long int seqLength_,
106                  Range       pos1_, Range pos2_, Range length_, Range distance_,
107                  int         max_count_primerpairs_, double GC_factor_, double temp_factor_ );
108
109    PrimerDesign( const char *sequence_, long int seqLength_);
110    ~PrimerDesign();
111
112    void setPositionalParameters ( Range pos1_, Range pos2_, Range length_, Range distance_ );
113    void setConditionalParameters( Range ratio_, Range temperature_, int min_dist_to_next_, bool expand_IUPAC_Codes_, int max_count_primerpairs_, double GC_factor_, double temp_factor_ );
114
115    void buildPrimerTrees ();
116    void printPrimerTrees ();
117
118    void matchSequenceAgainstPrimerTrees ();
119
120    void convertTreesToLists ();
121    void printPrimerLists    ();
122
123    void evaluatePrimerPairs ();
124    void printPrimerPairs    ();
125
126    void run ( int print_stages_ );
127
128    GB_ERROR get_error() const { return error; }
129
130    PRD_Sequence_Pos  get_max_primer_length() const { return primer_length.max(); }
131    PRD_Sequence_Pos  get_max_primer_pos()    const { return primer2.max(); }
132    const char       *get_result( int num, const char *&primers, int max_primer_length, int max_position_length, int max_length_length ) const; // return 0 if no more results (primers is set to "leftPrimer,rightPrimer")
133
134public:
135    static const int PRINT_RAW_TREES     = 1;
136    static const int PRINT_MATCHED_TREES = 2;
137    static const int PRINT_PRIMER_LISTS  = 4;
138    static const int PRINT_PRIMER_PAIRS  = 8;
139
140private:
141    void             init               ( const char *sequence_, long int seqLength_, Range pos1_, Range pos2_, Range length_, Range distance_, Range ratio_, Range temperature_, int min_dist_to_next_, bool expand_IUPAC_Codes_, int max_count_primerpairs_, double GC_factor_, double temp_factor_ );
142    PRD_Sequence_Pos followUp           ( Node *node_, std::deque<char> *primer_, int direction_ );
143    void             findNextPrimer     ( Node *start_at_, int depth_, int *counter_, int delivered_ );
144    int              insertNode         ( Node *current_, unsigned char base_, PRD_Sequence_Pos pos_, int delivered_, int offset_, int left_, int right_ );
145    void             clearTree          ( Node *start, int left_, int right_ );
146    bool             treeContainsPrimer ( Node *start );
147    void             calcGCandAT        ( int &GC_, int &AT_, Node *start_at_ );
148    double           evaluatePair       ( Item *one_, Item *two_ );
149    void             insertPair         ( double rating_, Item *one_, Item *two_ );
150
151    int (*show_status_txt)(const char *msg);
152    int (*show_status_double)(double gauge);
153
154    inline int show_status(const char *msg) { return show_status_txt ? show_status_txt(msg) : 0; }
155    inline int show_status(double gauge) { return show_status_double ? show_status_double(gauge) : 0; }
156
157public:
158    void set_status_callbacks(int (*show_txt)(const char*), int (*show_double)(double)) {
159        show_status_txt    = show_txt;
160        show_status_double = show_double;
161    }
162};
163
164
165#else
166#error PRD_Design.hxx included twice
167#endif // PRD_DESIGN_HXX
Note: See TracBrowser for help on using the repository browser.