def onehot_encode_seq(sequence, m=0, padding=False):
    'Converts a given IUPAC DNA sequence to a one-hot \n    encoded DNA sequence. \n    '
    import numpy as np
    import torch
    valid_keys = ['a', 'c', 'g', 't', 'u', 'n', 'r', 'y', 's', 'w', 'k', 'm']
    nucs = {'a': 0, 'c': 1, 'g': 2, 't': 3, 'u': 3}
    if padding:
        assert (m != 0), 'If using padding, m should be bigger than 0'
        padding_mat = np.tile(0.25, ((m - 1), 4))
    onehot = np.tile(0.0, (len(sequence), 4))
    for (i, char) in enumerate(sequence.lower()):
        if (char not in valid_keys):
            sys.exit('invalid char in sequence (choose from acgt and nryswkm)')
        elif (char == 'n'):
            onehot[i, :] = 0.25
        elif (char == 'r'):
            onehot[(i, (0, 2))] = 0.5
        elif (char == 'y'):
            onehot[(i, (1, 3))] = 0.5
        elif (char == 's'):
            onehot[(i, (1, 2))] = 0.5
        elif (char == 'w'):
            onehot[(i, (0, 3))] = 0.5
        elif (char == 'k'):
            onehot[(i, (2, 3))] = 0.5
        elif (char == 'm'):
            onehot[(i, (0, 1))] = 0.5
        else:
            onehot[(i, nucs[char])] = 1
    if padding:
        onehot = np.concatenate((padding_mat, onehot, padding_mat))
    return onehot
Converts a given IUPAC DNA sequence to a one-hot 
encoded DNA sequence.
def onehot_encode_seq(sequence, m=0, padding=False):
    'Converts a given IUPAC DNA sequence to a one-hot \n    encoded DNA sequence. \n    '
    import numpy as np
    import torch
    valid_keys = ['a', 'c', 'g', 't', 'u', 'n', 'r', 'y', 's', 'w', 'k', 'm']
    nucs = {'a': 0, 'c': 1, 'g': 2, 't': 3, 'u': 3}
    if padding:
        assert (m != 0), 'If using padding, m should be bigger than 0'
        padding_mat = np.tile(0.25, ((m - 1), 4))
    onehot = np.tile(0.0, (len(sequence), 4))
    for (i, char) in enumerate(sequence.lower()):
        if (char not in valid_keys):
            sys.exit('invalid char in sequence (choose from acgt and nryswkm)')
        elif (char == 'n'):
            onehot[i, :] = 0.25
        elif (char == 'r'):
            onehot[(i, (0, 2))] = 0.5
        elif (char == 'y'):
            onehot[(i, (1, 3))] = 0.5
        elif (char == 's'):
            onehot[(i, (1, 2))] = 0.5
        elif (char == 'w'):
            onehot[(i, (0, 3))] = 0.5
        elif (char == 'k'):
            onehot[(i, (2, 3))] = 0.5
        elif (char == 'm'):
            onehot[(i, (0, 1))] = 0.5
        else:
            onehot[(i, nucs[char])] = 1
    if padding:
        onehot = np.concatenate((padding_mat, onehot, padding_mat))
    return onehot