This is a test version of Biostars. For the public version, visit https://www.biostars.org.
replace gene names in gff file

I have gff file generated by braker. It gives the default gene name like the following:

# start gene g1
CC151   AUGUSTUS    gene    5487 15014 0.36 -   .   g1
CC151   AUGUSTUS    transcript  5487 15014 0.36 -   .   g1.t1
CC151   AUGUSTUS    terminal    5487 5697 1 -   1   transcript_id "g1.t1"; gene_id "g1";
CC151   AUGUSTUS    intron  6385 6467 1 -   2   transcript_id "g1.t1"; gene_id "g1";
CC151   AUGUSTUS    intron  6550 6622 1 -   0   transcript_id "g1.t1"; gene_id "g1";
CC151   AUGUSTUS    intron  6714 6854 1 -   0   transcript_id "g1.t1"; gene_id "g1";
CC151   AUGUSTUS    CDS 6998 7110 1 -   2   transcript_id "g1.t1"; gene_id "g1";
CC151   AUGUSTUS    CDS 7888 7941 1 -   0   transcript_id "g1.t1"; gene_id "g1";
# end gene g1

I wish to change the default g1 to custom name for example "CC151_gene1". I tried to create a list of all gene ids and corresponding replace texts and tried the following:

g1   CC151_gene1
g2   CC151_gene2

grep -f gene.replacement.txt mygfffile.gff > replaced.gfffile.gff

However, my original file was not modified. Can anyone suggest a better method ?

Thanks in advance.

annotation gff augustus genome gene

1 answer

I would suggest to use agat_sp_manage_IDs.pl from AGAT. In same time it will standardize your output file which is not correct (9th column should contain ’tag value’ attribute and it is not the case for gene and transcript)

Hi Juke, Thanks for suggesting AGAT. It does work, but the problem is the naming is too long. For instance, the total number of genes i have is 28540 but I get a gene name like M000000000001. this is close to 12 places.

Ya I implemented like that to follow what does Ensembl. What you could do now that your file is standardized by AGAT, is to use agat_sq_manage_ID.pl (Do not use this script with your original file because it expects a properly formatted gff3. All script with sq prefix need a proper gff3 file )

I have fixed it in AGAT version 0.1.0

Hi Juke34 Is it possible to specify the prefix/ custom gene name to rename all the genes in the gff3 file with AGAT, so that the difference is like Hsap1, Hsap2, Hsap3, etc?

I was reading the agat_sq_manage_ID.pl and it doesn't mention the prefix option.

Let me ask you another question. Can AGAT count the number of genes per chromosome/scaffold of a GFF3 file?

Thank you very much.

Yes the --prefix Option exists. There is no count per chromosome. You can do it by splitting your input and analyse one sequence at a time or you may just use a awk command to perform this task.

Log in to answer this question.