您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“python怎么實(shí)現(xiàn)CDS序列”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“python怎么實(shí)現(xiàn)CDS序列”吧!
篩選編碼蛋白的CDS序列
#!python # coding:utf-8 ''' ############################################################################################# #北京組學(xué)生物科技有限公司 #author huangls #date 2021.01.26 #version 1.2 #學(xué)習(xí)python課程推薦: #python 入門到精通(生物信息): #https://study.163.com/course/introduction/1209531837.htm?share=1&shareId=1030291076 ############################################################################################### ''' from Bio.Seq import Seq from Bio import SeqIO #from Bio.Alphabet import IUPAC from Bio.SeqRecord import SeqRecord import os, argparse, os.path,re parser = argparse.ArgumentParser(description='This script is used to get coding sequence from fasta file.') parser.add_argument('-f','--fasta',help='Please input fasta file. [REQUIRED]',required=True) parser.add_argument('-l','--len',type=int,default=300,help='seq length filter, default 300. [OPTIONAL]',required=False) parser.add_argument('-p','--prefix',default ='demo_seq',required=False,help='Please specify the output file prefix, default demo_seq. [OPTIONAL]') parser.add_argument('-o','--out_dir',help='Please 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=0 total=0 output_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)%3==0): 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+=1 print("Total input seqs: %s"%total) print("Coding seqs: %s"%count) print("Output file: %s"%dout+'/'+args.prefix+'.fa') output_handle.close()
到此,相信大家對(duì)“python怎么實(shí)現(xiàn)CDS序列”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。