source: branches/profile/AWTC/awtc_next_neighbours.hxx

Last change on this file was 9533, checked in by westram, 11 years ago
  • use explicit override
    • rest
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : awtc_next_neighbours.hxx                          //
4//   Purpose   : Search relatives via PT server                    //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef AWTC_NEXT_NEIGHBOURS_HXX
12#define AWTC_NEXT_NEIGHBOURS_HXX
13
14#ifndef ARBDB_BASE_H
15#include <arbdb_base.h>
16#endif
17#ifndef ARBTOOLS_H
18#include <arbtools.h>
19#endif
20#ifndef PT_GLOBAL_DEFS_H
21#include <PT_global_defs.h>
22#endif
23#ifndef POS_RANGE_H
24#include <pos_range.h>
25#endif
26
27#define ff_assert(bed) arb_assert(bed)
28
29class FamilyList : virtual Noncopyable {
30    // list is sorted either by 'matches' or 'rel_matches' (descending)
31    // depending on 'rel_matches' parameter to PT_FamilyFinder::searchFamily()
32public:
33    FamilyList *next;
34
35    char   *name;
36    long    matches;
37    double  rel_matches;
38
39    FamilyList *insertSortedBy_matches(FamilyList *other);
40    FamilyList *insertSortedBy_rel_matches(FamilyList *other);
41
42    FamilyList();
43    ~FamilyList();
44};
45
46struct aisc_com;
47
48class FamilyFinder : virtual Noncopyable {
49    bool                 rel_matches;
50    RelativeScoreScaling scaling;
51
52protected:
53    FamilyList *family_list;
54
55    bool hits_truncated;
56
57#if defined(WARN_TODO)
58#warning change real_hits back to int when aisc_get() has been made failsafe
59#endif
60    long real_hits;
61
62    PosRange range;
63
64public:
65    FamilyFinder(bool rel_matches_, RelativeScoreScaling scaling_);
66    virtual ~FamilyFinder();
67
68    void restrict_2_region(const PosRange& range_) {
69        // Restrict oligo search to 'range_'
70        // Only oligos which are completely inside that region are used for calculating relationship.
71        // Has to be called before calling searchFamily.
72        range = range_;
73    }
74
75    void unrestrict() { range = PosRange(-1, -1); }
76    const PosRange& get_TargetRange() const { return range; }
77
78    virtual GB_ERROR searchFamily(const char *sequence, FF_complement compl_mode, int max_results, double min_score) = 0;
79
80    const FamilyList *getFamilyList() const { return family_list; }
81    void delete_family_list();
82
83    bool hits_were_truncated() const { return hits_truncated; }
84    bool uses_rel_matches() const { return rel_matches; }
85    RelativeScoreScaling get_scaling() const { return scaling; }
86    int getRealHits() const { return real_hits; }
87};
88
89class PT_FamilyFinder : public FamilyFinder { // derived from a Noncopyable
90    GBDATA *gb_main;
91    int     server_id;
92    int     oligo_len;
93    int     mismatches;
94    bool    fast_flag;
95
96    struct PT_FF_comImpl *ci;
97
98    GB_ERROR init_communication();
99    GB_ERROR open(const char *servername);
100    GB_ERROR retrieve_family(const char *sequence, FF_complement compl_mode, int max_results, double min_score) __ATTR__USERESULT;
101    void     close();
102
103public:
104
105    PT_FamilyFinder(GBDATA *gb_main_, int server_id_, int oligo_len_, int mismatches_, bool fast_flag_, bool rel_matches_, RelativeScoreScaling scaling_);
106    ~PT_FamilyFinder() OVERRIDE;
107
108    GB_ERROR searchFamily(const char *sequence, FF_complement compl_mode, int max_results, double min_score) OVERRIDE __ATTR__USERESULT;
109
110    const char *results2string();
111};
112
113// --------------------------------------------------------------------------------
114
115#define AWAR_NN_BASE "next_neighbours/"
116
117#define AWAR_NN_OLIGO_LEN   AWAR_NN_BASE "oligo_len"
118#define AWAR_NN_MISMATCHES  AWAR_NN_BASE "mismatches"
119#define AWAR_NN_FAST_MODE   AWAR_NN_BASE "fast_mode"
120#define AWAR_NN_REL_MATCHES AWAR_NN_BASE "rel_matches"
121#define AWAR_NN_REL_SCALING AWAR_NN_BASE "scaling"
122
123class AW_root;
124class AW_window;
125
126void AWTC_create_common_next_neighbour_vars(AW_root *aw_root);
127void AWTC_create_common_next_neighbour_fields(AW_window *aws);
128
129#else
130#error awtc_next_neighbours.hxx included twice
131#endif // AWTC_NEXT_NEIGHBOURS_HXX
Note: See TracBrowser for help on using the repository browser.