I want to add the gene line to the transcriptome comment file,The annotation file is as follows:
chr1 Cufflinks transcript 11872 14412 0 + . gene_id "NONHSAG000001.2";gene_name "NONHSAG000001.2"; transcript_id "NONHSAT000002.2";FPKM "0"; exon_number 3;
chr1 Cufflinks exon 11872 12227 0 + . gene_id "NONHSAG000001.2";gene_name "NONHSAG000001.2"; transcript_id "NONHSAT000002.2"; FPKM "0"; exon_number 3;
chr1 Cufflinks exon 12613 12721 0 + . gene_id "NONHSAG000001.2";gene_name "NONHSAG000001.2"; transcript_id "NONHSAT000002.2"; FPKM "0"; exon_number 3;
chr1 Cufflinks exon 13225 14412 0 + . gene_id "NONHSAG000001.2";gene_name "NONHSAG000001.2"; transcript_id "NONHSAT000002.2"; FPKM "0"; exon_number 3;
Of course, the actual file is very large. I want to add a ‘gene’ line in front of each line where the third column is transcript, so that the file becomes:
chr1 Cufflinks gene 11872 14412 0 + . gene_id "NONHSAG000001.2";gene_name "NONHSAG000001.2"; transcript_id "NONHSAT000002.2";FPKM "0"; exon_number 3;
chr1 Cufflinks transcript 11872 14412 0 + . gene_id "NONHSAG000001.2";gene_name "NONHSAG000001.2"; transcript_id "NONHSAT000002.2";FPKM "0"; exon_number 3;
chr1 Cufflinks exon 11872 12227 0 + . gene_id "NONHSAG000001.2";gene_name "NONHSAG000001.2"; transcript_id "NONHSAT000002.2"; FPKM "0"; exon_number 3;
chr1 Cufflinks exon 12613 12721 0 + . gene_id "NONHSAG000001.2";gene_name "NONHSAG000001.2"; transcript_id "NONHSAT000002.2"; FPKM "0"; exon_number 3;
chr1 Cufflinks exon 13225 14412 0 + . gene_id "NONHSAG000001.2";gene_name "NONHSAG000001.2"; transcript_id "NONHSAT000002.2"; FPKM "0"; exon_number 3;
How can I implement this operation in R language?