请在awk中解释gsub(" \ 047 |,","",$ 0)的含义

时间:2016-03-22 23:49:26

标签: bash awk

来自源文件,例如;

{'PRIMER_INTERNAL_EXPLAIN': 'considered 3, ok 3',
 'PRIMER_INTERNAL_NUM_RETURNED': 0L,
 'PRIMER_LEFT_0': (29L, 22L),
 'PRIMER_LEFT_0_END_STABILITY': 3.86,
 'PRIMER_LEFT_0_GC_PERCENT': 45.45454545454545,
 'PRIMER_LEFT_0_HAIRPIN_TH': 0.0,
 'PRIMER_LEFT_0_PENALTY': 1.1657103482262485,
 'PRIMER_LEFT_0_SELF_ANY_TH': 0.0,
 'PRIMER_LEFT_0_SELF_END_TH': 0.0,
 'PRIMER_LEFT_0_SEQUENCE': 'ATGGCAAATACACAGAGGAAGC',
 'PRIMER_LEFT_0_TM': 58.98043552542492,
 'PRIMER_LEFT_1': (32L, 22L),
 'PRIMER_LEFT_1_END_STABILITY': 4.35,
 'PRIMER_LEFT_1_GC_PERCENT': 45.45454545454545,
 'PRIMER_LEFT_1_HAIRPIN_TH': 31.75767174449885,
 'PRIMER_LEFT_1_PENALTY': 1.2635420728922853,
 'PRIMER_LEFT_1_SELF_ANY_TH': 0.0,
 'PRIMER_LEFT_1_SELF_END_TH': 0.0,
 'PRIMER_LEFT_1_SEQUENCE': 'GCAAATACACAGAGGAAGCCTT',
 'PRIMER_LEFT_1_TM': 58.915214375647565,
 'PRIMER_LEFT_2': (27L, 23L),
 'PRIMER_LEFT_2_END_STABILITY': 3.46,
 'PRIMER_LEFT_2_GC_PERCENT': 43.47826086956522,
 'PRIMER_LEFT_2_HAIRPIN_TH': 0.0,
 'PRIMER_LEFT_2_PENALTY': 1.396379766521477,
 'PRIMER_LEFT_2_SELF_ANY_TH': 0.0,
 'PRIMER_LEFT_2_SELF_END_TH': 0.0,
 'PRIMER_LEFT_2_SEQUENCE': 'TGATGGCAAATACACAGAGGAAG',
 'PRIMER_LEFT_2_TM': 58.735746822319015,
 'PRIMER_LEFT_EXPLAIN': 'considered 479, overlap excluded region 66, GC content failed 18, low tm 100, high tm 139, ok 156',
 'PRIMER_LEFT_NUM_RETURNED': 3L,
 'PRIMER_PAIR_0_COMPL_ANY_TH': 0.0,
 'PRIMER_PAIR_0_COMPL_END_TH': 0.0,
 'PRIMER_PAIR_0_PENALTY': 3.6468465778591295,
 'PRIMER_PAIR_0_PRODUCT_SIZE': 114L,
 'PRIMER_PAIR_1_COMPL_ANY_TH': 0.0,
 'PRIMER_PAIR_1_COMPL_END_TH': 0.0,
 'PRIMER_PAIR_1_PENALTY': 3.744678302525166,
 'PRIMER_PAIR_1_PRODUCT_SIZE': 111L,
 'PRIMER_PAIR_2_COMPL_ANY_TH': 0.0,
 'PRIMER_PAIR_2_COMPL_END_TH': 0.0,
 'PRIMER_PAIR_2_PENALTY': 3.877515996154358,
 'PRIMER_PAIR_2_PRODUCT_SIZE': 116L,
 'PRIMER_PAIR_NUM_RETURNED': 3L,
 'PRIMER_RIGHT_0': (142L, 22L),
 'PRIMER_RIGHT_0_END_STABILITY': 3.33,
 'PRIMER_RIGHT_0_GC_PERCENT': 40.90909090909091,
 'PRIMER_RIGHT_0_HAIRPIN_TH': 39.90652312082375,
 'PRIMER_RIGHT_0_PENALTY': 2.481136229632881,
 'PRIMER_RIGHT_0_SELF_ANY_TH': 0.0,
 'PRIMER_RIGHT_0_SELF_END_TH': 0.0,
 'PRIMER_RIGHT_0_SEQUENCE': 'AGATGGTGAAACCTGTTTGTTG',
 'PRIMER_RIGHT_0_TM': 57.345909180244746,
 'PRIMER_RIGHT_1': (142L, 22L),
 'PRIMER_RIGHT_1_END_STABILITY': 3.33,
 'PRIMER_RIGHT_1_GC_PERCENT': 40.90909090909091,
 'PRIMER_RIGHT_1_HAIRPIN_TH': 39.90652312082375,
 'PRIMER_RIGHT_1_PENALTY': 2.481136229632881,
 'PRIMER_RIGHT_1_SELF_ANY_TH': 0.0,
 'PRIMER_RIGHT_1_SELF_END_TH': 0.0,
 'PRIMER_RIGHT_1_SEQUENCE': 'AGATGGTGAAACCTGTTTGTTG',
 'PRIMER_RIGHT_1_TM': 57.345909180244746,
 'PRIMER_RIGHT_2': (142L, 22L),
 'PRIMER_RIGHT_2_END_STABILITY': 3.33,
 'PRIMER_RIGHT_2_GC_PERCENT': 40.90909090909091,
 'PRIMER_RIGHT_2_HAIRPIN_TH': 39.90652312082375,
 'PRIMER_RIGHT_2_PENALTY': 2.481136229632881,
 'PRIMER_RIGHT_2_SELF_ANY_TH': 0.0,
 'PRIMER_RIGHT_2_SELF_END_TH': 0.0,
 'PRIMER_RIGHT_2_SEQUENCE': 'AGATGGTGAAACCTGTTTGTTG',
 'PRIMER_RIGHT_2_TM': 57.345909180244746,
 'PRIMER_RIGHT_EXPLAIN': 'considered 255, overlap excluded region 66, GC content failed 43, low tm 56, high tm 2, long poly-x seq 41, ok 47',
 'PRIMER_RIGHT_NUM_RETURNED': 3L,
 'SEQUENCE_ID': 'R-chr1:114713809-114714010',
 'SEQUENCE_TEMPLATE': 'TAATATCCGCAAATGACTTGCTATTATTGATGGCAAATACACAGAGGAAGCCTTCGCCTGTCCTCATGTATTGGTCTCTCATGGCACTGTACTCTTCTTGTCCAGCTGTATCCAGTATGTCCAACAAACAGGTTTCACCATCTATAACCACTTGTTTTCTGTAAGAATCCTGGGGGTGTggagggtaagggggcagggagg'}
None
{'PRIMER_INTERNAL_EXPLAIN': 'considered 3, ok 3',
 'PRIMER_INTERNAL_NUM_RETURNED': 0L,
 'PRIMER_LEFT_0': (51L, 23L),
 'PRIMER_LEFT_0_END_STABILITY': 4.24,
 'PRIMER_LEFT_0_GC_PERCENT': 43.47826086956522,
 'PRIMER_LEFT_0_HAIRPIN_TH': 0.0,
 'PRIMER_LEFT_0_PENALTY': 1.11245483566546,
 'PRIMER_LEFT_0_SELF_ANY_TH': 0.0,
 'PRIMER_LEFT_0_SELF_END_TH': 0.0,
 'PRIMER_LEFT_0_SEQUENCE': 'ACAAAGTGGTTCTGGATTAGCTG',
 'PRIMER_LEFT_0_TM': 58.92503010955636,
 'PRIMER_LEFT_1': (54L, 22L),
 'PRIMER_LEFT_1_END_STABILITY': 3.86,
 'PRIMER_LEFT_1_GC_PERCENT': 45.45454545454545,
 'PRIMER_LEFT_1_HAIRPIN_TH': 0.0,
 'PRIMER_LEFT_1_PENALTY': 1.2669303718815925,
 'PRIMER_LEFT_1_SELF_ANY_TH': 0.0,
 'PRIMER_LEFT_1_SELF_END_TH': 0.0,
 'PRIMER_LEFT_1_SEQUENCE': 'AAGTGGTTCTGGATTAGCTGGA',
 'PRIMER_LEFT_1_TM': 59.087044490345306,
 'PRIMER_LEFT_2': (55L, 22L),
 'PRIMER_LEFT_2_END_STABILITY': 3.41,
 'PRIMER_LEFT_2_GC_PERCENT': 45.45454545454545,
 'PRIMER_LEFT_2_HAIRPIN_TH': 0.0,
 'PRIMER_LEFT_2_PENALTY': 1.3141607548431367,
 'PRIMER_LEFT_2_SELF_ANY_TH': 0.0,
 'PRIMER_LEFT_2_SELF_END_TH': 0.0,
 'PRIMER_LEFT_2_SEQUENCE': 'AGTGGTTCTGGATTAGCTGGAT',
 'PRIMER_LEFT_2_TM': 58.88146858768033,
 'PRIMER_LEFT_EXPLAIN': 'considered 507, overlap excluded region 66, GC content failed 60, low tm 128, high tm 78, ok 175',
 'PRIMER_LEFT_NUM_RETURNED': 3L,
 'PRIMER_PAIR_0_COMPL_ANY_TH': 0.0,
 'PRIMER_PAIR_0_COMPL_END_TH': 0.0,
 'PRIMER_PAIR_0_PENALTY': 1.9448563397245948,
 'PRIMER_PAIR_0_PRODUCT_SIZE': 102L,
 'PRIMER_PAIR_1_COMPL_ANY_TH': 0.0,
 'PRIMER_PAIR_1_COMPL_END_TH': 0.0,
 'PRIMER_PAIR_1_PENALTY': 2.0993318759407273,
 'PRIMER_PAIR_1_PRODUCT_SIZE': 99L,
 'PRIMER_PAIR_2_COMPL_ANY_TH': 0.0,
 'PRIMER_PAIR_2_COMPL_END_TH': 0.0,
 'PRIMER_PAIR_2_PENALTY': 2.1465622589022715,
 'PRIMER_PAIR_2_PRODUCT_SIZE': 98L,
 'PRIMER_PAIR_NUM_RETURNED': 3L,
 'PRIMER_RIGHT_0': (152L, 22L),
 'PRIMER_RIGHT_0_END_STABILITY': 3.41,
 'PRIMER_RIGHT_0_GC_PERCENT': 40.90909090909091,
 'PRIMER_RIGHT_0_HAIRPIN_TH': 0.0,
 'PRIMER_RIGHT_0_PENALTY': 0.8324015040591348,
 'PRIMER_RIGHT_0_SELF_ANY_TH': 0.0,
 'PRIMER_RIGHT_0_SELF_END_TH': 0.0,
 'PRIMER_RIGHT_0_SEQUENCE': 'TTCTTGCTGGTGTGAAATGACT',
 'PRIMER_RIGHT_0_TM': 58.44506566396058,
 'PRIMER_RIGHT_1': (152L, 22L),
 'PRIMER_RIGHT_1_END_STABILITY': 3.41,
 'PRIMER_RIGHT_1_GC_PERCENT': 40.90909090909091,
 'PRIMER_RIGHT_1_HAIRPIN_TH': 0.0,
 'PRIMER_RIGHT_1_PENALTY': 0.8324015040591348,
 'PRIMER_RIGHT_1_SELF_ANY_TH': 0.0,
 'PRIMER_RIGHT_1_SELF_END_TH': 0.0,
 'PRIMER_RIGHT_1_SEQUENCE': 'TTCTTGCTGGTGTGAAATGACT',
 'PRIMER_RIGHT_1_TM': 58.44506566396058,
 'PRIMER_RIGHT_2': (152L, 22L),
 'PRIMER_RIGHT_2_END_STABILITY': 3.41,
 'PRIMER_RIGHT_2_GC_PERCENT': 40.90909090909091,
 'PRIMER_RIGHT_2_HAIRPIN_TH': 0.0,
 'PRIMER_RIGHT_2_PENALTY': 0.8324015040591348,
 'PRIMER_RIGHT_2_SELF_ANY_TH': 0.0,
 'PRIMER_RIGHT_2_SELF_END_TH': 0.0,
 'PRIMER_RIGHT_2_SEQUENCE': 'TTCTTGCTGGTGTGAAATGACT',
 'PRIMER_RIGHT_2_TM': 58.44506566396058,
 'PRIMER_RIGHT_EXPLAIN': 'considered 507, overlap excluded region 66, low tm 60, high tm 131, ok 250',
 'PRIMER_RIGHT_NUM_RETURNED': 3L,
 'SEQUENCE_ID': 'R-chr1:114716023-114716228',
 'SEQUENCE_TEMPLATE': 'GTCAGCGGGCTACCACTGGGCCTCACCTCTATGGTGGGATCATATTCATCTACAAAGTGGTTCTGGATTAGCTGGATTGTCAGTGCGCTTTTCCCAACACCACCTGCTCCAACCACCACCAGTTTGTACTCAGTCATTTCACACCAGCAAGAACCTGTTGGAAACCAGTAATCAGGGTTAATTGGCGAGCCACATCTACAGTACT'}
None

如果我使用它,

grep -E "PRIMER_LEFT_0_SEQUENCE|PRIMER_LEFT_1_SEQUENCE|PRIMER_RIGHT_0_SEQUENCE|PRIMER_RIGHT_1_SEQUENCE|SEQUENCE_ID" p3out_22_59_3pairs_del_No_out.out | paste - - - - - | awk '{ gsub("\047|,","",$0); print ">"$10"-L0\n"$2"\n>"$10"-L1\n"$4"\n>"$10"-R0\n"$6"\n>"$10"-R1\n"$8}' > xgrep_2primers.out

输出是,

>R-chr1:114713809-114714010-L0
ATGGCAAATACACAGAGGAAGC
>R-chr1:114713809-114714010-L1
GCAAATACACAGAGGAAGCCTT
>R-chr1:114713809-114714010-R0
AGATGGTGAAACCTGTTTGTTG
>R-chr1:114713809-114714010-R1
AGATGGTGAAACCTGTTTGTTG

任何人都可以在awk中向我解释{gsub(" \ 047 |,","",$ 0)的含义? Awk是如此强大的工具,我想了解更多。如果您知道要学习awk工具的好材料或地方,请与我分享。提前致谢!

3 个答案:

答案 0 :(得分:4)

\047是一个八进制转义符。它实际上只是一个单引号。使用嵌入式引号时,有时更容易编写\047而不是'\''

对于gsub,它运行正则表达式'|,(与[',]相同)并删除所有匹配项(因为第二个arg是一个空字符串)。

查看gsub所描述的gsub(ere, repl[, in]) Behave like sub (see below), except that it shall replace all occurrences of the regular expression (like the ed utility global substitute) in $0 or in the in argument, when specified.

gawk

如果您使用的是dropna(),请查看POSIX awk documentation

答案 1 :(得分:0)

tr -d "',"删除字符单引号和逗号相同。

答案 2 :(得分:-1)

取代' |没有。一个简单的撇号将是一个字符串的结尾,所以用\ 047

代替