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  // @@@ change real_hits back to int when aisc_get() has been made failsafe
61  long real_hits;
62 
64 
65 public:
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 
90 class 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 
104 public:
105 
106  PT_FamilyFinder(GBDATA *gb_main_, int server_id_, int oligo_len_, int mismatches_, bool fast_flag_, bool rel_matches_, RelativeScoreScaling scaling_);
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 
124 class AW_root;
125 class AW_window;
126 
127 void AWTC_create_common_next_neighbour_vars(AW_root *aw_root, const RootCallback& awar_changed_cb);
128 void 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
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:112
#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