)) worker.daemon = True worker.start() '''start background Thread that will run a loop to check run statistics and print We use thread, because I think this is necessary for a process that watches global variables like linesTested''' worker = Thread(target=checkStats) worker.daemon = True worker.start() ########################################################## #get windows and analyse if windType == "coordinate": windowGenerator = genomics.slidingCoordWindows(genoFile, windSize, stepSize, sampleData.indNames, include=scafsToInclude, exclude=scafsToExclude) elif windType == "sites": windowGenerator = genomics.slidingSitesWindows(genoFile, windSize, overlap, maxDist, minSites, sampleData.indNames, include=scafsToInclude, exclude=scafsToExclude) else: windowGenerator = genomics.predefinedCoordWindows(genoFile, windCoords, sampleData.indNames)
if include: scafsFile = open(include, "rU") scafsToInclude = [line.rstrip() for line in scafsFile.readlines()] print >> sys.stderr, len(scafsToInclude), "scaffolds will be analysed." scafsFile.close() else: scafsToInclude = None ########################################################################################################## #get windows and analyse if windType == "coordinate": windowGenerator = genomics.slidingCoordWindows(inFile, windSize, stepSize, headerLine=args.header, names=args.columns, include=scafsToInclude, exclude=scafsToExclude) elif windType == "sites": windowGenerator = genomics.slidingSitesWindows(inFile, windSize, overlap, maxDist, minSites, headerLine=args.header, names=args.columns, include=scafsToInclude, exclude=scafsToExclude) else: windowGenerator = genomics.predefinedCoordWindows(inFile,
if include: scafsFile = open(include, "rU") scafsToInclude = [line.rstrip() for line in scafsFile.readlines()] print >> sys.stderr, len(scafsToInclude), "scaffolds will be analysed." scafsFile.close() else: scafsToInclude = None ########################################################################################################## #get windows and analyse if windType == "coordinate": windowGenerator = genomics.slidingCoordWindows(inFile, windSize, stepSize, columns, include=scafsToInclude, exclude=scafsToExclude) elif windType == "sites": windowGenerator = genomics.slidingSitesWindows(inFile, windSize, overlap, maxDist, minSites, columns, include=scafsToInclude, exclude=scafsToExclude) else: windowGenerator = genomics.predefinedCoordWindows(inFile, windCoords, columns)
########################################################## if args.windType == "cat": window = genomics.parseGenoFile(genoFile, headerLine = args.header, names=sampleData.indNames) windowQueue.put((windowsQueued,window)) windowsQueued += 1 else: #get windows and analyse if args.windType == "coordinate": windowGenerator = genomics.slidingCoordWindows(genoFile, windSize, stepSize, headerLine = args.header, names = sampleData.indNames, include = scafsToInclude, exclude = scafsToExclude) elif args.windType == "sites": windowGenerator = genomics.slidingSitesWindows(genoFile, windSize, overlap, maxDist, minSites, headerLine = args.header, names = sampleData.indNames, include = scafsToInclude, exclude = scafsToExclude) else: windowGenerator = genomics.predefinedCoordWindows(genoFile, windCoords, headerLine = args.header, names = sampleData.indNames) for window in windowGenerator: windowQueue.put((windowsQueued,window)) windowsQueued += 1
windSize = args.windSize minSites = args.minSites stepSize = args.stepSize overlap = args.overlap maxDist = args.maxDist else: #to get contigs, we just use very lare non-overlapping coordinate windows windType = "coordinate" windSize = 1e7 minSites = 1 stepSize = 1e7 #initialise window generator if windType == "coordinate": windowGenerator = genomics.slidingCoordWindows( genoFile, windSize, stepSize, args.samples, splitPhased=args.splitPhased) else: windowGenerator = genomics.slidingSitesWindows( genoFile, windSize, overlap, maxDist, minSites, args.samples, splitPhased=args.splitPhased) for window in windowGenerator: posString = str(window.firstPos()) + "_" + str(window.lastPos())
scafsToExclude = None if include: scafsFile = open(include, "rU") scafsToInclude = [line.rstrip() for line in scafsFile.readlines()] print >> sys.stderr, len(scafsToInclude), "scaffolds will be analysed." scafsFile.close() else: scafsToInclude = None ########################################################################################################## #get windows and analyse if windType == "coordinate": windowGenerator = genomics.slidingCoordWindows(inFile, windSize, stepSize, args.columns, include = scafsToInclude, exclude = scafsToExclude) elif windType == "sites": windowGenerator = genomics.slidingSitesWindows(inFile, windSize, overlap, maxDist, minSites, args.columns, include = scafsToInclude, exclude = scafsToExclude) else: windowGenerator = genomics.predefinedCoordWindows(inFile, windCoords, args.columns) n=0 for window in windowGenerator: #if its the first window, get the headings and write if n == 0: for name in window.names: outFile.write(","+",".join([name + "_mean",name + "_median", name + "_max", name + "_min", name + "_sd", name + "_sum"]))