SeqAn3
3.4.0
The Modern C++ library for sequence analysis.
Toggle main menu visibility
Loading...
Searching...
No Matches
translation.hpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
2
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
3
// SPDX-License-Identifier: BSD-3-Clause
4
9
10
#pragma once
11
12
#include <
tuple
>
13
14
#include <
seqan3/alphabet/aminoacid/aa27.hpp
>
15
#include <
seqan3/alphabet/aminoacid/translation_details.hpp
>
16
#include <
seqan3/alphabet/aminoacid/translation_genetic_code.hpp
>
17
#include <
seqan3/core/range/type_traits.hpp
>
18
19
namespace
seqan3
20
{
21
22
// forwards:
23
class
dna4
;
24
class
dna5
;
25
class
dna15
;
26
class
rna4
;
27
class
rna5
;
28
class
rna15
;
29
51
template
<genetic_code gc = genetic_code::canonical, nucleot
id
e_alphabet nucl_type>
52
constexpr
aa27
translate_triplet
(nucl_type
const
& n1, nucl_type
const
& n2, nucl_type
const
& n3)
noexcept
53
{
54
if
constexpr
(std::same_as<nucl_type, dna4> || std::same_as<nucl_type, dna5> || std::same_as<nucl_type, dna15>)
55
{
56
// table exists for dna15 and is generated for dna4 and dna5 (compile time ok, because small)
57
return
seqan3::detail::translation_table<nucl_type, gc>::value[
to_rank
(n1)][
to_rank
(n2)][
to_rank
(n3)];
58
}
59
else
if
constexpr
(std::same_as<nucl_type, rna4> || std::same_as<nucl_type, rna5> || std::same_as<nucl_type, rna15>)
60
{
61
using
rna2dna_t =
62
std::conditional_t<std::same_as<nucl_type, rna4>
,
63
dna4
,
64
std::conditional_t<std::same_as<nucl_type, rna5>
,
65
dna5
,
66
std::conditional_t<std::same_as<nucl_type, rna15>
,
dna15
,
void
>>>;
67
68
// we can use dna's tables, because ranks are identical
69
return
seqan3::detail::translation_table<rna2dna_t, gc>::value[
to_rank
(n1)][
to_rank
(n2)][
to_rank
(n3)];
70
}
71
else
// composites or user defined nucleotide
72
{
73
// we cast to dna15; slightly slower run-time, but lot's of compile time saved for large alphabets.
74
// (nucleotide types can be converted to dna15 by definition)
75
return
seqan3::detail::translation_table<dna15, gc>::value[
to_rank
(
static_cast<
dna15
>
(n1))][
to_rank
(
76
static_cast<
dna15
>
(n2))][
to_rank
(
static_cast<
dna15
>
(n3))];
77
}
78
}
79
80
}
// namespace seqan3
aa27.hpp
Provides seqan3::aa27, container aliases and string literals.
seqan3::aa27
The twenty-seven letter amino acid alphabet.
Definition
aa27.hpp:43
seqan3::dna15
The 15 letter DNA alphabet, containing all IUPAC smybols minus the gap.
Definition
dna15.hpp:48
seqan3::dna4
The four letter DNA alphabet of A,C,G,T.
Definition
dna4.hpp:50
seqan3::dna5
The five letter DNA alphabet of A,C,G,T and the unknown character N.
Definition
dna5.hpp:48
seqan3::rna15
The 15 letter RNA alphabet, containing all IUPAC smybols minus the gap.
Definition
rna15.hpp:48
seqan3::rna4
The four letter RNA alphabet of A,C,G,U.
Definition
rna4.hpp:46
seqan3::rna5
The five letter RNA alphabet of A,C,G,U and the unknown character N.
Definition
rna5.hpp:46
std::conditional_t
type_traits.hpp
Provides various transformation traits used by the range module.
seqan3::translate_triplet
constexpr aa27 translate_triplet(nucl_type const &n1, nucl_type const &n2, nucl_type const &n3) noexcept
Translate one nucleotide triplet into single amino acid (single nucleotide interface).
Definition
translation.hpp:52
seqan3::to_rank
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition
alphabet/concept.hpp:152
seqan3
The main SeqAn3 namespace.
Definition
aligned_sequence_concept.hpp:26
translation_details.hpp
Provides translation details for nucleotide to aminoacid translation.
translation_genetic_code.hpp
Genetic codes used for translating a triplet of nucleotides into an amino acid.
tuple
Hide me
Version:
seqan3
alphabet
aminoacid
translation.hpp
Generated on
for SeqAn3 by
1.17.0