Utility functions for sequences#

One-hot encoding#

[1]:
import numpy as np
from chame.util.seq import *
[2]:
sequence_to_onehot("attaaaggtt".upper())
[2]:
array([[1, 0, 0, 0],
       [0, 0, 0, 1],
       [0, 0, 0, 1],
       [1, 0, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 0],
       [0, 0, 1, 0],
       [0, 0, 1, 0],
       [0, 0, 0, 1],
       [0, 0, 0, 1]], dtype=int32)