extract gene-id + function annotation from .gff

1.8k views Asked by At

i have a .gff file looking like this:

Niben044Scf00000988 .   contig  1   120868  .   .   .   ID=Niben044Scf00000988;Name=Niben044Scf00000988
Niben044Scf00000988 maker   gene    6221    8457    .   -   .   ID=NbS00000988g0019;AltID=maker-Niben044Scf00000988-augustus-gene-0.18;Name=NbS00000988g0019;PredictionNote=maker-augustus
Niben044Scf00000988 maker   mRNA    6221    8457    .   -   .   ID=NbS00000988g0019.1;Parent=NbS00000988g0019;AltID=maker-Niben044Scf00000988-augustus-gene-0.18-mRNA-1;Name=NbS00000988g0019.1;_AED=0.07;_QI=0|1|1|1|1|1|3|43|341;_eAED=0.07;blast_hits=TAIR:AT3G28470.1:I57.93:L145:E8e-43,SWP:MYB38_MAIZE:I46.92:L130:E1e-29,GB:CAN75378.1:I45.28:L360:E1e-77,ITAG:Solyc03g113530.2.1:I74.03:L362:E4e-155;func_annotation="MYB transcription factor [Solanum lycopersicum]"

....

I need the gene-ids and the function-annotations which belongs to them. i want to use it in R.

with gffread it seem that i only can extract sequences.

the output should looke like this:

Gene-ID \t functionannotation

NbS00000988g001 \t MYB transcription factor [Solanum lycopersicum]

is there any tool or mini-script in bioperl?

1

There are 1 answers

0
user1981275 On

You can use use Bio::FeatureIO for that. Below an example for your data:

use strict;
use warnings;
use Bio::FeatureIO;

# read infile "my.gff"
my $in  = Bio::FeatureIO->new(-file => "my.gff" , -format => 'GFF');

# write to outfile "out.txt"
open(my $fh, '>', 'out.txt') or die $!;
print $fh "Gene-ID\tfunctionannotation\n";

while ( my $feature = $in->next_feature() ) {
        my ($func) = $feature->annotation()->get_Annotations('func_annotation');
        print $fh $feature->seq_id . "\t" . $func->value . "\n" if $func;
}

File out.txt:

Gene-ID functionannotation
Niben044Scf00000988 MYB transcription factor [Solanum lycopersicum]