Hi,
Does anyone here know how to extract lines from a gtf file using a list/subset of gene id obtained from the same gtf file? I basically want a 'recoded' (in vcf terminology) gtf file containing information for only those genes which I am interested in.
I tried awk awk 'FNR==NR {a[$0];next} {for (i in a) if (i~$1) print i}' and grep grep -Fwf but these have not yielded what I want. Thank you for your help.
2 answers
After playing with awk for a while, I came up with a solution:
awk -F'"' 'FNR==NR {block[$0];next} $2 in block' gene_id_list.txt ref_CDS.gtf > out.txt
[Note the quote delimeter]
While not the most elegant solution, this does what's asked in the question. Hope it helps anyone else looking for something similar.
Log in to answer this question.
can you please paste some sample data?