This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Please give me a grep command to get Gene IDS and TPM values from a stringtie output gtf file

Hi, Could anyone please give me a grep command to get gene_id and respective TPM values from a string tie output file.

My result output file looks like the following

Chr01   StringTie   transcript  133413  134899  1000    -   .   gene_id "STRG.1"; transcript_id "STRG.1.1"; reference_id "mRNA:HanXRQr2_Chr01g0000011"; ref_gene_id "gene:HanXRQr2_Chr01g0000011"; ref_gene_name "HanXRQr2Chr01g0000011"; cov "6.216543"; FPKM "0.818698"; TPM "0.915700"
grep stringtie awk rna-seq gtf

2 answers

Hi! And welcome to biostars :). Keep in mind for next time that generally is a good practice to provide some code showing your own efforts to fix the issue. Here a quick solution (not tested):

cut -f 9 your_file | cut -d';' -f1,8 | sed 's/gene_id "//g;s/"; TPM "/,/g;s/"//g'

Thank you for the code. I will definitely keep in mind your advice.

cut -f 9 in.gtf | awk -F '[; "]+' '{i=1;while(i<=NF) {if($i=="gene_id" || $i=="TPM"){ printf("%s\t",$(i+1));} i++;}printf("\n");}'

Thank you for the code. I used it to get my result.

Log in to answer this question.