0
$\begingroup$

I am trying to find this pattern on a large file but the output doesn't look good. The output doesn't seem to reflect the pattern.

Father = 1|0 or 1/0

Mother = 110 or 1/0

Daughter 1 = 1|0 or 1/0

Daughter 2 = 1|1 or 1/1

Daughter 3 = 0|0 or 0/0

Son 1 = 1|0 or 1/0

Son 2 = 1|1 or 1/1

The content of the file1 looks like this

CHROM   POS REF ALT FATHER  MOTHER  DAUGHTER1   DAUGHTER2   DAUGHTER3   

SON1    SON2    INFO    FREQUECY
1   1226852 G   C   1/0 0/0 1|0 1|0 1|0 1|0 0|0 AN=2184;AC=12   0.005494505
1   1847936 C   T   0/1 1/1 1|1 1|1 1|1 1|1 0|1 AC=1;AN=2184    0.000457875
1   2428427 C   G   0/1 0/0 0|0 0|0 0|0 0|0 1|0 AC=4;AN=2184    0.001831502
1   2515616 G   A   1/0 1/0 1/0 1|1 1|1 1/0 1/0 AC=1;AN=2184    0.000457875
1   3801895 T   C   1/0 1/0 0|0 1/0 1/0 0|0 1|1 AC=10;AN=2184   0.004578755
1   3833321 T   C   1/0 1/0 1|1 1/0 1/0 1|1 0|0 AN=2184;AC=801  0.366758242
1   9009352 A   G   0/1 0/1 1|1 0/1 0/1 1|1 0|0 AC=90;AN=2184   0.041208791
1   9328077 G   A   1/1 0/0 1|0 1|0 1|0 1|0 1|0 AC=1;AN=2184    0.000457875
1   10684412    C   T   0/1 0/0 1|0 1|0 1|0 1|0 0|0 AN=2184;AC=2    0.000915751
1   11782120    G   A   1/0 0/0 0|0 0|0 1|0 1|0 0|0 AC=3;AN=2184    0.001373626
1   12034879    A   T   0/1 1/1 0|1 0|1 0|1 0|1 1|1 AC=3;AN=2184    0.001373626
1   16064465    C   A   1/0 0/0 0|0 0|0 0|0 0|0 1|0 AN=2184;AC=4    0.001831502
1   16111170    G   A   1/0 1/0 1/0 0|0 0|0 1/0 1/0 AC=1;AN=2184    0.000457875
1   16200229    C   A   0/0 1/0 0|0 0|1 0|1 0|0 0|1 AC=9;AN=2184    0.004120879
1   16258118    C   T   0/1 0/0 1|0 1|0 1|0 1|0 0|0 AN=2184;AC=1    0.000457875
1   17966719    A   G   0/0 0/1 0|1 0|0 0|0 0|1 0|0 AC=0;AN=2184    0
1   19751079    CG  C   0/1 0/1 1|1 0|0 0|0 0/1 0/1 AN=2184;AC=1    0.000457875
1   19955045    G   A   0/0 1/0 0|0 0|1 0|1 0|0 0|1 AN=2184;AC=4    0.001831502
1   21060356    G   A   1/0 1/0 1/0 1/0 1/0 1|1 0|0 AN=2184;AC=541  0.247710623

My awk script look like this

awk '($8~/1\/1/ || $8~/1\\|1/) && ($9~/0\/0/ ||$9~/0\\|0/) && ($7~/^1\\|0/||$7~/1\/0/) && ($10~/1\\|0/||$7~/1\/0/) && ($10~/0\/0/ ||  $10~/0\\|0/) && ($5~/1\/0/|| $5~/1\\|0/) && ($11~/0\/1/||$11~/0\\|1/)&& ($6~/1\\|0/||$6~/1\/0/) && ($12 ~/1\/1/ ||12~/1\\|1/){print}' file1 >file2
$\endgroup$
3
  • $\begingroup$ What's wrong with the output? "Doesn't look good" isn't very informative. Please edit your question and highlight what is going wrong. $\endgroup$
    – terdon
    Commented Oct 9, 2019 at 8:20
  • $\begingroup$ The output doesn't reflect the pattern. $\endgroup$ Commented Oct 9, 2019 at 8:37
  • $\begingroup$ Well yes, I imagine so. But since this is a really complex pattern, it would be very helpful if you could show the output you get and explain why it is wrong. I wrote you the script you're using, and I still don't see what the issue is. $\endgroup$
    – terdon
    Commented Oct 9, 2019 at 8:40

1 Answer 1

2
$\begingroup$

Example output of what you got and what you expected would be helpful, without these one can only guess.

First of all your input does not have a row satisfying the criteria you have given, so I added two dummy rows, one with / and one with | used as separator.

Here is the code I used:

awk '($5~/1\|0/ || $5~/1\/0/) && ($6~/1\|0/ || $6~/1\/0/) && ($7~/1\|0/ || $7~/1\/0/) && ($8~/1\|1/ || $8~/1\/1/) && ($9~/0\|0/ || $9~/0\/0/) && ($10~/1\|0/ || $10~/1\/0/) && ($11~/1\|1/ || $11~/1\/1/) {print}' test.txt

And its output (input is yours + 2 dummy rows):

Dummy  dummy D D 1/0 1/0 1/0 1/1 0/0 1/0 1/1 dummy dummy
Dummy  dummy D D 1|0 1|0 1|0 1|1 0|0 1|0 1|1 dummy dummy

The code is basically yours, except for:

  • I escaped | with one \ instead of two
  • I changed this part: ($10~/1\\|0/||$7~/1\/0/). I think $7 should have been $10
  • I removed a ^ from one of your conditions, I believe they all should start with ^ though, per @terdon's answer on a related question

I believe the code above does what you want, but when I run code above with two backslashes to escape I get the following output and could not figure out why!

1   3801895 T   C   1/0 1/0 0|0 1/0 1/0 0|0 1|1 AC=10;AN=2184   0.004578755
1   16200229    C   A   0/0 1/0 0|0 0|1 0|1 0|0 0|1 AC=9;AN=2184    0.004120879
1   19955045    G   A   0/0 1/0 0|0 0|1 0|1 0|0 0|1 AN=2184;AC=4    0.001831502
Dummy  dummy D D 1/0 1/0 1/0 1/1 0/0 1/0 1/1 dummy dummy
Dummy  dummy D D 1|0 1|0 1|0 1|1 0|0 1|0 1|1 dummy dummy
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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