def main(argv): opts, args = getopt.getopt(argv,"a:ghc:i",["report=", "genonames="]) for opt, arg in opts: if opt == '-a': report = arg print "processing array, getting snps {0}".format(report) getarraysnps(arg) [f, e] = parsegenotypes.checkRef(report) parsegenotypes.flipArray(report, f) parsegenotypes.filterzeros(report) parsegenotypes.printtabarray(report) elif opt == '-g': processgenotypes() elif opt == '-h': processhapmap() elif opt == '-c': snps = glob.json('Array251Msnps') if arg == '': genofiles = names1KG else: genofiles = arg combinegenos(genofiles, snps) elif opt == "-i": genofiles = names.append('hapmap')
def processhapmap(): print "parsing hapmap genotypes chrom files" parsegenotypes.parsehapmap() print "now filtering SNPs" b = parsegenotypes.filterSNPs('../genotypes/hapmap') print "{0} SNPs filtered out".format(len(b)) [flips, errors] = parsegenotypes.checkRef('../genotypes/hapmap') print "{0} flips and {1} errors".format(len(flips),len(errors)) #flips = glob.json('../genotypes/hapmapflips') #errors = glob.json('../genotypes/hapmaperrors') parsegenotypes.flipGeno('hapmapGeno', flips, errors)
def processgenotypes(): """parse genotype files and flip them around according to hg19 """ for i, n in enumerate(homedirnames): parsegenotypes.parse1KGvcf(vcffiles[i], names1KG[i]) b = parsegenotypes.filterSNPs(names1KG[i]) print "{0} SNPs filtered out".format(len(b)) c = parsegenotypes.checkRef(n) print "{0} errors and {1} flipped".format(len(c[1]),len(c[0])) #parsegenotypes.corrRef(c[0], n) parsegenotypes.flipGeno(n+'Geno', c[0], c[1])
import parsegenotypes d = parsegenotypes.checkRef(parsegenotypes.names[3])
parser.add_argument('-g', action='store_true') parser.add_argument('-hapmap', action='store_true') parser.add_argument('-init1KG', action='store_true') parser.add_argument('-inithapmap', action='store_true') parser.add_argument('-int', action='store_true') parser.add_argument('-pool', action='store_true') parser.add_argument('-merge', action='store_true') parser.add_argument('-i') args = parser.parse_args() print args if args.a: print "processing array, getting snps {0}".format(args.a) report = args.a getarraysnps(report) [f, e] = parsegenotypes.checkRef(report) parsegenotypes.flipArray(report, f, e) parsegenotypes.filterzeros(report) parsegenotypes.printtabarray(report) if args.g: processgenotypes() if args.hapmap: processhapmap() if args.init1KG: #snps = glob.json('25M1.1snps') snps = glob.json('MKReportbySNP1.txtsnps') #combinegenos(names1KG, snps, 'Genos1kgArray25M') combinegenos(names1KG, snps, 'Genos1kgArrayOmni') if args.inithapmap: snps = glob.json('Array25M1snps')