SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::shape Class Reference

A class that defines which positions of a pattern to hash. More...

#include <seqan3/search/kmer_index/shape.hpp>

+ Inheritance diagram for seqan3::shape:

Public Member Functions

Constructors, destructor and assignment
constexpr shape () noexcept=default
 Defaulted.
 
constexpr shape (shape const &) noexcept=default
 Defaulted.
 
constexpr shape (shape &&) noexcept=default
 Defaulted.
 
constexpr shapeoperator= (shape const &) noexcept=default
 Defaulted.
 
constexpr shapeoperator= (shape &&) noexcept=default
 Defaulted.
 
 ~shape () noexcept=default
 Defaulted.
 
constexpr shape (ungapped k) noexcept
 Construct an ungapped shape from a given size.
 
constexpr shape (bin_literal const literal) noexcept
 Construct from a given seqan3::bin_literal.
 
- Public Member Functions inherited from seqan3::dynamic_bitset< 58 >
constexpr dynamic_bitset () noexcept=default
 Defaulted.
 
constexpr dynamic_bitset (dynamic_bitset const &) noexcept=default
 Defaulted.
 
constexpr dynamic_bitset (dynamic_bitset &&) noexcept=default
 Defaulted.
 
constexpr dynamic_bitset (uint64_t const value)
 Construct from an uint64_t.
 
constexpr dynamic_bitset (begin_it_type begin_it, end_it_type end_it) noexcept
 Construct from two iterators.
 
constexpr dynamic_bitset (other_range_t &&range) noexcept
 Construct from a different range.
 
constexpr dynamic_bitset (size_type const n, value_type const value) noexcept
 Construct with n times value.
 
constexpr dynamic_bitset (char const(&lit)[N])
 Construction from literal.
 
constexpr dynamic_bitsetoperator= (dynamic_bitset const &) noexcept=default
 Defaulted.
 
constexpr dynamic_bitsetoperator= (dynamic_bitset &&) noexcept=default
 Defaulted.
 
constexpr dynamic_bitsetoperator= (std::initializer_list< value_type > const ilist) noexcept
 Assign from std::initializer_list.
 
constexpr dynamic_bitsetoperator= (char const(&lit)[N])
 Assign from literal.
 
 ~dynamic_bitset () noexcept=default
 Defaulted.
 
constexpr void assign (char const(&lit)[N])
 Assign from literal.
 
constexpr void assign (std::initializer_list< value_type > const ilist) noexcept
 Assign from std::initializer_list.
 
constexpr void assign (size_type const count, value_type const value) noexcept
 Assign with count times value.
 
constexpr void assign (other_range_t &&range) noexcept
 Assign from a different range.
 
constexpr void assign (begin_it_type begin_it, end_it_type end_it) noexcept
 Assign from pair of iterators.
 
constexpr iterator begin () noexcept
 Returns the begin to the dynamic_bitset.
 
constexpr const_iterator begin () const noexcept
 Returns the begin to the dynamic_bitset.
 
constexpr const_iterator cbegin () const noexcept
 Returns the begin to the dynamic_bitset.
 
constexpr iterator end () noexcept
 Returns iterator past the end of the dynamic_bitset.
 
constexpr const_iterator end () const noexcept
 Returns iterator past the end of the dynamic_bitset.
 
constexpr const_iterator cend () const noexcept
 Returns iterator past the end of the dynamic_bitset.
 
constexpr dynamic_bitsetoperator&= (dynamic_bitset const &rhs) noexcept
 Sets the bits to the result of binary AND on corresponding pairs of bits of *this and rhs.
 
constexpr dynamic_bitsetoperator|= (dynamic_bitset const &rhs) noexcept
 Sets the bits to the result of binary OR on corresponding pairs of bits of *this and rhs.
 
constexpr dynamic_bitsetoperator^= (dynamic_bitset const &rhs) noexcept
 Sets the bits to the result of binary XOR on corresponding pairs of bits of *this and rhs.
 
constexpr dynamic_bitset operator~ () const noexcept
 Returns a temporary copy of *this with all bits flipped (binary NOT).
 
constexpr dynamic_bitsetoperator<<= (size_t const count) noexcept
 Performs binary shift left on the current object.
 
constexpr dynamic_bitsetoperator>>= (size_t const count) noexcept
 Performs binary shift right on the current object.
 
constexpr dynamic_bitset operator>> (size_t const count) const noexcept
 Performs binary shift right.
 
constexpr dynamic_bitset operator<< (size_t const count) const noexcept
 Performs binary shift left.
 
constexpr dynamic_bitsetset () noexcept
 Sets all bits to 1.
 
constexpr dynamic_bitsetset (size_t const i, bool const value=true)
 Sets the i'th bit to value.
 
constexpr dynamic_bitsetreset () noexcept
 Sets all bits to 0.
 
constexpr dynamic_bitsetreset (size_t const i)
 Sets the i'th bit to false.
 
constexpr dynamic_bitsetflip () noexcept
 Flips all bits (binary NOT).
 
constexpr dynamic_bitsetflip (size_t const i)
 Flips the i'th bit (binary NOT).
 
constexpr bool all () const noexcept
 Checks if all bit are set.
 
constexpr bool any () const noexcept
 Checks if any bit is set.
 
constexpr bool none () const noexcept
 Checks if no bit is set.
 
constexpr size_type count () const noexcept
 Returns the number of set bits.
 
constexpr reference at (size_t const i)
 Returns the i-th element.
 
constexpr const_reference at (size_t const i) const
 Returns the i-th element.
 
constexpr const_reference test (size_t const i) const
 Returns the i-th element.
 
constexpr reference operator[] (size_t const i) noexcept
 Returns the i-th element.
 
constexpr const_reference operator[] (size_t const i) const noexcept
 Returns the i-th element.
 
constexpr reference front () noexcept
 Returns the first element.
 
constexpr const_reference front () const noexcept
 Returns the first element.
 
constexpr reference back () noexcept
 Returns the last element.
 
constexpr const_reference back () const noexcept
 Returns the last element.
 
constexpr bitfield * raw_data () noexcept
 Direct access to the underlying bit field.
 
constexpr bitfield const * raw_data () const noexcept
 Direct access to the underlying bit field.
 
constexpr bool empty () const noexcept
 Checks whether the container is empty.
 
constexpr size_type size () const noexcept
 Returns the number of elements in the container, i.e. std::distance(begin(), end()).
 
constexpr size_type max_size () const noexcept
 Returns the maximum number of elements the container is able to hold and resolves to bit_capacity.
 
constexpr size_type capacity () const noexcept
 Returns the number of elements that the container is able to hold and resolves to bit_capacity.
 
constexpr void reserve (size_t) const noexcept
 Since the capacity is fixed on compile time, this is a no-op.
 
constexpr void shrink_to_fit () const noexcept
 Since the capacity is fixed on compile time, this is a no-op.
 
constexpr void clear () noexcept
 Removes all elements from the container.
 
constexpr iterator insert (const_iterator pos, value_type const value) noexcept
 Inserts value before pos in the container.
 
constexpr iterator insert (const_iterator pos, size_type const count, value_type const value) noexcept
 Inserts count copies of value before position in the container.
 
constexpr iterator insert (const_iterator pos, begin_it_type begin_it, end_it_type end_it) noexcept
 Inserts elements from range [begin_it, end_it) before pos in the container.
 
constexpr iterator insert (const_iterator pos, std::initializer_list< value_type > const &ilist) noexcept
 Inserts elements from initializer list before pos in the container.
 
constexpr iterator erase (const_iterator begin_it, const_iterator end_it) noexcept
 Removes specified elements from the container.
 
constexpr iterator erase (const_iterator pos) noexcept
 Removes specified elements from the container.
 
constexpr void push_back (value_type const value) noexcept
 Appends the given element value to the end of the container.
 
constexpr void pop_back () noexcept
 Removes the last element of the container.
 
constexpr void resize (size_type const count, value_type const value=false) noexcept
 Resizes the container to contain count elements.
 
constexpr void swap (dynamic_bitset &rhs) noexcept
 Swap contents with another instance.
 
constexpr void swap (dynamic_bitset &&rhs) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::string to_string (char_t zero=char_t{ '0'}, char_t one=char_t{ '1'}) const
 Converts the dynamic_bitset to a std::string.
 
constexpr unsigned long to_ulong () const
 Converts the dynamic_bitset to an unsigned long integer.
 
constexpr unsigned long long to_ullong () const
 Converts the dynamic_bitset to an unsigned long long integer.
 

Related Symbols

(Note that these are not member symbols.)

Other literals
constexpr shape operator""_shape (unsigned long long const value)
 The seqan3::shape literal.
 

Additional Inherited Members

- Public Types inherited from seqan3::dynamic_bitset< 58 >
using value_type = bool
 Equals bool.
 
using reference = reference_proxy_type
 A proxy type that enables assignment.
 
using const_reference = bool
 Equals the value_type.
 
using iterator = detail::random_access_iterator< dynamic_bitset >
 The iterator type of this container (a random access iterator).
 
using const_iterator = detail::random_access_iterator< dynamic_bitset const >
 The const_iterator type of this container (a random access iterator).
 
using difference_type = ptrdiff_t
 A std::ptrdiff_t.
 
using size_type = detail::min_viable_uint_t< bit_capacity >
 An unsigned integer type (usually std::size_t).
 

Detailed Description

A class that defines which positions of a pattern to hash.

This entity is experimental and subject to change in the future.

When hashing a sequence, there may be positions that do not count towards the final hash value. A shape offers an easy way to define such patterns. Given a k-mer length k (0 < k <= 58), a shape represents a binary sequence where a 0 encodes a "don't care position", i.e. a position that is not taken into account when computing the hash value. A 1 therefore translates to a position that is used to compute the hash value.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <ranges> // For std::ranges::size()
#include <seqan3/core/debug_stream.hpp> // For seqan3::debug_stream
#include <seqan3/search/kmer_index/shape.hpp> // For seqan3::shape
using namespace seqan3::literals;
int main()
{
seqan3::shape s0{seqan3::ungapped{5}}; // represents "11111", i.e. ungapped 5-mer
seqan3::debug_stream << s0 << '\n'; // prints "[1,1,1,1,1]"
seqan3::debug_stream << std::ranges::size(s0) << '\n'; // prints "5"
seqan3::shape s1{seqan3::bin_literal{0b101}}; // represents "101", i.e. gapped 3-mer
seqan3::debug_stream << s1 << '\n'; // prints "[1,0,1]"
seqan3::debug_stream << std::ranges::size(s1) << '\n'; // prints "3"
seqan3::shape s2{0b101_shape}; // Same as previous
seqan3::debug_stream << s2 << '\n'; // prints "[1,0,1]"
seqan3::debug_stream << std::ranges::size(s2) << '\n'; // prints "3"
}
A class that defines which positions of a pattern to hash.
Definition shape.hpp:57
Provides seqan3::debug_stream and related types.
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:37
The SeqAn namespace for literals.
Provides seqan3::shape.
A strong type of underlying type uint64_t that represents the shape in binary representation.
Definition shape.hpp:31
A strong type of underlying type uint8_t that represents the ungapped shape size.
Definition shape.hpp:22
Attention
0 < size <= 58

Constructor & Destructor Documentation

◆ shape() [1/2]

constexpr seqan3::shape::shape ( ungapped  k)
inlineconstexprnoexcept

Construct an ungapped shape from a given size.

Complexity

Linear in k.

Exceptions

No-throw guarantee.

Attention
The size must be in the interval [1, 58]. In Debug mode, an assertion will check this constraint.

◆ shape() [2/2]

constexpr seqan3::shape::shape ( bin_literal const  literal)
inlineconstexprnoexcept

Construct from a given seqan3::bin_literal.

Complexity

Linear in the size of the bin_literal.

Exceptions

No-throw guarantee.

Attention
The size of the bin_literal must be in the interval [1, 58].

Friends And Related Symbol Documentation

◆ operator""_shape()

constexpr shape operator""_shape ( unsigned long long const  value)
related

The seqan3::shape literal.

Parameters
[in]valueThe unsigned integer to assign.
Returns
seqan3::shape

The documentation for this class was generated from the following file:
Hide me