Skip to content

Commit

Permalink
Merge pull request #3028 from eseiler/misc/clang_format
Browse files Browse the repository at this point in the history
[MISC] fix clang-format on nucleotides
  • Loading branch information
smehringer authored Jun 28, 2022
2 parents 568b256 + 05b0a26 commit afde6f4
Show file tree
Hide file tree
Showing 9 changed files with 343 additions and 316 deletions.
111 changes: 57 additions & 54 deletions include/seqan3/alphabet/nucleotide/dna15.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class dna15 : public nucleotide_base<dna15, 15>

//!\brief Befriend seqan3::nucleotide_base.
friend base_t;
//!\cond \brief Befriend seqan3::alphabet_base.
//!\cond
//!\brief Befriend seqan3::alphabet_base.
friend base_t::base_t;
//!\endcond
//!\brief Befriend seqan3::rna15 so it can copy #char_to_rank.
Expand Down Expand Up @@ -93,67 +94,69 @@ class dna15 : public nucleotide_base<dna15, 15>
static constexpr char_type
rank_to_char_table[alphabet_size]{'A', 'B', 'C', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'T', 'V', 'W', 'Y'};

//!\copydoc seqan3::dna4::char_to_rank
static constexpr std::array<rank_type, 256> char_to_rank_table{[]() constexpr {std::array<rank_type, 256> ret{};
//!\copydoc seqan3::dna4::rank_complement_table
static constexpr rank_type rank_complement_table[alphabet_size]{
11, // T is complement of 'A'_dna15
12, // V is complement of 'B'_dna15
4, // G is complement of 'C'_dna15
5, // H is complement of 'D'_dna15
2, // C is complement of 'G'_dna15
3, // D is complement of 'H'_dna15
7, // M is complement of 'K'_dna15
6, // K is complement of 'M'_dna15
8, // N is complement of 'N'_dna15
14, // Y is complement of 'R'_dna15
10, // S is complement of 'S'_dna15
0, // A is complement of 'T'_dna15
1, // B is complement of 'V'_dna15
13, // W is complement of 'W'_dna15
9 // R is complement of 'Y'_dna15
};

//!\copydoc seqan3::dna4::rank_complement
static constexpr rank_type rank_complement(rank_type const rank)
{
return rank_complement_table[rank];
}

// initialize with UNKNOWN (std::array::fill unfortunately not constexpr)
for (auto & c : ret)
c = 8; // rank of 'N'
//!\copydoc seqan3::dna4::rank_to_char
static constexpr char_type rank_to_char(rank_type const rank)
{
return rank_to_char_table[rank];
}

// reverse mapping for characters and their lowercase
for (size_t rnk = 0u; rnk < alphabet_size; ++rnk)
//!\copydoc seqan3::dna4::char_to_rank
static constexpr rank_type char_to_rank(char_type const chr)
{
ret[rank_to_char_table[rnk]] = rnk;
ret[to_lower(rank_to_char_table[rnk])] = rnk;
using index_t = std::make_unsigned_t<char_type>;
return char_to_rank_table[static_cast<index_t>(chr)];
}

// set U equal to T
ret['U'] = ret['T'];
ret['u'] = ret['t'];

return ret;
}()
}; // namespace seqan3

//!\copydoc seqan3::dna4::rank_complement_table
static constexpr rank_type rank_complement_table[alphabet_size]{
11, // T is complement of 'A'_dna15
12, // V is complement of 'B'_dna15
4, // G is complement of 'C'_dna15
5, // H is complement of 'D'_dna15
2, // C is complement of 'G'_dna15
3, // D is complement of 'H'_dna15
7, // M is complement of 'K'_dna15
6, // K is complement of 'M'_dna15
8, // N is complement of 'N'_dna15
14, // Y is complement of 'R'_dna15
10, // S is complement of 'S'_dna15
0, // A is complement of 'T'_dna15
1, // B is complement of 'V'_dna15
13, // W is complement of 'W'_dna15
9 // R is complement of 'Y'_dna15
};
// clang-format off
//!\copydoc seqan3::dna4::char_to_rank
static constexpr std::array<rank_type, 256> char_to_rank_table
{
[]() constexpr {
std::array<rank_type, 256> ret{};

//!\copydoc seqan3::dna4::rank_complement
static constexpr rank_type rank_complement(rank_type const rank)
{
return rank_complement_table[rank];
}
ret.fill(8u); // initialize with UNKNOWN ('N')

//!\copydoc seqan3::dna4::rank_to_char
static constexpr char_type rank_to_char(rank_type const rank)
{
return rank_to_char_table[rank];
}
// reverse mapping for characters and their lowercase
for (size_t rnk = 0u; rnk < alphabet_size; ++rnk)
{
ret[rank_to_char_table[rnk]] = rnk;
ret[to_lower(rank_to_char_table[rnk])] = rnk;
}

//!\copydoc seqan3::dna4::char_to_rank
static constexpr rank_type char_to_rank(char_type const chr)
{
using index_t = std::make_unsigned_t<char_type>;
return char_to_rank_table[static_cast<index_t>(chr)];
}
}
;
// set U equal to T
ret['U'] = ret['T'];
ret['u'] = ret['t'];

return ret;
}()
};
};
// clang-format on

// ------------------------------------------------------------------
// containers
Expand Down
120 changes: 61 additions & 59 deletions include/seqan3/alphabet/nucleotide/dna16sam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class dna16sam : public nucleotide_base<dna16sam, 16>

//!\brief Befriend seqan3::nucleotide_base.
friend base_t;
//!\cond \brief Befriend seqan3::alphabet_base.
//!\cond
//!\brief Befriend seqan3::alphabet_base.
friend base_t::base_t;
//!\endcond

Expand All @@ -75,71 +76,72 @@ class dna16sam : public nucleotide_base<dna16sam, 16>
static constexpr char_type rank_to_char_table
[alphabet_size]{'=', 'A', 'C', 'M', 'G', 'R', 'S', 'V', 'T', 'W', 'Y', 'H', 'K', 'D', 'B', 'N'};

//!\copydoc seqan3::dna4::char_to_rank_table
static constexpr std::array<rank_type, 256> char_to_rank_table{[]() constexpr {std::array<rank_type, 256> ret{};

// initialize with UNKNOWN (std::array::fill unfortunately not constexpr)
for (auto & c : ret)
c = 15; // rank of 'N'

// reverse mapping for characters and their lowercase
for (size_t rnk = 0u; rnk < alphabet_size; ++rnk)
//!\copydoc seqan3::dna4::rank_complement_table
static constexpr rank_type rank_complement_table[alphabet_size]{
15, // N is complement of '='_dna16sam 0
8, // T is complement of 'A'_dna16sam 1
4, // G is complement of 'C'_dna16sam 2
12, // K is complement of 'M'_dna16sam 3
2, // C is complement of 'G'_dna16sam 4
10, // Y is complement of 'R'_dna16sam 5
6, // S is complement of 'S'_dna16sam 6
14, // B is complement of 'V'_dna16sam 7
1, // A is complement of 'T'_dna16sam 8
9, // W is complement of 'W'_dna16sam 9
5, // R is complement of 'Y'_dna16sam 10
13, // D is complement of 'H'_dna16sam 11
3, // M is complement of 'K'_dna16sam 12
11, // H is complement of 'D'_dna16sam 13
7, // V is complement of 'B'_dna16sam 14
15 // N is complement of 'N'_dna16sam 15
};

//!\copydoc seqan3::dna4::rank_complement
static constexpr rank_type rank_complement(rank_type const rank)
{
ret[rank_to_char_table[rnk]] = rnk;
ret[to_lower(rank_to_char_table[rnk])] = rnk;
return rank_complement_table[rank];
}

// set U equal to T
ret['U'] = ret['T'];
ret['u'] = ret['t'];

return ret;
}()
}; // namespace seqan3

//!\copydoc seqan3::dna4::rank_complement_table
static constexpr rank_type rank_complement_table[alphabet_size]{
15, // N is complement of '='_dna16sam 0
8, // T is complement of 'A'_dna16sam 1
4, // G is complement of 'C'_dna16sam 2
12, // K is complement of 'M'_dna16sam 3
2, // C is complement of 'G'_dna16sam 4
10, // Y is complement of 'R'_dna16sam 5
6, // S is complement of 'S'_dna16sam 6
14, // B is complement of 'V'_dna16sam 7
1, // A is complement of 'T'_dna16sam 8
9, // W is complement of 'W'_dna16sam 9
5, // R is complement of 'Y'_dna16sam 10
13, // D is complement of 'H'_dna16sam 11
3, // M is complement of 'K'_dna16sam 12
11, // H is complement of 'D'_dna16sam 13
7, // V is complement of 'B'_dna16sam 14
15 // N is complement of 'N'_dna16sam 15
};

//!\copydoc seqan3::dna4::rank_complement
static constexpr rank_type rank_complement(rank_type const rank)
{
return rank_complement_table[rank];
}

/*!\copydoc seqan3::dna4::rank_to_char
/*!\copydoc seqan3::dna4::rank_to_char
*
* The representation is the same as in the SAM specifications (which is NOT in alphabetical order).
*/
static constexpr char_type rank_to_char(rank_type const rank)
{
return rank_to_char_table[rank];
}
static constexpr char_type rank_to_char(rank_type const rank)
{
return rank_to_char_table[rank];
}

//!\copydoc seqan3::dna4::char_to_rank
static constexpr rank_type char_to_rank(char_type const chr)
{
using index_t = std::make_unsigned_t<char_type>;
return char_to_rank_table[static_cast<index_t>(chr)];
}
}
;
//!\copydoc seqan3::dna4::char_to_rank
static constexpr rank_type char_to_rank(char_type const chr)
{
using index_t = std::make_unsigned_t<char_type>;
return char_to_rank_table[static_cast<index_t>(chr)];
}

// clang-format off
//!\copydoc seqan3::dna4::char_to_rank_table
static constexpr std::array<rank_type, 256> char_to_rank_table{
[]() constexpr {
std::array<rank_type, 256> ret{};

ret.fill(15u); // initialize with UNKNOWN ('N')

// reverse mapping for characters and their lowercase
for (size_t rnk = 0u; rnk < alphabet_size; ++rnk)
{
ret[rank_to_char_table[rnk]] = rnk;
ret[to_lower(rank_to_char_table[rnk])] = rnk;
}

// set U equal to T
ret['U'] = ret['T'];
ret['u'] = ret['t'];

return ret;
}()
};
};
// clang-format on

// ------------------------------------------------------------------
// containers
Expand Down
Loading

1 comment on commit afde6f4

@vercel
Copy link

@vercel vercel bot commented on afde6f4 Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

seqan3 – ./

seqan3.vercel.app
seqan3-git-master-seqan.vercel.app
seqan3-seqan.vercel.app

Please sign in to comment.