#!/usr/bin/env python
# Finds SNPs in a BIM file which may have strand problems if this is a merged data set
# e.g., if A/T we can't be sure that merging has happened correctly if the source plink files had SNPs 
# on different strands
#
#
#

from __future__ import print_function
import argparse
import sys
import re


parser = argparse.ArgumentParser(description='finds SNPs in a BIM file  with A/T or C/G ref-alt pairs')
parser.add_argument('fname', help='file name',type=str)
parser.add_argument('--show-alleles', action="store_true", dest="show", default="", help='file name')
args = parser.parse_args()

mat = re.compile("(\S+)\s(\S+)\s(\S+)\s(\S+)\s((A\sT)|(T\sA)|(C\sG)|(G\sC))$",flags=re.I)

for line in open(args.fname):
    m = mat.search(line)
    if m:
        out=m.group(2)
        if args.show: out=out+"\t"+m.group(5)
        print(out)
