Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize CDS sequence by python

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report