Get the App
SLTechnology News&Howtos  ›  Development  › 

How to translate cds sequence into protein sequence by biopython

Shulou Source: shulou.com Published: 2022-06-01 10:57:20 10月02日 Update

This article mainly explains "how to use biopython to translate cds sequence into protein sequence". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "how to use biopython to translate cds sequences into protein sequences".

The cds sequence is translated into a protein sequence. Due to the differences in codons of different species or special organelles (mitochondria, etc.), we cannot translate casually by default. The biopython here can use different codons for protein translation according to our needs. Codons are as follows:

1. Ordinary codon translation, rna translation into protein

> from Bio.Seq import Seq > from Bio.Alphabet import IUPAC > messenger_rna = Seq ("AUGGCCAUUGUAAUGGGCCGCUGAAAGGGUGCCCGAUAG", IUPAC.unambiguous_rna) > messenger_rnaSeq ('AUGGCCAUUGUAAUGGGCCGCUGAAAGGGUGCCCGAUAG', IUPACUnambiguousRNA ()) > messenger_rna.translate () Seq (' MAIVMGR*KGAR*', HasStopCodon (IUPACProtein (),'*'))

2. Translation of cds sequence into protein sequence

> from Bio.Seq import Seq > from Bio.Alphabet import IUPAC > coding_dna = Seq ("ATGGCCATTGTAATGGGCCGCTGAAAGGGTGCCCGATAG", IUPAC.unambiguous_dna) > coding_dnaSeq ('ATGGCCATTGTAATGGGCCGCTGAAAGGGTGCCCGATAG', IUPACUnambiguousDNA ()) > coding_dna.translate () Seq (' MAIVMGR*KGAR*', HasStopCodon (IUPACProtein (),'*'))

3. Specify codon translation into protein sequence

> > coding_dna.translate (table= "Vertebrate Mitochondrial") Seq ('MAIVMGRWKGAR*', HasStopCodon (IUPACProtein (),' *'))

Or use serial numbers.

> coding_dna.translate (table=2) Seq ('MAIVMGRWKGAR*', HasStopCodon (IUPACProtein (),' *'))

Run the sample code in batches:

From Bio.Seq import Seqfrom Bio import SeqIOfrom Bio.Alphabet import IUPACfrom Bio.SeqRecord import SeqRecordimport sys, os, argparse, os.path,re,math,timeparser = argparse.ArgumentParser (description='This script is used to translate cds to pep') # parser.add_argument Help='Please input complete out_put directory path',default = os.getcwd (), required=False) parser.add_argument Pep') # args = parser.parse_args () dout=''if os.path.exists (args.out_dir): dout=os.path.abspath (args.out) _ dir) else: os.mkdir (args.out_dir) dout=os.path.abspath (args.out_dir) output_handle = open (dout+'/'+args.name+'.fa' "w") for rec in SeqIO.parse (args.fasta, "fasta"): rec.seq=rec.seq.translate (table=args.table) SeqIO.write (rec, output_handle, "fasta") output_handle.close () here I believe you have a deeper understanding of "how to use biopython to translate cds sequences into protein sequences". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Sequence protein codon codon difference content learning practical common deeper special code interest practicality reality difference serial number simple operation method more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB NVidia Docker Xiaomi