我有一个文件(bigfile.txt),其中一列看起来像这样
NW_017095471.1 Gnomon mRNA 108321 109565 . + . ID=rna34;Parent=gene27;Dbxref=GeneID:108565285,Genbank:XM_017925071.1;Name=XM_017925071.1;gbkey=mRNA;gene=LOC108565285;model_evidence=Supporting evidence includes similarity to: 7 Proteins%2C and 100%25 coverage of the annotated genomic feature by RNAseq alignments%2C including 30 samples with support for all annotated introns;product=transmembrane protein 126A;transcript_id=XM_017925071.1
ID=gene27;Dbxref=GeneID:108565285;Name=LOC108565285;gbkey=Gene;gene=LOC108565285;gene_biotype=protein_coding
ID=gene28;Dbxref=GeneID:108569527;Name=LOC108569527;gbkey=Gene;gene=LOC108569527;gene_biotype=protein_coding
ID=gene78;Dbxref=GeneID:108562956;Name=LOC108562956;gbkey=Gene;gene=LOC108562956;gene_biotype=protein_coding
我有一个单独的清单:
gene27
gene28
我要使用每一行并grep ID字段,然后返回“ Name =”后面的“ LOC#”。
gene=$line
`grep $gene";" bigfile.txt | sed -e 's/Name=
返回
LOC108565285
LOC108569527
我该如何只提取这部分呢?
试试这个,
grep "ID=$pattern;" file | grep -o 'Name=[^;]*' | sed 's/Name=//g';
grep -o 'Name=[^;]*'
使用grep时,模式以“ Name =“开头,立即以“;”结尾 sed 's/Name=//g';
只需删除不需要的图案即可。本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句