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) for window in windowGenerator: windowQueue.put((windowsQueued, window)) windowsQueued += 1 ############################################################################################################################################ print >> sys.stderr, "\nWriting final results...\n" while resultsHandled < windowsQueued: sleep(1) sleep(5) genoFile.close() outFile.close()
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, windCoords, headerLine=args.header, names=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 + "_" + stat for stat in args.stats])) outFile.write("\n") if windType == "coordinate" or windType == "predefined": scaf, start, end, mid, sites = (window.scaffold, window.limits[0], window.limits[1], window.midPos(),
exclude=scafsToExclude) elif args.windType == "sites": windowGenerator = genomics.slidingSitesWindows( genoFile, windSize, overlap, maxDist, minSites, headerLine=headerLine, names=sampleData.indNames, include=scafsToInclude, exclude=scafsToExclude) else: windowGenerator = genomics.predefinedCoordWindows( genoFile, windCoords, headerLine=headerLine, names=sampleData.indNames) for window in windowGenerator: windowQueue.put((windowsQueued, window)) windowsQueued += 1 ############################################################################################################################################ while resultsHandled < windowsQueued: sleep(1) sleep(5) genoFile.close()
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) 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" ])) outFile.write("\n") if windType == "coordinate" or windType == "predefined": scaf, start, end, mid, sites = (window.scaffold, window.limits[0],
stepSize, indNames, include=scafsToInclude, exclude=scafsToExclude) elif windType == "sites": windowGenerator = genomics.slidingSitesWindows(genoFile, windSize, overlap, maxDist, minSites, indNames, include=scafsToInclude, exclude=scafsToExclude) else: windowGenerator = genomics.predefinedCoordWindows(genoFile, windCoords, names=indNames) for window in windowGenerator: #simpleque has no max, so to make sure we haven't gotten ahead of ourselves, we compare windowsQueued to resultsReceived while windowsQueued - resultsReceived >= 50: sleep(10) if test or verbose: sys.stderr.write("Waiting for queue to clear...\n") if test or verbose: if test: sleep(0.5) sys.stderr.write("Sending window {} to queue. Length: {}\n".format( windowsQueued, window.seqLen())) windowQueue.put((windowsQueued, window)) windowsQueued += 1
########################################################## #get windows and analyse if windType == "coordinate": windowGenerator = genomics.slidingCoordWindows(genoFile, windSize, stepSize, headerLine = args.header, names = sampleData.indNames, include = scafsToInclude, exclude = scafsToExclude) elif 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 ############################################################################################################################################ print("Writing final results...", file=sys.stderr) while resultsHandled < windowsQueued: sleep(1) sleep(5)