Normally, we do not allow implicit conversion of single argument constructors, but in this case we make an exception, because seqan3::dna4 and seqan3::rna4 are interchangeable as they behave nearly the same (e.g. same ranks, same char to rank conversion).
int main()
{
letter2 = 'C'_rna4;
}
The four letter DNA alphabet of A,C,G,T..
Definition: dna4.hpp:53
Provides seqan3::dna4, container aliases and string literals.
The SeqAn namespace for literals.
Provides seqan3::rna4, container aliases and string literals.
seqan3::sequence
s (e.g. seqan3::dna4_vector) in general are not implicitly convertible and must be explicitly copied to be converted:
int main()
{
seqan3::dna4_vector vector{'A'_rna4, 'C'_rna4, 'G'_rna4};
}
std::vector< dna4 > dna4_vector
Alias for a std::vector of seqan3::dna4.
Definition: dna4.hpp:208
std::vector< rna4 > rna4_vector
Alias for a std::vector of seqan3::rna4.
Definition: rna4.hpp:119
You can avoid this copy by using std::ranges::view
s:
int main()
{
seqan3::dna4_vector vector = "ACG"_dna4;
auto rna4_view = vector | seqan3::views::convert<seqan3::rna4>;
for (auto && chr: rna4_view)
{
static_assert(std::same_as<
decltype(chr),
seqan3::rna4 &&>);
}
}
The four letter RNA alphabet of A,C,G,U..
Definition: rna4.hpp:49
Provides seqan3::views::convert.
This conversion constructor only allows converting seqan3::rna4 to seqan3::dna4. Other alphabets that inherit from seqan3::rna4 will not be implicitly convertible to seqan3::dna4.