ARB
awtc_next_neighbours.hxx
Go to the documentation of this file.
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 
32 class FamilyList : virtual Noncopyable {
33  // list is sorted either by 'matches' or 'rel_matches' (descending)
34  // depending on 'rel_matches' parameter to PT_FamilyFinder::searchFamily()
35 public:
37 
38  char *name;
39  long matches;
40  double rel_matches;
41 
44 
45  FamilyList();
46  ~FamilyList();
47 };
48 
49 struct aisc_com;
50 
51 class FamilyFinder : virtual Noncopyable {
52  bool rel_matches;
53  RelativeScoreScaling scaling;
54 
55 protected:
57 
59 
60 #if defined(WARN_TODO)
61 #warning change real_hits back to int when aisc_get() has been made failsafe
62 #endif
63  long real_hits;
64 
66 
67 public:
68  FamilyFinder(bool rel_matches_, RelativeScoreScaling scaling_);
69  virtual ~FamilyFinder();
70 
71  void restrict_2_region(const PosRange& range_) {
72  // Restrict oligo search to 'range_'
73  // Only oligos which are completely inside that region are used for calculating relationship.
74  // Has to be called before calling searchFamily.
75  range = range_;
76  }
77 
78  void unrestrict() { range = PosRange(-1, -1); }
79  const PosRange& get_TargetRange() const { return range; }
80 
81  virtual GB_ERROR searchFamily(const char *sequence, FF_complement compl_mode, int max_results, double min_score) = 0;
82 
83  const FamilyList *getFamilyList() const { return family_list; }
84  void delete_family_list();
85 
86  bool hits_were_truncated() const { return hits_truncated; }
87  bool uses_rel_matches() const { return rel_matches; }
88  RelativeScoreScaling get_scaling() const { return scaling; }
89  int getRealHits() const { return real_hits; }
90 };
91 
92 class PT_FamilyFinder : public FamilyFinder { // derived from a Noncopyable
93  GBDATA *gb_main;
94  int server_id;
95  int oligo_len;
96  int mismatches;
97  bool fast_flag;
98 
99  struct PT_FF_comImpl *ci;
100 
101  GB_ERROR init_communication();
102  GB_ERROR open(const char *servername);
103  GB_ERROR retrieve_family(const char *sequence, FF_complement compl_mode, int max_results, double min_score) __ATTR__USERESULT;
104  void close();
105 
106 public:
107 
108  PT_FamilyFinder(GBDATA *gb_main_, int server_id_, int oligo_len_, int mismatches_, bool fast_flag_, bool rel_matches_, RelativeScoreScaling scaling_);
110 
111  GB_ERROR searchFamily(const char *sequence, FF_complement compl_mode, int max_results, double min_score) OVERRIDE __ATTR__USERESULT;
112 
113  const char *results2string();
114 };
115 
116 // --------------------------------------------------------------------------------
117 
118 #define AWAR_NN_BASE "next_neighbours/"
119 
120 #define AWAR_NN_OLIGO_LEN AWAR_NN_BASE "oligo_len"
121 #define AWAR_NN_MISMATCHES AWAR_NN_BASE "mismatches"
122 #define AWAR_NN_FAST_MODE AWAR_NN_BASE "fast_mode"
123 #define AWAR_NN_REL_MATCHES AWAR_NN_BASE "rel_matches"
124 #define AWAR_NN_REL_SCALING AWAR_NN_BASE "scaling"
125 
126 class AW_root;
127 class AW_window;
128 
129 void AWTC_create_common_next_neighbour_vars(AW_root *aw_root, const RootCallback& awar_changed_cb);
130 void AWTC_create_common_next_neighbour_fields(AW_window *aws, int scaler_length);
131 
132 #else
133 #error awtc_next_neighbours.hxx included twice
134 #endif // AWTC_NEXT_NEIGHBOURS_HXX
const char * GB_ERROR
Definition: arb_core.h:25
virtual GB_ERROR searchFamily(const char *sequence, FF_complement compl_mode, int max_results, double min_score)=0
FamilyFinder(bool rel_matches_, RelativeScoreScaling scaling_)
GB_ERROR searchFamily(const char *sequence, FF_complement compl_mode, int max_results, double min_score) OVERRIDE __ATTR__USERESULT
RelativeScoreScaling
void restrict_2_region(const PosRange &range_)
bool hits_were_truncated() const
bool uses_rel_matches() const
FamilyList * insertSortedBy_rel_matches(FamilyList *other)
const char * results2string()
FF_complement
FamilyList * family_list
PT_FamilyFinder(GBDATA *gb_main_, int server_id_, int oligo_len_, int mismatches_, bool fast_flag_, bool rel_matches_, RelativeScoreScaling scaling_)
FamilyList * insertSortedBy_matches(FamilyList *other)
FamilyList * next
static void awar_changed_cb(AW_root *, awt_mask_awar_item *item)
#define OVERRIDE
Definition: cxxforward.h:93
#define __ATTR__USERESULT
Definition: attributes.h:58
const FamilyList * getFamilyList() const
const PosRange & get_TargetRange() const
void AWTC_create_common_next_neighbour_vars(AW_root *aw_root, const RootCallback &awar_changed_cb)
void AWTC_create_common_next_neighbour_fields(AW_window *aws, int scaler_length)
RelativeScoreScaling get_scaling() const
int getRealHits() const