source: tags/ms_r16q2/AWTC/awtc_next_neighbours.hxx

Last change on this file was 14622, checked in by westram, 6 years ago
  • reintegrates 'ui' into 'trunk'
    • implements #656
    • adds instant update for
      • next neighbour search
      • branch analysis (mark functions)
      • arb-phylo (filter setup)
  • adds: log:branches/ui@14588:14621
  • 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#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
65    PosRange range;
66
67public:
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
92class 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
106public:
107
108    PT_FamilyFinder(GBDATA *gb_main_, int server_id_, int oligo_len_, int mismatches_, bool fast_flag_, bool rel_matches_, RelativeScoreScaling scaling_);
109    ~PT_FamilyFinder() OVERRIDE;
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
126class AW_root;
127class AW_window;
128
129void AWTC_create_common_next_neighbour_vars(AW_root *aw_root, const RootCallback& awar_changed_cb);
130void 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
Note: See TracBrowser for help on using the repository browser.