Loading...
Searching...
No Matches
seqan3::shape Class Reference
Search » k-mer Index

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

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

Inheritance diagram for seqan3::shape:
[legend]

## 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 shape & | operator= (shape const &) noexcept=default
| Defaulted.
constexpr shape & | operator= (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 & | operator= (dynamic_bitset const &) noexcept=default
| Defaulted.
| ~dynamic_bitset () noexcept=default
| Defaulted.
constexpr void | assign (char const(&lit)[N])
| Assign from literal.
constexpr iterator | begin () 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 | cend () const noexcept
| Returns iterator past the end of the dynamic_bitset.
constexpr dynamic_bitset & | operator&= (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_bitset & | operator|= (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_bitset & | operator^= (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_bitset & | operator<<= (size_t const count) noexcept
| Performs binary shift left on the current object.
constexpr dynamic_bitset & | operator>>= (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_bitset & | set () noexcept
| Sets all bits to 1.
constexpr dynamic_bitset & | reset () noexcept
| Sets all bits to 0.
constexpr dynamic_bitset & | flip () noexcept
| Flips all bits (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 | 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 reference | front () noexcept
| Returns the first element.
constexpr reference | back () noexcept
| Returns the last element.
constexpr bitfield * | raw_data () 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 | erase (const_iterator begin_it, const_iterator end_it) 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.
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
| Equals bool.
using | reference
| A proxy type that enables assignment.
using | const_reference
| Equals the value_type.
using | iterator
| The iterator type of this container (a random access iterator).
using | const_iterator
| The const_iterator type of this container (a random access iterator).
using | difference_type
| A std::ptrdiff_t.
using | size_type
| 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-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 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"
}
seqan3::shape
A class that defines which positions of a pattern to hash.
Definition shape.hpp:57
debug_stream.hpp
Provides seqan3::debug_stream and related types.
seqan3::debug_stream
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:38
seqan3::literals
The SeqAn namespace for literals.
shape.hpp
Provides seqan3::shape.
seqan3::bin_literal
A strong type of underlying type uint64_t that represents the shape in binary representation.
Definition shape.hpp:31
seqan3::ungapped
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]

seqan3::shape::shape | ( | ungapped | k | ) |

inline constexpr noexcept

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]

seqan3::shape::shape | ( | bin_literal const | literal | ) |

inline constexpr noexcept

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()

shape operator""_shape | ( | unsigned long long const | value | ) |

related

The seqan3::shape literal.

Parameters

  [in] | value | The unsigned integer to assign.

Returns
  seqan3::shape

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

- shape.hpp

Hide me