source: trunk/GDE/SINA/builddir/src/search.h

Last change on this file was 19170, checked in by westram, 2 years ago
  • sina source
    • unpack + remove tarball
    • no longer ignore sina builddir.
File size: 3.9 KB
Line 
1/*
2Copyright (c) 2006-2018 Elmar Pruesse <elmar.pruesse@ucdenver.edu>
3
4This file is part of SINA.
5SINA is free software: you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free
7Software Foundation, either version 3 of the License, or (at your
8option) any later version.
9
10SINA is distributed in the hope that it will be useful, but WITHOUT ANY
11WARRANTY; without even the implied warranty of MERCHANTABILITY or
12FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13for more details.
14
15You should have received a copy of the GNU General Public License
16along with SINA.  If not, see <http://www.gnu.org/licenses/>.
17
18Additional permission under GNU GPL version 3 section 7
19
20If you modify SINA, or any covered work, by linking or combining it
21with components of ARB (or a modified version of that software),
22containing parts covered by the terms of the
23ARB-public-library-license, the licensors of SINA grant you additional
24permission to convey the resulting work. Corresponding Source for a
25non-source form of such a combination shall include the source code
26for 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
38namespace sina {
39
40class query_arb;
41
42enum ENGINE_TYPE {
43    ENGINE_ARB_PT=0,
44    ENGINE_SINA_KMER=1
45};
46std::ostream& operator<<(std::ostream& out, const sina::ENGINE_TYPE& t);
47void validate(boost::any& v, const std::vector<std::string>& values,
48              sina::ENGINE_TYPE* /*unused*/,int /*unused*/);
49
50
51class search : private boost::noncopyable {
52protected:
53    search() = default;
54public:
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 :
Note: See TracBrowser for help on using the repository browser.