This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Add double qoutes around transcript_id in gtf file

I am trying to add double quotes around transcript_id column in gtf file by following command but did not work

awk '{ if ($0 ~ "transcript_id") print $0; else print $0" transcript_id \"\";"; }' inputfile > outfile

and input file looks like this:

SL3.0ch00       StringTie       transcript      548415  552574  1000    +       .       gene_id STRG.6; transcript_id STRG.6.1; cov 2.472455; FPKM 1.523706; TPM 1.143045;
SL3.0ch00       StringTie       transcript      570552  575378  1000    -       .       gene_id STRG.11; transcript_id STRG.11.2; cov 9.309154; FPKM 5.736975; TPM 4.303733;

please kindly help me out.

rna-seq awk gtf stringtie

Hello BioBaby ,

Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time.
code_formatting

Thank you!

1 answer

Use sed:

$ sed 's/transcript_id \([^;]\+\)/transcript_id \"\1\"/g' input.gtf > output.gtf

fin swimmer

thanks finswimmer...it works!

Log in to answer this question.