SeqAn3
masked.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 
39 #pragma once
40 
45 
46 namespace seqan3
47 {
66  template <typename sequence_alphabet_t>
68  requires alphabet_concept<sequence_alphabet_t>
70 class masked : public cartesian_composition<masked<sequence_alphabet_t>, sequence_alphabet_t, mask>
71 {
72 private:
75 
76 public:
78  using sequence_alphabet_type = sequence_alphabet_t;
79 
82 
84 
88  constexpr masked() : base_type{} {}
89  constexpr masked(masked const &) = default;
90  constexpr masked(masked &&) = default;
91  constexpr masked & operator =(masked const &) = default;
92  constexpr masked & operator =(masked &&) = default;
93  ~masked() = default;
94 
95  using base_type::base_type; // Inherit non-default constructors
96 
98  SEQAN3_DOXYGEN_ONLY(( constexpr masked(component_type const alph) {} ))
100  SEQAN3_DOXYGEN_ONLY(( constexpr masked(indirect_component_type const alph) {} ))
102  SEQAN3_DOXYGEN_ONLY(( constexpr masked & operator=(component_type const alph) {} ))
104  SEQAN3_DOXYGEN_ONLY(( constexpr masked & operator=(indirect_component_type const alph) {} ))
106 
107  // Inherit operators from base
108  using base_type::operator=;
109  using base_type::operator==;
110  using base_type::operator!=;
111  using base_type::operator>=;
112  using base_type::operator<=;
113  using base_type::operator<;
114  using base_type::operator>;
115 
119  constexpr masked & assign_char(char_type const c)
121  {
122  seqan3::assign_char(get<0>(*this), c);
123  seqan3::assign_rank(get<1>(*this), is_lower(c));
124  return *this;
125  }
127 
131  constexpr char_type to_char() const noexcept
133  {
134  if (seqan3::to_rank(get<1>(*this)))
135  {
136  return to_lower(seqan3::to_char(get<0>(*this)));
137  }
138  else
139  {
140  return seqan3::to_char(get<0>(*this));
141  }
142  }
143 };
144 
147 template <typename sequence_alphabet_type>
148 masked(sequence_alphabet_type &&, mask const &)
150 } //namespace seqan3
Meta-header for the mask submodule; includes all headers from alphabet/mask/.
char_t char_type
The type of the alphabet when converted to char (e.g. via to_char()).
Definition: alphabet_base.hpp:87
sequence_alphabet_t sequence_alphabet_type
First template parameter as member type.
Definition: masked.hpp:78
The CRTP base for a combined alphabet that contains multiple values of different alphabets at the sam...
Definition: cartesian_composition.hpp:209
constexpr char_type to_char() const noexcept
Return a character.
Definition: masked.hpp:132
constexpr masked & assign_char(char_type const c)
Assign from a character.
Definition: masked.hpp:120
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:58
static detail::min_viable_uint_t< size > constexpr value_size
The size of the alphabet, i.e. the number of different values it can take.
Definition: alphabet_base.hpp:198
constexpr alphabet_type & assign_rank(alphabet_type &alph, underlying_rank_t< alphabet_type > const rank) requires requires(alphabet_type alph)
Implementation of seqan3::semi_alphabet_concept::assign_rank() that delegates to a member function...
Definition: member_exposure.hpp:110
Provides seqan3::cartesian_composition.
Provides utilities for modifying characters.
constexpr alphabet_type & assign_char(alphabet_type &alph, underlying_char_t< alphabet_type > const chr) requires requires(alphabet_type alph)
Implementation of seqan3::alphabet_concept::assign_char() that delegates to a member function...
Definition: member_exposure.hpp:178
Provides parse conditions for tokenization.
Implementation of a masked alphabet to be used for cartesian compositions.
Definition: mask.hpp:61
constexpr masked(component_type const alph)
Construction via a value of one of the components.
Definition: masked.hpp:98
typename underlying_char< alphabet_type >::type underlying_char_t
The char_type of the alphabet. [type metafunction shortcut].
Definition: concept_pre.hpp:172
constexpr underlying_rank_t< alphabet_type > to_rank(alphabet_type const alph) requires requires(alphabet_type alph)
Implementation of seqan3::semi_alphabet_concept::to_rank() that delegates to a member function...
Definition: member_exposure.hpp:97
constexpr underlying_char_t< alphabet_type > to_char(alphabet_type const alph) requires requires(alphabet_type alph)
Implementation of seqan3::alphabet_concept::to_char() that delegates to a member function.
Definition: member_exposure.hpp:165
auto constexpr is_lower
Checks whether c is a lower case character.
Definition: parse_condition.hpp:296
Implementation of a masked composition, which extends a given alphabet with a mask.
Definition: masked.hpp:70
constexpr char_type to_lower(char_type const c) noexcept
Converts &#39;A&#39;-&#39;Z&#39; to &#39;a&#39;-&#39;z&#39; respectively; other characters are returned as is.
Definition: char_operations.hpp:107