SeqAn3
mode.hpp
Go to the documentation of this file.
1 // ============================================================================
2 // SeqAn - The Library for Sequence Analysis
3 // ============================================================================
4 //
5 // Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin
6 // Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 // * Neither the name of Knut Reinert or the FU Berlin nor the names of
18 // its contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
25 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 // DAMAGE.
32 //
33 // ============================================================================
34 
40 #pragma once
41 
46 
51 namespace seqan3::detail
52 {
53 
55 struct search_mode_all {};
57 struct search_mode_all_best {};
59 struct search_mode_best {};
60 
61 } // namespace seqan3::detail
62 
63 namespace seqan3::search_cfg
64 {
65 
67 inline detail::search_mode_all constexpr all;
69 inline detail::search_mode_all_best constexpr all_best;
71 inline detail::search_mode_best constexpr best;
72 
79 struct strata : detail::strong_type<uint8_t, strata, detail::strong_type_skill::convert>
80 {
81  using detail::strong_type<uint8_t, strata, detail::strong_type_skill::convert>::strong_type;
82 };
83 
84 } // namespace seqan3::search_cfg
85 
86 namespace seqan3::detail
87 {
91 template <typename mode_t>
92 struct search_config_mode
93 {
95  mode_t value;
97 };
98 
102 template <template <typename ...> typename search_config_mode_type>
103 struct search_config_mode_adaptor : public configuration_fn_base<search_config_mode_adaptor<search_config_mode_type>>
104 {
105 
111  template <typename configuration_t, typename mode_t>
113  requires is_algorithm_configuration_v<remove_cvref_t<configuration_t>>
115  // TODO: require strong type
116  constexpr auto invoke(configuration_t && cfg, mode_t mode) const
117  {
118  static_assert(is_valid_search_configuration_v<search_cfg::id::mode, remove_cvref_t<configuration_t>>,
119  SEQAN3_INVALID_CONFIG(search_cfg::id::mode));
120 
121  return std::forward<configuration_t>(cfg).push_front(search_config_mode<mode_t>{std::move(mode)});
122  }
123 };
124 
127 template <>
128 struct on_search_config<search_cfg::id::mode>
129 {
131  template <config_element_concept t>
132  using invoke = typename is_type_specialisation_of<t, search_config_mode>::type;
133 };
134 
137 template <typename mode_t>
138 struct search_config_type_to_id<search_config_mode<mode_t>>
139 {
141  static constexpr search_cfg::id value = search_cfg::id::mode;
142 };
143 } // namespace seqan3::detail
144 
145 namespace seqan3::search_cfg
146 {
150 inline detail::search_config_mode_adaptor<seqan3::detail::search_config_mode> constexpr mode;
151 
152 } // namespace seqan3::search_cfg
153 
Provides functionality to access get function by enum values.
detail::search_mode_best constexpr best
Configuration element to receive one best hit (with the lowest number of errors). ...
Definition: mode.hpp:71
Provides seqan3::type_list and auxiliary metafunctions.
A special sub namespace for the search configurations.
Continuous gaps in the beginning and end of both sequences are not scored.
Configuration element to receive all hits with the best number of errors plus the strata value...
Definition: mode.hpp:79
id
Specifies an id for every configuration element.
Definition: utility.hpp:68
std::remove_cv_t< std::remove_reference_t< t > > remove_cvref_t
Return the input type with const, volatile and references removed [Type metafunction].
Definition: basic.hpp:64
detail::search_mode_all_best constexpr all_best
Configuration element to receive all hits within the lowest number of errors.
Definition: mode.hpp:69
Definition: aligned_sequence_concept.hpp:288
Provides various metafunctions on generic types.
detail::search_config_mode_adaptor< seqan3::detail::search_config_mode > constexpr mode
Configuration element to determine the search mode.
Definition: mode.hpp:150
Meta-Header for components of the algorithm submodule.