• DNA 序列翻译


    dna = "ATGCACGTGCGCTCACTGCGAGCTGCGGCGCCGCACAGCTTCGTGGCGCTCTGGGCACCCCTGTTCCTGCTGCGCTCCGCCCTGGCCGACTTCAGCCTGGACAACGAGGTGCACTCGAGCTTCATCCACCGGCGCCTCCGCAGCCAGGAGCGGCGGGAGATGCAGCGCGAGATCCTCTCCATTTTGGGCTTGCCCCACCGCCCGCGCCCGCACCTCCAGGGCAAGCACAACTCGGCACCCATGTTCATGCTGGACCTGTACAACGCCATGGCGGTGGAGGAGGGCGGCGGGCCCGGCGGCCAGGGCTTCTCCTACCCCTACAAGGCCGTCTTCAGTACCCAGGGCCCCCCTCTGGCCAGCCTGCAAGATAGCCATTTCCTCACCGACGCCGACATGGTCATGAGCTTCGTCAACCTCGTGGAACATGACAAGGAATTCTTCCACCCACGCTACCACCATCGAGAGTTCCGGTTTGATCTTTCCAAGATCCCAGAAGGGGAAGCTGTCACGGCAGCCGAATTCCGGATCTACAAGGACTACATCCGGGAACGCTTCGACAATGAGACGTTCCGGATCAGCGTTTATCAGGTGCTCCAGGAGCACTTGGGCAGGGAATCGGATCTCTTCCTGCTCGACAGCCGTACCCTCTGGGCCTCGGAGGAGGGCTGGCTGGTGTTTGACATCACAGCCACCAGCAACCACTGGGTGGTCAATCCGCGGCACAACCTGGGCCTGCAGCTCTCGGTGGAGACGCTGGATGGGCAGAGCATCAACCCCAAGTTGGCGGGCCTGATTGGGCGGCACGGGCCCCAGAACAAGCAGCCCTTCATGGTGGCTTTCTTCAAGGCCACGGAGGTCCACTTCCGCAGCATCCGGTCCACGGGGAGCAAACAGCGCAGCCAGAACCGCTCCAAGACGCCCAAGAACCAGGAAGCCCTGCGGATGGCCAACGTGGCAGAGAACAGCAGCAGCGACCAGAGGCAGGCCTGTAAGAAGCACGAGCTGTATGTCAGCTTCCGAGACCTGGGCTGGCAGGACTGGATCATCGCGCCTGAAGGCTACGCCGCCTACTACTGTGAGGGGGAGTGTGCCTTCCCTCTGAACTCCTACATGAACGCCACCAACCACGCCATCGTGCAGACGCTGGTCCACTTCATCAACCCGGAAACGGTGCCCAAGCCCTGCTGTGCGCCCACGCAGCTCAATGCCATCTCCGTCCTCTACTTCGATGACAGCTCCAACGTCATCCTGAAGAAATACAGAAACATGGTGGTCCGGGCCTGTGGCTGCCACTAG"
     
     def trabslate_dna(sequence):
         start_codon = 'ATG'
         stop_codon = ('TAA', 'TAG', 'TGA' )
         codontable = {
             'ATA': 'I', 'ATC': 'I', 'ATT': 'I', 'ATG': 'M',
             'ACA': 'T', 'ACC': 'T', 'ACG': 'T', 'ACT': 'T',
             'AAC': 'N', 'AAT': 'N', 'AAA': 'K', 'AAG': 'K',
             'AGC': 'S', 'AGT': 'S', 'AGA': 'R', 'AGG': 'R',
             'CTA': 'L', 'CTC': 'L', 'CTG': 'L', 'CTT': 'L',
             'CCA': 'P', 'CCC': 'P', 'CCG': 'P', 'CCT': 'P',
             'CAC': 'H', 'CAT': 'H', 'CAA': 'Q', 'CAG': 'Q',
             'CGA': 'R', 'CGC': 'R', 'CGG': 'R', 'CGT': 'R',
             'GTA': 'V', 'GTC': 'V', 'GTG': 'V', 'GTT': 'V',
             'GCA': 'A', 'GCC': 'A', 'GCG': 'A', 'GCT': 'A',
             'GAC': 'D', 'GAT': 'D', 'GAA': 'E', 'GAG': 'E',
             'GGA': 'G', 'GGC': 'G', 'GGG': 'G', 'GGT': 'G',
             'TCA': 'S', 'TCC': 'S', 'TCG': 'S', 'TCT': 'S',
             'TTC': 'F', 'TTT': 'F', 'TTA': 'L', 'TTG': 'L',
             'TAC': 'Y', 'TAT': 'Y', 'TAA': '_', 'TAG': '_',
             'TGC': 'C', 'TGT': 'C', 'TGA': '_', 'TGG': 'W'
         }
         start = sequence.find(start_codon)
         codons = [] # Create a codon list to store codons generated from coding seq.
         for i in range(start, len(sequence), 3):
             if sequence[i:i+3] in stop_codons:
                 break
             if sequence[i:i+3] in codontable.keys():
                 codons.append(sequence[i:i+3])
         protein_sequence = ''.join([codontable[codon] for codon in codons]) #Translate condons to protein seq.
         return "{0}_".format(protein_sequence)
     
     protein_seq = translate_DNA(dna)
     print(protein_seq)
    

      

    hhh

    import os
    import re
    
    
    F_path= os.getcwd()
    print(F_path)
    
    
    def trabslate_dna(sequence):
        codontable = {
         'ATA': 'I', 'ATC': 'I', 'ATT': 'I', 'ATG': 'M',
         'ACA': 'T', 'ACC': 'T', 'ACG': 'T', 'ACT': 'T',
         'AAC': 'N', 'AAT': 'N', 'AAA': 'K', 'AAG': 'K',
         'AGC': 'S', 'AGT': 'S', 'AGA': 'R', 'AGG': 'R',
         'CTA': 'L', 'CTC': 'L', 'CTG': 'L', 'CTT': 'L',
         'CCA': 'P', 'CCC': 'P', 'CCG': 'P', 'CCT': 'P',
         'CAC': 'H', 'CAT': 'H', 'CAA': 'Q', 'CAG': 'Q',
         'CGA': 'R', 'CGC': 'R', 'CGG': 'R', 'CGT': 'R',
         'GTA': 'V', 'GTC': 'V', 'GTG': 'V', 'GTT': 'V',
         'GCA': 'A', 'GCC': 'A', 'GCG': 'A', 'GCT': 'A',
         'GAC': 'D', 'GAT': 'D', 'GAA': 'E', 'GAG': 'E',
         'GGA': 'G', 'GGC': 'G', 'GGG': 'G', 'GGT': 'G',
         'TCA': 'S', 'TCC': 'S', 'TCG': 'S', 'TCT': 'S',
         'TTC': 'F', 'TTT': 'F', 'TTA': 'L', 'TTG': 'L',
         'TAC': 'Y', 'TAT': 'Y', 'TAA': '*', 'TAG': '*',
         'TGC': 'C', 'TGT': 'C', 'TGA': '*', 'TGG': 'W' }
     #start = sequence.find(start_codon)
        codons = [] # Create a codon list to store codons generated from coding seq.
        for i in range(0, len(sequence), 3):
            codons.append(sequence[i:i+3])
        protein_sequence = ''.join([codontable[codon] for codon in codons]) #Translate condons to protein seq.
        return "{0}".format(protein_sequence)
    
    
    
    dna = "ATGCACGTGCGCTCACTGCGAGCTGCGGCGCCGCACAGCTTCGTGGCGCTCTGGGCACCCCTGTTCCTGCTGCGCTCCGCCCTGGCCGACTTCAGCCTGGACAACGAGGTGCACTCGAGCTTCATCCACCGGCGCCTCCGCAGCCAGGAGCGGCGGGAGATGCAGCGCGAGATCCTCTCCATTTTGGGCTTGCCCCACCGCCCGCGCCCGCACCTCCAGGGCAAGCACAACTCGGCACCCATGTTCATGCTGGACCTGTACAACGCCATGGCGGTGGAGGAGGGCGGCGGGCCCGGCGGCCAGGGCTTCTCCTACCCCTACAAGGCCGTCTTCAGTACCCAGGGCCCCCCTCTGGCCAGCCTGCAAGATAGCCATTTCCTCACCGACGCCGACATGGTCATGAGCTTCGTCAACCTCGTGGAACATGACAAGGAATTCTTCCACCCACGCTACCACCATCGAGAGTTCCGGTTTGATCTTTCCAAGATCCCAGAAGGGGAAGCTGTCACGGCAGCCGAATTCCGGATCTACAAGGACTACATCCGGGAACGCTTCGACAATGAGACGTTCCGGATCAGCGTTTATCAGGTGCTCCAGGAGCACTTGGGCAGGGAATCGGATCTCTTCCTGCTCGACAGCCGTACCCTCTGGGCCTCGGAGGAGGGCTGGCTGGTGTTTGACATCACAGCCACCAGCAACCACTGGGTGGTCAATCCGCGGCACAACCTGGGCCTGCAGCTCTCGGTGGAGACGCTGGATGGGCAGAGCATCAACCCCAAGTTGGCGGGCCTGATTGGGCGGCACGGGCCCCAGAACAAGCAGCCCTTCATGGTGGCTTTCTTCAAGGCCACGGAGGTCCACTTCCGCAGCATCCGGTCCACGGGGAGCAAACAGCGCAGCCAGAACCGCTCCAAGACGCCCAAGAACCAGGAAGCCCTGCGGATGGCCAACGTGGCAGAGAACAGCAGCAGCGACCAGAGGCAGGCCTGTAAGAAGCACGAGCTGTATGTCAGCTTCCGAGACCTGGGCTGGCAGGACTGGATCATCGCGCCTGAAGGCTACGCCGCCTACTACTGTGAGGGGGAGTGTGCCTTCCCTCTGAACTCCTACATGAACGCCACCAACCACGCCATCGTGCAGACGCTGGTCCACTTCATCAACCCGGAAACGGTGCCCAAGCCCTGCTGTGCGCCCACGCAGCTCAATGCCATCTCCGTCCTCTACTTCGATGACAGCTCCAACGTCATCCTGAAGAAATACAGAAACATGGTGGTCCGGGCCTGTGGCTGCCACTAG"
    
    print(trabslate_dna(dna))
    
    AA_FL=trabslate_dna(dna)
    aa_feature='AAAPHSFVALWAPLFLLRSALAD'
    
    
    
    
    match = re.search(aa_feature, AA_FL)
    if match:
        matchstart = match.start()
    
        matchend = match.end()
    
        matchlength = matchend - matchstart
    
        matchtext = AA_FL[matchstart:matchend]
    
        print (matchstart,matchend,matchtext)
    else:
        print ('match fail!')
    
    
    kk='''     CDS        87..166
                         /locus_tag="5555666ppp"
                         /label="5555666ppp"
                         /ApEinfo_label="5555666ppp"
                         /ApEinfo_fwdcolor="#346ee0"
                         /ApEinfo_revcolor="#ff80c0"
                         /ApEinfo_graphicformat="arrow_data {{0 0.5 0 1 2 0 0 -1 0
                         -0.5} {} 0} width 5 offset 0"'''
    
    print(kk)
    

      

  • 相关阅读:
    java程序员面试金典--i++
    JavaScript 装逼指南
    轻松学习 JavaScript——第 8 部分:JavaScript 中的类
    轻松学习 JavaScript——第 7 部分:对象属性描述符
    轻松学习 JavaScript——第 6 部分:JavaScript 箭头函数
    轻松学习 JavaScript——第 5 部分:简化函数提升
    轻松学习 JavaScript——第 4 部分:函数中的 arguments 对象
    轻松学习 JavaScript——第 3 部分:函数中的默认参数
    布隆过滤器
    决策树(ID3、C4.5、CART)
  • 原文地址:https://www.cnblogs.com/kehan/p/12322403.html
Copyright © 2020-2023  润新知