首页 > 其他 > 详细

GFF2GTF.py2

时间:2021-04-23 00:10:52      阅读:33      评论:0      收藏:0      [点我收藏+]
import sys

inFile = open(sys.argv[1],‘r‘)

for line in inFile:
  #skip comment lines that start with the ‘#‘ character
  if line[0] != ‘#‘:
    #split line into columns by tab
    data = line.strip().split(‘\t‘)

    ID = ‘‘

    #if the feature is a gene 
    if data[2] == "gene":
      #get the id
      ID = data[-1].split(‘ID=‘)[-1].split(‘;‘)[0]

    #if the feature is anything else
    else:
      # get the parent as the ID
      ID = data[-1].split(‘Parent=‘)[-1].split(‘;‘)[0]
    
    #modify the last column
    data[-1] = ‘gene_id "‘ + ID + ‘"; transcript_id "‘ + ID

    #print out this new GTF line
    print ‘\t‘.join(data)

https://www.jianshu.com/p/c284a6b4e1c6

GFF2GTF.py2

原文:https://www.cnblogs.com/3Dgenome/p/14690619.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!