1 | /* |
---|
2 | Copyright (c) 2006-2018 Elmar Pruesse <elmar.pruesse@ucdenver.edu> |
---|
3 | |
---|
4 | This file is part of SINA. |
---|
5 | SINA is free software: you can redistribute it and/or modify it under |
---|
6 | the terms of the GNU General Public License as published by the Free |
---|
7 | Software Foundation, either version 3 of the License, or (at your |
---|
8 | option) any later version. |
---|
9 | |
---|
10 | SINA is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
13 | for more details. |
---|
14 | |
---|
15 | You should have received a copy of the GNU General Public License |
---|
16 | along with SINA. If not, see <http://www.gnu.org/licenses/>. |
---|
17 | |
---|
18 | Additional permission under GNU GPL version 3 section 7 |
---|
19 | |
---|
20 | If you modify SINA, or any covered work, by linking or combining it |
---|
21 | with components of ARB (or a modified version of that software), |
---|
22 | containing parts covered by the terms of the |
---|
23 | ARB-public-library-license, the licensors of SINA grant you additional |
---|
24 | permission to convey the resulting work. Corresponding Source for a |
---|
25 | non-source form of such a combination shall include the source code |
---|
26 | for the parts of ARB used as well as that of the covered work. |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef _SEARCH_H_ |
---|
30 | #define _SEARCH_H_ |
---|
31 | |
---|
32 | #include <boost/core/noncopyable.hpp> |
---|
33 | #include <boost/program_options.hpp> |
---|
34 | #include <string> |
---|
35 | #include <vector> |
---|
36 | #include "cseq.h" |
---|
37 | |
---|
38 | namespace sina { |
---|
39 | |
---|
40 | class query_arb; |
---|
41 | |
---|
42 | enum ENGINE_TYPE { |
---|
43 | ENGINE_ARB_PT=0, |
---|
44 | ENGINE_SINA_KMER=1 |
---|
45 | }; |
---|
46 | std::ostream& operator<<(std::ostream& out, const sina::ENGINE_TYPE& t); |
---|
47 | void validate(boost::any& v, const std::vector<std::string>& values, |
---|
48 | sina::ENGINE_TYPE* /*unused*/,int /*unused*/); |
---|
49 | |
---|
50 | |
---|
51 | class search : private boost::noncopyable { |
---|
52 | protected: |
---|
53 | search() = default; |
---|
54 | public: |
---|
55 | virtual ~search() = default; |
---|
56 | struct result_item { |
---|
57 | result_item(float sc, const cseq* seq) : score(sc), sequence(seq) {} |
---|
58 | float score; |
---|
59 | const cseq* sequence; |
---|
60 | bool operator<(const result_item& o) const { |
---|
61 | if (score < o.score) return true; |
---|
62 | if (score > o.score) return false; |
---|
63 | return *sequence < *o.sequence; |
---|
64 | } |
---|
65 | bool operator>(const result_item& o) const { |
---|
66 | return !operator<(o); |
---|
67 | } |
---|
68 | }; |
---|
69 | using result_vector = std::vector<result_item>; |
---|
70 | |
---|
71 | /** |
---|
72 | * match runs a word search using the PT server |
---|
73 | * |
---|
74 | * arguments: |
---|
75 | * family: will contain scored results |
---|
76 | * query: query sequence |
---|
77 | * min_match: minimum number of results required |
---|
78 | * max_match: maximum number of results desired |
---|
79 | * min_score: minimum relative score |
---|
80 | * max_score: maximum relative score |
---|
81 | * arb: pointer to matching arb database |
---|
82 | * noid: skip matches containing query |
---|
83 | * min_len: skip matches shorter |
---|
84 | * num_full: minimum "full length", ignoring score |
---|
85 | * minlen_full: length to be considered "full" |
---|
86 | * range_cover: minimum sequences touching alignment edge |
---|
87 | * leave_query_out: drop sequence with matching id |
---|
88 | */ |
---|
89 | virtual double match(result_vector &family, |
---|
90 | const cseq& query, |
---|
91 | int min_match, |
---|
92 | int max_match, |
---|
93 | float min_score, |
---|
94 | float max_score, |
---|
95 | query_arb *arb, |
---|
96 | bool noid, |
---|
97 | int minlen, |
---|
98 | int num_full, |
---|
99 | int minlen_full, |
---|
100 | int range_cover, |
---|
101 | bool leave_query_out) = 0; |
---|
102 | |
---|
103 | virtual void find(const cseq& query, result_vector& results, unsigned int max) = 0; |
---|
104 | |
---|
105 | virtual unsigned int size() const = 0; |
---|
106 | }; |
---|
107 | |
---|
108 | } // namespace sina |
---|
109 | |
---|
110 | #endif // _SEARCH_H_ |
---|
111 | |
---|
112 | /* |
---|
113 | Local Variables: |
---|
114 | mode:c++ |
---|
115 | c-file-style:"stroustrup" |
---|
116 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . 0)) |
---|
117 | indent-tabs-mode:nil |
---|
118 | fill-column:99 |
---|
119 | End: |
---|
120 | */ |
---|
121 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : |
---|