当前位置: 首页 > article >正文

《python语言程序设计》第8章第12题生物信息:找出基因,生物学家使用字母A C T和G构成字符2串建模一个基因组(下)

一、上一个版本

      • 抱歉各位兄弟我感觉这道题我现在的能力有限,不纠结了跳过去.等第3刷的时候解决吧.
    • 可能彼岸就在眼前,但是我累了.等下次吧

这个版本中div_text函数已经可以很好的划分字符串了
但是我发现了一个问题.它间隔字符效果如下


genome_text = 'TTATGTTTTAAGGATGGGGCGTTAGTT'
len_num_out = len(genome_text)


def div_text(start_num, end_num, text_word):
    text_i_save = ""
    for i_t in range(start_num, end_num):
        text_i_save += text_word[i_t]
    return text_i_save

请添加图片描述
之前的间隔的取数.在这里得到了修正.其实就是将for循环的步幅改回到1

len_num = len(genome_text)
for i in range(0, len_num):
    if i + 2 < len_num:
        print(div_text(i, i + 3, genome_text))
        print('i is', i, 'i+3 is', i + 3)

请添加图片描述


genome_text = 'TTATGTTTTAAGGATGGGGCGTTAGTT'
len_num_out = len(genome_text)


def div_text(start_num, end_num, text_word):
    text_i_save = ""
    for i_t in range(start_num, end_num):
        text_i_save += text_word[i_t]
    return text_i_save


def cut_word_start(judge_word, text_word):
    len_num = len(text_word)
    for i in range(0, len_num):
        if i + 2 < len_num:
            if div_text(i, i + 3, text_word) == judge_word:
                return text_word[i + 3:]


def cut_word_end(judge_word, text_word):
    len_num = len(text_word)
    for i in range(0, len_num):
        if i + 2 < len_num:
            if div_text(i, i + 3, text_word) == judge_word:
                print(text_word[:i])
                # print(i)


def main():
    a = cut_word_start("ATG", genome_text)
    cut_word_end("TAA",a)


main()

请添加图片描述

二、如何将TAG、TAA、TGA都做成条件

      • 抱歉各位兄弟我感觉这道题我现在的能力有限,不纠结了跳过去.等第3刷的时候解决吧.
    • 可能彼岸就在眼前,但是我累了.等下次吧

第一条里我已经成功提取了TTT这个序列但是

‘TTATGTTTTAAGGATGGGGCGTTAGTT’
还存在GGGCGT

另外 当我取的了TTT后,如何让计算机继续往后去寻找
规则也写的很明白
ATG之后TAG或TAA或TGA之前,这样一个区间

抱歉各位兄弟我感觉这道题我现在的能力有限,不纠结了跳过去.等第3刷的时候解决吧.


genome_text = 'TTATGTTTTAAGGATGGGGCGTTAGTT'
len_num_out = len(genome_text)


def div_text(start_num, end_num, text_word):
    text_i_save = ""
    for i_t in range(start_num, end_num):
        text_i_save += text_word[i_t]
    return text_i_save


def cut_word_start(judge_word, text_word):
    len_num = len(text_word)
    for i in range(0, len_num):
        if i + 2 < len_num:
            if div_text(i, i + 3, text_word) == judge_word:
                return text_word[i + 3:]


def cut_word_end(judge_word1, judge_word2, judge_word3, text_word):
    len_num = len(text_word)
    for i in range(0, len_num):
        if i + 2 < len_num:
            run_code = div_text(i, i + 3, text_word)
            if run_code == judge_word1 or run_code == judge_word2 or run_code == judge_word3:
                print(text_word[:i])


# 这个从他们之前取值的想法有点烧脑了.先放弃了
def between_code(judge_start, judge_end1, judge_end2, judge_end3, text_int):
    a = cut_word_start(judge_start, text_int)
    cut_word_end(judge_end1, judge_end2, judge_end3, a)
    


def main():
    a = cut_word_start("ATG", genome_text)
    cut_word_end("TAG", "TAA", "TGA", a)

main()



请添加图片描述

可能彼岸就在眼前,但是我累了.等下次吧


http://www.kler.cn/news/289436.html

相关文章:

  • 【Linux系统编程】TCP实现--socket
  • 力扣2542.最大子序列的分数
  • 设计模式-离氏替换原则
  • Edge PDF 关闭 提供支持的应用Adobe Acrobat
  • 深度学习-OpenCv的运用(4)
  • 【安全生产】叉车安全带报警器有哪些特点?
  • 数分基础(06)商业分析四种类型简介
  • VsCode + Go + macOS 小白 demo运行
  • 数学建模强化宝典(9)遗传算法
  • 财富趋势金融大模型已通过备案
  • 贪心算法---合并区间
  • Flutter之CRC校验
  • python使用selenium,实现简单爬虫功能
  • 《从C/C++到Java入门指南》- 22.对象的转型
  • 机器学习面试题(9月3日笔记)
  • 跨境多账号登录如何防止IP、cookie和设备关联?
  • pil 常见用法
  • 如何打造在线音乐网站?java springboot架构,vue前端开发,音乐分享新体验
  • sealos快速搭建k8s集群
  • 记录 PyQt6 / PySide 6 自定义边框窗口的 Bug 及可能可行的解决方案:窗口抖动和添加 DWM 环绕阴影的大致原理
  • Java的IO模型详解-BIO,NIO,AIO
  • 常见接口限流算法
  • 4. 第一个3D案例—创建3D场景
  • idea中git提交或push到远程后回退到之前的某次提交简单有效的解决方案
  • go语言的闭包
  • gitea + drone实现CI/CD
  • 浅谈新能源汽车充电桩安装以及防范
  • Java中的类加载过程
  • 关于武汉高芯coin417G2红外机芯的二次开发
  • AFFiNE简介