Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize CDS sequence by python

Shulou Source: shulou.com Published: 2022-06-01 04:39:11 09月23日 Update

This article mainly explains "how to realize CDS sequence by python". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to realize CDS sequence by python".

Screening of CDS sequences encoding proteins

#! python# coding:utf-8'''# Beijing Group Science and Technology Co., Ltd. # author Huangls#date 2021.01.26#version 1.learn python course recommendation: # python introduction to mastery (bioinformatics): # https://study.163.com/course/introduction/1209531837.htm?share=1&shareId=1030291076############################################################## # #''from Bio.Seq import Seqfrom Bio import SeqIO#from Bio.Alphabet import IUPACfrom Bio.SeqRecord import SeqRecordimport os Argparse, os.path,reparser = argparse.ArgumentParser (description='This script is used to get coding sequence from fasta file.') parser.add_argument. [REQUIRED]', required=True) parser.add_argument ('- default default 300) [OPTIONAL]', required=False) parser.add_argument ('- pendant demo_seq',required=False,help='Please specify the output file prefix, default demo_seq. [OPTIONAL]') parser.add_argument ('- oval input output directory path default cwd.) [OPTIONAL]', default = os.getcwd () Required=False) # 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) count=0total=0output_handle = open (dout+'/'+args.prefix+'.fa') "w") for rec in SeqIO.parse (args.fasta, "fasta"): seq=str (rec.seq) # seq=seq.upper () total+=1 if (len (seq) > = args.len and re.search ("^ ATG", seq,re.I) and len (seq)% 3room0): if re.search ('TAG$',seq,re.I) or re.search (' TGA$',seq,re.I) or re.search ('TAA$',seq) Re.I): seq = seq [:-3] f=re.finditer ('TAG | TGA | TAA',seq,re.I) if not f: SeqIO.write (rec, output_handle) "fasta") count+=1 else: isstop=False for i in f: index=i.start () if index%3 = 0: isstop=True break if not isstop: SeqIO.write (rec, output_handle) "fasta") count+=1print ("Total input seqs:% s"% total) print ("Coding seqs:% s"% count) print ("Output file:% s"% dout+'/'+args.prefix+'.fa') output_handle.close () so far I believe that you have a deeper understanding of "how to achieve CDS sequence in python", so 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 learning content biology practical deeper information company interest practicality practical easy to operate method more limited friends biotechnology science and technology coding Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Redmi Shulou Information Linux Shulou Tech Info