Skip to content

Commit

Permalink
Expand on documentation for compatbits (#63)
Browse files Browse the repository at this point in the history
Make it more clear exactly what this function promises.
  • Loading branch information
jakobnissen authored Jan 15, 2024
1 parent 2f4b82c commit a35961c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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

0 comments on commit a35961c

Please sign in to comment.