crested.utils.one_hot_encode_sequence

crested.utils.one_hot_encode_sequence#

crested.utils.one_hot_encode_sequence(sequence, expand_dim=True)#

One hot encode a DNA sequence.

Will return a numpy array with shape (len(sequence), 4) if expand_dim is True, otherwise (4,). Alphabet is ACGT.

Parameters:
  • sequence (str) – The DNA sequence to one hot encode.

  • expand_dim (bool (default: True)) – Whether to expand the dimensions of the output array.

Return type:

ndarray

Returns:

The one hot encoded DNA sequence.