Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand on documentation for compatbits #63

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/aminoacid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ gap(::Type{AminoAcid}) = AA_Gap
compatbits(aa::AminoAcid)

Return the compatibility bits of `aa` as `UInt32`.
The resulting `UInt32` has one bit set per amino acid
it is compatible with.

For example, `J` is compatible with `I` (bit 10) and `L` (bit 11),
and so is `0x00000600`.

Examples
--------
Expand All @@ -206,9 +211,17 @@ Examples
julia> compatbits(AA_A)
0x00000001

julia> compatbits(AA_E)
0x00000040

julia> compatbits(AA_J)
0x00000600

julia> compatbits(AA_X)
0x003fffff

julia> compatbits(AA_Gap)
0x00000000
```
"""
compatbits(aa::AminoAcid) = @inbounds compatbits_aa[encoded_data(aa) + 1]
10 changes: 10 additions & 0 deletions src/nucleicacid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ end
compatbits(nt::NucleicAcid)

Return the compatibility bits of `nt` as `UInt8`.
The resulting `UInt8` has the lower four bits set
if `nt` is compatible with `A`, `C`, `G` and `T/U`, respectively.

Hence, `RNA_Gap` is `0x00` (not compatible with any nucleotide),
and `DNA_W` is `0x09` (compatible with `A` and `T`)

Examples
--------
Expand All @@ -474,6 +479,11 @@ julia> compatbits(DNA_C)
julia> compatbits(DNA_N)
0x0f

julia> compatbits(DNA_W)
0x09

julia> compatbits(RNA_Gap)
0x00
```
"""
@inline function compatbits(nt::NucleicAcid)
Expand Down
Loading