Thank You!
• 0 views
•
link
Hi, I have a gtf file. Could someone tell me how to change the order of attributes on the 9th column (gene_id comes first, then transcript_id, and lastly gene_name)?
Currently the format is below:
DDB0169550 dictyBase Curator exon 11729 12478 . + . transcript_id "DDB0201587"; gene_id "DDB_G0294088"; gene_name "A";
DDB0169550 dictyBase Curator exon 13479 13862 . + . transcript_id "DDB0201587"; gene_id "DDB_G0294088"; gene_name "B";
DDB0169550 dictyBase Curator CDS 6411 6676 . + 0 transcript_id "DDB0201587"; gene_id "DDB_G0294088"; gene_name "C";
Thanks for your help!
do not post the images of the data.
$ sed -r '/^#/! s/(transcript_id ".*"); (gene_id ".*"); (gene_name ".*");/\2; \1; \3/' test.gtf
DDB0169550 dictyBase Curator exon 11729 12478 . . gene_id "DDB_G0294088"; transcript_id "DDB0201587"; gene_name "A"
DDB0169550 dictyBase Curator exon 13479 13862 . . gene_id "DDB_G0294088"; transcript_id "DDB0201587"; gene_name "B"
DDB0169550 dictyBase Curator CDS 6411 6676 . 0 gene_id "DDB_G0294088"; transcript_id "DDB0201587"; gene_name "C"
Thank You!
Log in to answer this question.
May I ask why you want to change the order of the attributes? In theory it should not matter.
EDIT: Sorry I'm wrong, in GTF there are two mandatory attributes gene_id and transcript_id, any other attributes or comments must appear after these two. So yes order matter. (More details here: https://agat.readthedocs.io/en/latest/gxf.html)