• 关于给定DNA序列,如何找到合理的切割位点使得其退火温度保持相对一致


    多说无益,直接上代码(其实就是懒的说)

    import random
    import numpy as np
    
    S = ['A','G','C','T']
    
    
    def createStr(n):
        str = []
        for i in range(30):
            str.append(S[random.randint(0,3)])
        return str
    
    def calScore(str):
        score =[]
        for i in range(len(str)):
            if str[i] in ('G','C'):
                score.append(4)
            else:
                score.append(2)
        return score
    
    def divide(score,eTm,low,high):
        div_point=[]
        div_score=[]
        i=j=0
        total_len = len(score)
        piece_s = 0
        while j < total_len:
            piece_s += score[j]
            if j-i+1  < low:   #长度不足下限
                continue
            else:
                if j-i+1 == high:  #长度达到上限
                    i = j+1
                    j = i
                    div_point.append(j)  #添加分割点
                    div_score.append(piece_s)
                    pieces_s = 0
                else:      #长度在范围内
                    if piece_s >= eTm:  #温度达到或超过期望值
                          i = j+1
                          j = i
                          div_point.append(j)  #添加分割点
                          div_score.append(piece_s)
                          piece_s = 0
            j += 1
        
        return div_point,div_score
                    
                    
    def std(div_score):
        a = np.array(div_score)
        mean = np.mean(a)
        return np.sum((a-mean)**2)/len(a)
               
                
    
    str = createStr(10)
    score = calScore(str)
    
  • 相关阅读:
    矩阵快速幂模板C++
    异或空间与高斯消元
    POJ2947解题报告
    Manacher算法笔记 C++
    Python(80)_使用selenium实现第一个web自动化程序
    Python(78)_认识selenium自动化测试
    111
    Python(60)_闭包
    Python(55)_默认参数的陷阱
    Python(53)_实现一个加法计数器
  • 原文地址:https://www.cnblogs.com/urahyou/p/14097281.html
Copyright © 2020-2023  润新知