I would like to subset a GFF file (gene and nested features) from a gene list.
The GFF file looks like this
##gff-version 3
Scaffold_1 JGI gene 22901 45904 . + . ID=Genecv11000001m.g;Name=Genecv11000001m.g
Scaffold_1 JGI mRNA 22901 45904 . + . ID=PAC4GC:50510902;Name=Genecv11000001m;longest=1;Parent=Genecv11000001m.g
Scaffold_1 JGI five_prime_UTR 22901 23284 . + . ID=PAC4GC:50510902.five_prime_UTR.1;Parent=PAC4GC:50510902
Scaffold_1 JGI CDS 23285 23423 . + 0 ID=PAC4GC:50510902.CDS.1;Parent=PAC4GC:50510902
Scaffold_1 JGI CDS 24031 24062 . + 2 ID=PAC4GC:50510902.CDS.2;Parent=PAC4GC:50510902
Scaffold_1 JGI CDS 24192 24254 . + 0 ID=PAC4GC:50510902.CDS.3;Parent=PAC4GC:50510902
Scaffold_1 JGI CDS 24509 24568 . + 0 ID=PAC4GC:50510902.CDS.4;Parent=PAC4GC:50510902
Scaffold_1 JGI CDS 37558 37603 . + 0 ID=PAC4GC:50510902.CDS.5;Parent=PAC4GC:50510902
Scaffold_1 JGI CDS 37775 37821 . + 2 ID=PAC4GC:50510902.CDS.6;Parent=PAC4GC:50510902
Scaffold_1 JGI CDS 37927 38228 . + 0 ID=PAC4GC:50510902.CDS.7;Parent=PAC4GC:50510902
Scaffold_1 JGI CDS 42345 42702 . + 1 ID=PAC4GC:50510902.CDS.8;Parent=PAC4GC:50510902
Scaffold_1 JGI CDS 42798 43343 . + 0 ID=PAC4GC:50510902.CDS.9;Parent=PAC4GC:50510902
Scaffold_1 JGI CDS 44798 45079 . + 0 ID=PAC4GC:50510902.CDS.10;Parent=PAC4GC:50510902
Scaffold_1 JGI three_prime_UTR 45080 45904 . + . ID=PAC4GC:50510902.three_prime_UTR.1;Parent=PAC4GC:50510902
Scaffold_1 JGI mRNA 22901 45904 . + . ID=PAC4GC:50510903;Name=Genecv11000002m;longest=0;Parent=Genecv11000001m.g
Scaffold_1 JGI five_prime_UTR 22901 23284 . + . ID=PAC4GC:50510903.five_prime_UTR.1;Parent=PAC4GC:50510903
Scaffold_1 JGI CDS 23285 23423 . + 0 ID=PAC4GC:50510903.CDS.1;Parent=PAC4GC:50510903
Scaffold_1 JGI CDS 24031 24062 . + 2 ID=PAC4GC:50510903.CDS.2;Parent=PAC4GC:50510903
Scaffold_1 JGI CDS 24198 24254 . + 0 ID=PAC4GC:50510903.CDS.3;Parent=PAC4GC:50510903
Scaffold_1 JGI CDS 24509 24568 . + 0 ID=PAC4GC:50510903.CDS.4;Parent=PAC4GC:50510903
Scaffold_1 JGI CDS 37558 37603 . + 0 ID=PAC4GC:50510903.CDS.5;Parent=PAC4GC:50510903
Scaffold_1 JGI CDS 37775 37821 . + 2 ID=PAC4GC:50510903.CDS.6;Parent=PAC4GC:50510903
Scaffold_1 JGI CDS 37927 38228 . + 0 ID=PAC4GC:50510903.CDS.7;Parent=PAC4GC:50510903
Scaffold_1 JGI CDS 42345 42702 . + 1 ID=PAC4GC:50510903.CDS.8;Parent=PAC4GC:50510903
Scaffold_1 JGI CDS 42798 43343 . + 0 ID=PAC4GC:50510903.CDS.9;Parent=PAC4GC:50510903
Scaffold_1 JGI CDS 44798 45079 . + 0 ID=PAC4GC:50510903.CDS.10;Parent=PAC4GC:50510903
Scaffold_1 JGI three_prime_UTR 45080 45904 . + . ID=PAC4GC:50510903.three_prime_UTR.1;Parent=PAC4GC:50510903
And a have the target genes in a list such as
Genecv11033552m
Genecv11003131m
Genecv11036683m
Genecv11012576m
Genecv11003654m
Genecv11012587m
I know that is possible to subset the gff using grep -f gene_list.txt <gff_file>
. However this extracts only the gene and mRNA features, missing the CDS and UTR entries, while I would like to subset the gene together with all its children features (mRNA, five_prime_UTR, CDS, three_prime_UTR).
This happens because the ID in CDS and UTR features are the same of the mRNA and not as in the gene feature.
Any ideas?