I try to find rows in my file where '1/1' or '0/0' occur 3 or more times. I use regex in Python. I test my regex with https://regex101.com/.
Here is the part of my input file:
0 chr1 1152 NaN G A 1355.64 NaN 1/1 0/1 0/1 0/1 1/1 0/1 0/1 0/1 0/1 1/1 0/1 0/1
4 chr1 1331 NaN A C 4171.07 NaN 0/0 0/1 0/1 0/1 0/0 0/1 0/1 0/1 0/1 0/0 0/1 0/1
5 chr1 1349 NaN T C 11194.50 NaN 0/1 0/1 0/1 0/1 1/1 0/1 0/1 0/1 0/1 1/1 0/1 0/1
6 chr1 1401 NaN T G 10825.80 NaN 0/1 0/1 0/1 0/1 1/1 0/1 0/1 0/1 0/1 1/1 0/1 0/1
8 chr1 4045 NaN G T 1917.92 NaN 1/1 1/1 1/1 1/1 1/1 1/1 0/1 1/1 0/1 1/1 0/1 1/1
I wrote a regex to find the beginning of the line:
r"^\d\s{3}(chr\d)?\s{2}\d+\s+\D+\d+\.\d+\s+\w+"
but I have a problem with the next part. I've tried:
r"^\d\s{3}(chr\d)?\s{2}\d+\s+\D+\d+\.\d+\s+\w+(\s{2,}1/1|\s{2,}0/0)"
but it finds just the first occurrence of '1/1' or '0/0'. When I try to use:
r"^\d\s{3}(chr\d)?\s{2}\d+\s+\D+\d+\.\d+\s+\w+((\s{2,}1/1){3,}|(\s{2,}0/0){3,})"
then there is just one match where '1/1' occurs three times or more but one by one:
8 chr1 4045 NaN G T 1917.92 NaN 1/1 1/1 1/1 1/1 1/1 1/1 0/1 1/1 0/1 1/1 0/1 1/1
Any ideas on how to find all rows with >= 3 '1/1' or '0/0'? Thanks a lot!



