Question: Convert GTF file into GFF3 file
0
gravatar for Rox
4.6 years ago by
Rox1.3k
France / Toulouse / GeT-Plage
Rox1.3k wrote:

Hello everyone !

I'm looking for an easy way to transform any gtf file to a gff3 file.

I've tried different script proposed by maker ( genemark_gtf2gff3 and cufflinks2gff3 ) but none of them is working with my file, which doesn't come from genemark nor cufflinks.

Any suggestions ?

Thanks !

Roxane

script • 3.9k views
ADD COMMENTlink modified 4.6 years ago by Sej Modha4.8k • written 4.6 years ago by Rox1.3k
2
gravatar for Sej Modha
4.6 years ago by
Sej Modha4.8k
Glasgow, UK
Sej Modha4.8k wrote:

Did you try? http://blog.nextgenetics.net/?e=27

ADD COMMENTlink written 4.6 years ago by Sej Modha4.8k

Thanks I'm going to try it ! It could be a stupid question, but I can't recognize the language used here :

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')

#parse the transcript/gene ID. I suck at using regex, so I usually just do a series of splits.
transcriptID = data[-1].split('transcript_id')[-1].split(';')[0].strip()[1:-1]
geneID = data[-1].split('gene_id')[-1].split(';')[0].strip()[1:-1]

#replace the last column with a GFF formatted attributes columns
#I added a GID attribute just to conserve all the GTF data
data[-1] = "ID=" + transcriptID + ";GID=" + geneID

#print out this new GFF line
print '\t'.join(data)
ADD REPLYlink modified 4.6 years ago • written 4.6 years ago by Rox1.3k

Stupid question, it is written just above, python, sorry !

ADD REPLYlink written 4.6 years ago by Rox1.3k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1064 users visited in the last hour
_