0

I have some large tab-delimited text files look like:

#CHR  POS  REF  ALT    EFC                         GOM
1    100   A    G     u_v(XXXXXX);i_v(XXXXXXX)     0
2    465   T    C     d_r(XXXXXX);i_r(XXXXXXXX)    1
9    600   T    G     d_i(XXXXXX);f_v(XXXXXXXX)    -

I want to delete the lines which

(1) the content in "EFC" column contains "i_r" or "u_v" (even there are also "(XXXXXX)" and other things there)

or

(2) the values in "GOM" column equal to 1.

So how to get the expected files using awk or sed?

2

Directly translated into awk:

awk -F'\t' '!($5 ~ /i_r/ || $5 ~ /u_v/ || $6 == 1) { print; }' input
  1. Set the field separator to tab \t
  2. If the following conditions are not true !( ... )
  3. Condition one: field 5 contains i_r, or
  4. Condition two: field 5 contains u_v, or
  5. Condition three: field 6 is 1, then
  6. print the line

Lines that match any of the conditions will not be printed ("deleted").

Sample output:

#CHR    POS     REF     ALT     EFC     GOM
9       600     T       G       d_i(XXXXXX);f_v(XXXXXXXX)       -

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.