"""
Function of this code: one method of feature extraciton from the numerical values.
Contact for help: gch_liu@163.com 
"""

import numpy as np
from kmer_finder import kmer_finder

def ktuple(data_1):
    k=3
    data_1_num=len(data_1)
    print('---------------------------------')
    print(data_1)
    testseq1=data_1[0]
    [kmer_ACGT_freq1,kmer_freq1]=kmer_finder(testseq1,k)
    N=len(kmer_ACGT_freq1)
    
    kmers_total_data_1=np.array([],dtype=(str,10))
    kmers_total_data_1 = np.resize(kmers_total_data_1, [N, data_1_num+1])

    kmers_total_data_1[:,0:2]=kmer_ACGT_freq1
    
    for i in range(1,data_1_num):
        print("ktuple total",data_1_num,"，now no：",i)
        testseq=data_1[i]
        [kmer_ACGT_freq,kmer_freq]=kmer_finder(testseq,k)
        kmers_total_data_1[:,i+1]=kmer_freq   #num2cell function
    kmers=kmers_total_data_1.T
    return kmers
