Skip to content

Commit

Permalink
Merge pull request #11 from aertslab/fix_one_hot_encoded
Browse files Browse the repository at this point in the history
Fix size of hot_encoding_table and one_hot_decoding_table.
  • Loading branch information
LukasMahieu authored Aug 6, 2024
2 parents 3d7bc43 + 3c194ed commit 6955e72
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/crested/tl/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def str_to_uint8(string) -> np.ndarray:
"""Convert string to byte representation."""
return np.frombuffer(string.encode("ascii"), dtype=np.uint8)

# 255 x 4
hot_encoding_table = np.zeros((np.iinfo(np.uint8).max, len(alphabet)), dtype=dtype)
# 256 x 4
hot_encoding_table = np.zeros((np.iinfo(np.uint8).max + 1, len(alphabet)), dtype=dtype)

# For each ASCII value of the nucleotides used in the alphabet
# (upper and lower case), set 1 in the correct column.
Expand Down Expand Up @@ -116,7 +116,7 @@ def _weighted_difference(

def build_one_hot_decoding_table() -> np.ndarray:
"""Get hot decoding table to decode a one hot encoded sequence to a DNA sequence string."""
one_hot_decoding_table = np.full(np.iinfo(np.uint8).max, ord("N"), dtype=np.uint8)
one_hot_decoding_table = np.full(np.iinfo(np.uint8).max + 1, ord("N"), dtype=np.uint8)
one_hot_decoding_table[1] = ord("A")
one_hot_decoding_table[2] = ord("C")
one_hot_decoding_table[4] = ord("G")
Expand Down

0 comments on commit 6955e72

Please sign in to comment.