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)