Python 实现【DNA序列】

B站影视 港台电影 2025-04-02 13:36 1

摘要:def find_max_gc_ratio_substring(dna_sequence, n):max_ratio = -1result_substring = ""for i in range(len(dna_sequence) - n + 1):subs

def find_max_gc_ratio_substring(dna_sequence, n):max_ratio = -1result_substring = ""for i in range(len(dna_sequence) - n + 1):substring = dna_sequence[i:i+n]gc_count = substring.count('G') + substring.count('C')current_ratio = gc_count / nif current_ratio > max_ratio:max_ratio = current_ratioresult_substring = substringreturn result_substring# 示例输入dna_sequence = input.stripn = int(input)# 输出结果print(find_max_gc_ratio_substring(dna_sequence, n))

来源:牛腩与科学

相关推荐