예제 #1
0
    ploidyDict = dict(zip(samples, ploidy))
elif args.ploidyFile is not None:
    with open(args.ploidyFile, "rt") as pf:
        ploidyDict = dict([[s[0], int(s[1])] for s in [l.split() for l in pf]])
elif args.inferPloidy:
    ploidyDict = dict(zip(samples, [None] * len(samples)))
else:
    if args.genoFormat == "haplo":
        ploidyDict = dict(zip(samples, [1] * len(samples)))
    else:
        ploidyDict = dict(zip(samples, [2] * len(samples)))
    if args.haploid:
        for sample in args.haploid:
            ploidyDict[sample] = 1

sampleData = genomics.SampleData(indNames=samples, ploidyDict=ploidyDict)

############################################################################################################################################

#open files

if args.genoFile != None:
    genoFile = gzip.open(args.genoFile,
                         "rt") if args.genoFile.endswith(".gz") else open(
                             args.genoFile, "rt")
else:
    genoFile = sys.stdin

outs = {}

if args.outFile:
예제 #2
0
#if populations and samples not specified, just get all sample names from file
if len(allInds) == 0:
    with gzip.open(args.genoFile,
                   "r") if args.genoFile.endswith(".gz") else open(
                       args.genoFile, "r") as gf:
        allInds = gf.readline().split()[2:]

if args.inferPloidy: ploidyDict = dict(zip(allInds, [None] * len(allInds)))
else: ploidyDict = dict(zip(allInds, [2] * len(allInds)))

if args.haploid:
    for sample in args.haploid.split(","):
        ploidyDict[sample] = 1

sampleData = genomics.SampleData(indNames=allInds,
                                 popNames=popNames,
                                 popInds=popInds,
                                 ploidyDict=ploidyDict)

############################################################################################################################################

#open files

if args.genoFile:
    genoFile = gzip.open(args.genoFile,
                         "r") if args.genoFile.endswith(".gz") else open(
                             args.genoFile, "r")
else:
    genoFile = sys.stdin

if args.outFile:
    outFile = gzip.open(args.outFile,
예제 #3
0
#Define the input file and create a file handle:

genoFileName = filename
genoFile = gzip.open(genoFileName, "r")

#Provide names for the populations in our dataset, and list the individuals in each.
# We have 9 silvereye  populations

popNames = ["P1", "P2"]

samples = [["P1_" + str(i) for i in xrange(1, int(pop1))],
           ["P2_" + str(i) for i in xrange(1, int(pop2))]]

#Create a sampleData object, which stores this population information.

sampleData = genomics.SampleData(popInds=samples, popNames=popNames)

#Set the run parameters
windSize = 500000
stepSize = 500000
minSites = 1

#Now we create a windowGenerator object
windowGenerator = genomics.slidingWindows(genoFile,
                                          windSize,
                                          stepSize,
                                          skipDeepcopy=True)

#Define and open the output file.

outFileName = "FST_" + str(genoFileName) + ".csv"