awkを使用して目的の出力を取得し、出力を別のファイルに追加するにはどうすればよいですか?
私のtest.gtfファイルは次のとおりです。 テスト.gtf chr2 Cufflinks exon 5072 5353 . - . transcript_id "transc_00000019"; gene_id "XLOC_000017"; gene_name "XLOC_000017"; exon_number "1"; inf "unknown"; Other "XLOC_000017"; chr2 Cufflinks transcript 5072 5353 . - . transcript_id "transc_00000019"; gene_id "XLOC_000017"; gene_name "XLOC_000017"; oId "TCONS_00000019"; class_code "u"; tss_id "TSS19"; inf "unknown"; original_gene_id "XLOC_000017"; chr2 Cufflinks exon 20450 20769 . + . transcript_id "transc_00000001"; gene_id "XLOC_000001"; gene_name "XLOC_000001"; exon_number "1"; inf "unknown"; original_gene_id "XLOC_000001"; chr2 Cufflinks transcript 20450 20769 . + . transcript_id "transc_00000001"; gene_id "XLOC_000001"; gene_name "XLOC_000001"; oId "TCONS_00000001"; class_code "u"; tss_id "TSS1"; inf "unknown"; original_gene_id "XLOC_000001"; chr2 Cufflinks exon 24985 25273 . + . transcript_id "transc_00000002"; gene_id "XLOC_000002"; gene_name "XLOC_000002"; exon_number "1"; inf "unknown"; original_gene_id "XLOC_000002"; chr2 Cufflinks transcript 24985 25273 . + . transcript_id "transc_00000002"; gene_id "XLOC_000002"; gene_name "XLOC_000002"; oId "TCONS_00000002"; class_code "u"; tss_id "TSS2"; inf "unknown"; original_gene_id "XLOC_000002"; chr2 Cufflinks exon 43499 43705 . + . transcript_id "transc_00000003"; gene_id "XLOC_000003"; gene_name "XLOC_000003"; exon_number "1"; inf "unknown"; original_gene_id "XLOC_000003"; chr2 Cufflinks transcript 43499 43705 . + . transcript_id "transc_00000003"; gene_id "XLOC_000003"; gene_name "XLOC_000003"; oId "TCONS_00000003"; class_code "u"; tss_id "TSS3"; inf "unknown"; original_gene_id "XLOC_000003"; transcript3番目の列で次のコマンドを試してみましたが、次のように5番目と4番目の列を使用して番号を取得しようとしました。 awk -F"\t" '$3=="transcript" {ID=substr($9, length($9)-16, 15); L[ID]+=$5-$4+1} END{for(i in L){print i"\t"L[i]}}' test.gtf ただし、上記のコマンドは出力を提供しません。出力は次のようになります。 transcript_id num transc_00000019 282 transc_00000001 320 transc_00000002 289 transc_00000003 207 test2.tsv次のような別のファイルがあります。 gene_id transcript_id column3 column4 column5 column6 XLOC_000017 transc_00000019 - - - - XLOC_000001 transc_00000001 - - - - XLOC_000002 transc_00000002 - - - - XLOC_000003 transc_00000003 - - - - 私が得た出力はファイルの別の列として追加する必要があり、test2.tsv次のようになります。 test2.tsv gene_id transcript_id column3 column4 column5 column6 num XLOC_000017 transc_00000019 - - - - 282 XLOC_000001 transc_00000001 - - - - 320 XLOC_000002 transc_00000002 - - - - 289 XLOC_000003 transc_00000003 - - - - 207