from sklearn.preprocessing import OneHotEncoder
token = {'A':0, 'G':1, 'C':2, 'T':3}
def fn_token(x):
for key in token:
x = x.replace(key, str(token[key]))
return x
def encode(seq):
enc = OneHotEncoder(categories='auto')
seq = fn_token(seq)
seq = [int(ele) for ele in seq]
seq = np.array(seq).reshape(len(seq),-1)
enc.fit(seq)
targets = enc.transform(seq).toarray()
targets = targets.T
return targets