source: branches/help/AWTC/awtc_next_neighbours.hxx

Last change on this file was 18665, checked in by westram, 3 years ago
  • change many WARN_TODO triggered warnings into todo markers.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 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#ifndef CB_H
27#include <cb.h>
28#endif
29
30#define ff_assert(bed) arb_assert(bed)
31
32class FamilyList : virtual Noncopyable {
33    // list is sorted either by 'matches' or 'rel_matches' (descending)
34    // depending on 'rel_matches' parameter to PT_FamilyFinder::searchFamily()
35public:
36    FamilyList *next;
37
38    char   *name;
39    long    matches;
40    double  rel_matches;
41
42    FamilyList *insertSortedBy_matches(FamilyList *other);
43    FamilyList *insertSortedBy_rel_matches(FamilyList *other);
44
45    FamilyList();
46    ~FamilyList();
47};
48
49struct aisc_com;
50
51class FamilyFinder : virtual Noncopyable {
52    bool                 rel_matches;
53    RelativeScoreScaling scaling;
54
55protected:
56    FamilyList *family_list;
57
58    bool hits_truncated;
59
60    // @@@ change real_hits back to int when aisc_get() has been made failsafe
61    long real_hits;
62
63    PosRange range;
64
65public:
66    FamilyFinder(bool rel_matches_, RelativeScoreScaling scaling_);
67    virtual ~FamilyFinder();
68
69    void restrict_2_region(const PosRange& range_) {
70        // Restrict oligo search to 'range_'
71        // Only oligos which are completely inside that region are used for calculating relationship.
72        // Has to be called before calling searchFamily.
73        range = range_;
74    }
75
76    void unrestrict() { range = PosRange(-1, -1); }
77    const PosRange& get_TargetRange() const { return range; }
78
79    virtual GB_ERROR searchFamily(const char *sequence, FF_complement compl_mode, int max_results, double min_score) = 0;
80
81    const FamilyList *getFamilyList() const { return family_list; }
82    void delete_family_list();
83
84    bool hits_were_truncated() const { return hits_truncated; }
85    bool uses_rel_matches() const { return rel_matches; }
86    RelativeScoreScaling get_scaling() const { return scaling; }
87    int getRealHits() const { return real_hits; }
88};
89
90class PT_FamilyFinder : public FamilyFinder { // derived from a Noncopyable
91    GBDATA *gb_main;
92    int     server_id;
93    int     oligo_len;
94    int     mismatches;
95    bool    fast_flag;
96
97    struct PT_FF_comImpl *ci;
98
99    GB_ERROR init_communication();
100    GB_ERROR open(const char *servername);
101    GB_ERROR retrieve_family(const char *sequence, FF_complement compl_mode, int max_results, double min_score) __ATTR__USERESULT;
102    void     close();
103
104public:
105
106    PT_FamilyFinder(GBDATA *gb_main_, int server_id_, int oligo_len_, int mismatches_, bool fast_flag_, bool rel_matches_, RelativeScoreScaling scaling_);
107    ~PT_FamilyFinder() OVERRIDE;
108
109    GB_ERROR searchFamily(const char *sequence, FF_complement compl_mode, int max_results, double min_score) OVERRIDE __ATTR__USERESULT;
110
111    const char *results2string();
112};
113
114// --------------------------------------------------------------------------------
115
116#define AWAR_NN_BASE "next_neighbours/"
117
118#define AWAR_NN_OLIGO_LEN   AWAR_NN_BASE "oligo_len"
119#define AWAR_NN_MISMATCHES  AWAR_NN_BASE "mismatches"
120#define AWAR_NN_FAST_MODE   AWAR_NN_BASE "fast_mode"
121#define AWAR_NN_REL_MATCHES AWAR_NN_BASE "rel_matches"
122#define AWAR_NN_REL_SCALING AWAR_NN_BASE "scaling"
123
124class AW_root;
125class AW_window;
126
127void AWTC_create_common_next_neighbour_vars(AW_root *aw_root, const RootCallback& awar_changed_cb);
128void AWTC_create_common_next_neighbour_fields(AW_window *aws, int scaler_length);
129
130#else
131#error awtc_next_neighbours.hxx included twice
132#endif // AWTC_NEXT_NEIGHBOURS_HXX
Note: See TracBrowser for help on using the repository browser.