This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extract certain lines from gff3 file?

How to extract lines with GENE from gff3 file and write them into another file?

file content as blow:

NW_008989317.1 Gnomon CDS 2122 2224 . + 1 Parent=rna51510;ID=CDS:rna51510:9 NW_008989317.1 Gnomon CDS 2347 2493 . + 0 ID=CDS:rna51510:10;Parent=rna51510 NW_008989317.1 Gnomon gene 77367 78593 . + . Name=LOC103941441;ID=gene40805;Name=gene40805 NW_008989317.1 Gnomon mRNA 77367 78593 . + . Parent=gene40805;ID=rna51515 NW_008989317.1 Gnomon CDS 77367 77922 . + 0 Parent=rna51515;ID=CDS:rna51515:1 NW_008989317.1 Gnomon CDS 78059 78276 . + 2 Parent=rna51515;ID=CDS:rna51515:2

gff3 gene_ids extract

1 answer

Open your terminal and change to your directory that .gff3 located, then run the following command.

awk '$3=="gene" {print $0}' INPUT.gff3 > OUTPUT.gff3

Log in to answer this question.