SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
align_result_selector.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
15 #include <type_traits>
16 
27 #include <seqan3/std/ranges>
28 
29 namespace seqan3::detail
30 {
31 
38 template <typename first_t, typename second_t>
39 struct alignment_type;
40 
42 template <typename first_t, typename second_t>
47 struct alignment_type<first_t, second_t>
48 {
50  using type = std::tuple<gap_decorator<all_view<first_t &>>, gap_decorator<all_view<second_t &>>>;
51 };
52 
59 template <std::ranges::ForwardRange first_range_t,
60  std::ranges::ForwardRange second_range_t,
61  typename configuration_t>
63  requires is_type_specialisation_of_v<remove_cvref_t<configuration_t>, configuration>
65 struct align_result_selector
66 {
68  static constexpr auto _determine()
69  {
70  using score_type = int32_t;
71 
72  if constexpr (std::remove_reference_t<configuration_t>::template exists<align_cfg::result>())
73  {
74  if constexpr (std::Same<remove_cvref_t<decltype(get<align_cfg::result>(configuration_t{}).value)>,
75  with_back_coordinate_type>)
76  {
77  return alignment_result_value_type<uint32_t,
78  score_type,
79  alignment_coordinate>{};
80  }
81  else if constexpr (std::Same<remove_cvref_t<decltype(get<align_cfg::result>(configuration_t{}).value)>,
82  with_front_coordinate_type>)
83  {
84  return alignment_result_value_type<uint32_t,
85  score_type,
86  alignment_coordinate,
87  alignment_coordinate>{};
88  }
89  else if constexpr (std::Same<remove_cvref_t<decltype(get<align_cfg::result>(configuration_t{}).value)>,
90  with_alignment_type>)
91  {
92  // Due to an error with gcc8 we define these types beforehand.
93  using first_gapped_seq_type = gapped<value_type_t<first_range_t>>;
94  using second_gapped_seq_type = gapped<value_type_t<second_range_t>>;
95 
96  // We use vectors of gapped sequence if the gap decorator cannot be used.
98 
99  // If the ranges are RandomAccess and Sized we can use the Gap Decorator, otherwise fallback_t.
100  using decorator_t = alignment_type<first_range_t, second_range_t>;
101 
102  return alignment_result_value_type<uint32_t,
103  score_type,
104  alignment_coordinate,
105  alignment_coordinate,
106  detail::transformation_trait_or_t<decorator_t, fallback_t>>{};
107  }
108  else
109  {
110  return alignment_result_value_type<uint32_t, score_type>{};
111  }
112  }
113  else
114  {
115  return alignment_result_value_type<uint32_t, score_type>{};
116  }
117  }
118 
120  using type = decltype(_determine());
121 };
122 
123 } // namespace seqan3::detail
Provides seqan3::detail::transformation_trait_or.
Specifies requirements of a Range type for which begin returns a type that models std::RandomAccessIt...
std::remove_cv_t< std::remove_reference_t< t > > remove_cvref_t
Return the input type with const, volatile and references removed (type trait).
Definition: basic.hpp:35
Specifies the requirements of a Range type that knows its size in constant time with the size functio...
Provides seqan3::type_list and auxiliary type traits.
Provides seqan3::gapped.
Adaptations of concepts from the Ranges TS.
Provides seqan3::view::all.
Definition: aligned_sequence_concept.hpp:35
Provides various type traits on generic types.
Provides seqan3::detail::alignment_coordinate.
Provides seqan3::detail::configuration and utility functions.
Provides various transformation traits used by the range module.
Provides configuration for alignment output.
Specifies requirements of a Range type for which begin returns a type that models std::ForwardIterato...
The concept std::Same<T, U> is satisfied if and only if T and U denote the same type.
Provides seqan3::gap_decorator.