用正則表達將出現基因類型miRNA,rRNA,snRNA的每一行都寫入文件protin_coding.txt中
import re
Gene={}
pattern=re.compile(r'gene_type=((mi|r|sn)RNA);')
with open("gencode.v33lift37_gene.gff3","r") as File:
for line in File:
m=pattern.search(line)
if m!=None:
genetype=m.group(1)
(這之後就不知道怎麼寫了)
with open("protin_coding.txt","w") as out:
for i in sorted (Gene.items(),key=lambda x:x[1],reverse=True):
print('{0}\t{1}'.format(i[0],i[1]))
print('{0}\t{1}'.format(i[0],i[1]),file=out)