<reponame>Hawkaoaoa/RCPre
# single nucleic ggap
def g_gap_single(seq,ggaparray,g):
    # seq length is fix =23
   
    rst = np.zeros((16))
    for i in range(len(seq)-1-g):
        str1 = seq[i]
        str2 = seq[i+1+g]
        idx = ggaparray.index(str1+str2)
        rst[idx] += 1
        
    for j in range(len(ggaparray)):
        rst[j] = rst[j]/(len(seq)-1-g) #l-1-g
        
    return rst

def ggap_encode(seq,ggaparray,g):
    result = []
    for x in seq:
        temp = g_gap_single(x,ggaparray,g)
        result.append(temp)
    result = np.array(result)
    return result

# binucleic ggap
# kmerarray[64:340]
def big_gap_single(seq,ggaparray,g):
    # seq length is fix =23
   
    rst = np.zeros((256))
    for i in range(len(seq)-1-g):
        str1 = seq[i]+seq[i+1]
        str2 = seq[i+g]+seq[i+1+g]
        idx = ggaparray.index(str1+str2)
        rst[idx] += 1
        
    for j in range(len(ggaparray)):
        rst[j] = rst[j]/(len(seq)-1-g) #l-1-g
        
    return rst

def biggap_encode(seq,ggaparray,g):
    result = []
    for x in seq:
        temp = big_gap_single(x,ggaparray,g)
        result.append(temp)
    result = np.array(result)
    return result

# single nucleic ggap
def g_gap_single(seq,ggaparray,g):
    # seq length is fix =23
   
    rst = np.zeros((16))
    for i in range(len(seq)-1-g):
        str1 = seq[i]
        str2 = seq[i+1+g]
        idx = ggaparray.index(str1+str2)
        rst[idx] += 1
        
    for j in range(len(ggaparray)):
        rst[j] = rst[j]/(len(seq)-1-g) #l-1-g
        
    return rst

def ggap_encode(seq,ggaparray,g):
    result = []
    for x in seq:
        temp = g_gap_single(x,ggaparray,g)
        result.append(temp)
    result = np.array(result)
    return result

# binucleic ggap
# kmerarray[64:340]
def big_gap_single(seq,ggaparray,g):
    # seq length is fix =23
   
    rst = np.zeros((256))
    for i in range(len(seq)-1-g):
        str1 = seq[i]+seq[i+1]
        str2 = seq[i+g]+seq[i+1+g]
        idx = ggaparray.index(str1+str2)
        rst[idx] += 1
        
    for j in range(len(ggaparray)):
        rst[j] = rst[j]/(len(seq)-1-g) #l-1-g
        
    return rst

def biggap_encode(seq,ggaparray,g):
    result = []
    for x in seq:
        temp = big_gap_single(x,ggaparray,g)
        result.append(temp)
    result = np.array(result)
    return result
# single nucleic ggap # seq length is fix =23 #l-1-g # binucleic ggap # kmerarray[64:340] # seq length is fix =23 #l-1-g