0
EQ963472        29264   .       G       A       212.0   .       DP=170;VDB=0.0253;AF1=1;AC1=2;DP4=0,0,79,83;MQ=60;FQ=-282;ANN=A|stop_gained|HIGH|AFLA_072280|AFLA_072280|transcript|EED56534|protein_coding|
EQ963472        31777   .       C       T       222.0   .       DP=179;VDB=0.0245;AF1=1;AC1=2;DP4=0,0,66,95;MQ=60;FQ=-282;ANN=T|stop_gained|HIGH|AFLA_072310|AFLA_072310|transcript|EED56537|protein_coding|
EQ963472        58523   .       G       A       222.0   .       DP=161;VDB=0.0269;AF1=1;AC1=2;DP4=0,0,71,83;MQ=60;FQ=-282;ANN=A|start_lost|HIGH|AFLA_072370|AFLA_072370|transcript|EED56543|protein_coding|1
EQ963472        171022  .       A       C       222.0   .       DP=164;VDB=0.0253;AF1=1;AC1=2;DP4=0,0,90,65;MQ=60;FQ=-282;ANN=C|stop_lost&splice_region_variant|HIGH|AFLA_072870|AFLA_072870|transcript|EED5
EQ963472        174382  .       C       T       136.0   .       DP=159;VDB=0.0253;AF1=1;AC1=2;DP4=0,0,65,76;MQ=60;FQ=-282;ANN=T|stop_gained|HIGH|AFLA_072890|AFLA_072890|transcript|EED56595|protein_coding|
EQ963472        185314  .       T       C       77.0    .       DP=168;VDB=0.0259;AF1=1;AC1=2;DP4=0,0,6,2;MQ=60;FQ=-51;ANN=C|stop_lost|HIGH|AFLA_072940|AFLA_072940|transcript|EED56600|protein_coding|1/1|c
EQ963472        188490  .       C       T       217.0   .       DP=175;VDB=0.0267;AF1=1;AC1=2;DP4=0,1,86,78;MQ=60;FQ=-282;PV4=0.48,8.8e-08,1,1;ANN=T|stop_gained|HIGH|AFLA_072960|AFLA_072960|transcript|EED

Fetch ids with AFLA_* and corresponding first column ids using pattern matching and regular expression

I tried to fetch only the AFLA ids using the following: grep -o "AFLA_[0-9]" A1.SNP.contig.snpeff_high.out |less This results in: AFLA_0 AFLA_0 AFLA_0 AFLA_0 We can concatenate the first two columns with an _ to get a unique id.

The output from the file should have first two columns and the AFLA_*

output should be:

EQ963472_29264 AFLA_072280 AFLA_072280
9
  • First column/field has the same id. Update your answer and show us what you want to achieve. Also what have you tried ? Jun 14, 2017 at 14:55
  • the description is unclear. Post the final desired result Jun 14, 2017 at 15:05
  • Instead of saying "didn't work" (in your edit) say what output you got and what you expected. It looks fine to me.
    – Joe P
    Jun 14, 2017 at 15:06
  • 2
    This is really fatiguing. Update your original post and show the lines you want. Let me give you an example... Jun 14, 2017 at 15:35
  • 2
    @gauravagarwal, stop confusing people, that's not good Jun 14, 2017 at 15:40

2 Answers 2

1

The output from the file should have first two columns and the AFLA_* ids

awk solution:

awk -F'[[:space:]]+|\\|AFLA_' -v pfx="ALFA_" 
     '{ print $1,$2,pfx $9,pfx substr($10,0,index($10,"|")-1) }' yourfile

The output:

EQ963472 29264 ALFA_072280 ALFA_072280
EQ963472 31777 ALFA_072310 ALFA_072310
EQ963472 58523 ALFA_072370 ALFA_072370
EQ963472 171022 ALFA_072870 ALFA_072870
EQ963472 174382 ALFA_072890 ALFA_072890
EQ963472 185314 ALFA_072940 ALFA_072940
EQ963472 188490 ALFA_072960 ALFA_072960

  • -F'[[:space:]]+|\\|AFLA_' - considering whitespace(s) and |AFLA_ sequence as field separators
6
  • If the outout should have AFLA_ prefixed to the fourth and fifth column then what changed should be made in the script? Jun 14, 2017 at 15:30
  • do you want the 3rd and 4th columns to be prefixed like EQ963472 29264 AFLA_072280 AFLA_072280 ? Jun 14, 2017 at 15:32
  • Instead of just the numbers in third and fourth column I need to have the complete id like AFLA_072280. Jun 14, 2017 at 15:34
  • @gauravagarwal,see my update Jun 14, 2017 at 15:39
  • Great! RomanPerekhrest. Exactly this is the output needed. Jun 14, 2017 at 15:42
0

With following grep "|AFLA_*" foo | cut -f1 -d" "

I see result as

EQ963472
EQ963472
EQ963472
EQ963472
EQ963472
EQ963472
EQ963472

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .