Example #1
0
def doPop(study, force, pop):
    setIndivs = study.pops.getIndivs(pop)
    hash = MEGA.getHash(setIndivs)
    if addPopHash(study.cacheDir + "/pops", pop, hash) or force:
        name = "study/%s/%s" % (study.name, pop)
        sql.addId(name, hash)
        stats.doBasicInfoSet(setIndivs, force)
Example #2
0
def doxpEHH(study, force, pop, supp):
    logging.info("Starting xpEHH %s %s", pop, supp)
    shutil.rmtree("xpEHH", True)
    os.mkdir("xpEHH")
    os.chdir("xpEHH")
    setIndivs = study.getStatIndivs("xpEHH", pop)
    suppSetIndivs = study.getStatIndivs("xpEHH", supp)
    logging.info("numIndivs: %d %d", len(setIndivs), len(suppSetIndivs))
    hash = MEGA.getHash(setIndivs)
    hashSupp = MEGA.getHash(suppSetIndivs)
    myDir = MEGA.cacheDB + "/sets/" + karyo.karyotype + "/" + hash
    logging.info("xpEHH: %s hash: %s phase: %s", pop, hash,
                 study.getPhasePop("xpEHH", pop))
    if not force:
        if os.path.isfile(myDir + "/%s-22.uxpEHH" % (supp,)):
            logging.info("Already done and not forced")
            os.chdir("..")
            return
    name = "study/%s/xpEHH/%s" % (study.name, pop)
    sql.addId(name, hash)
    suppName = "study/%s/xpEHH/%s-support" % (study.name, supp)
    sql.addId(suppName, hashSupp)
    stats.doBasicInfoSet(setIndivs, force)
    stats.doBasicInfoSet(suppSetIndivs, force)
    w = open(tmpDir + "/xpEHH/inds", "w")
    for famId, sampId in setIndivs:
        w.write("%s\t%s\n" % (famId, sampId))
    w.close()
    w = open(tmpDir + "/xpEHH/suppinds", "w")
    for famId, sampId in suppSetIndivs:
        w.write("%s\t%s\n" % (famId, sampId))
    w.close()
    os.system("python3 %s/doHaploStats.py prepareData %s %s suppinds %s %s xpEHH" %
              (MEGA.haploScripts, karyo.karyotype, study.name,
               study.xpEHHConf["source"],
               study.getPhasePop("xpEHH", supp)))
    for k in range(1, 23 + 1):
        shutil.copyfile("%d.hap" % (k,),
                        "s%d.hap" % (k,))
    os.system("python3 %s/doHaploStats.py prepareData %s %s inds %s %s xpEHH" % (
              MEGA.haploScripts, karyo.karyotype, study.name,
              study.xpEHHConf["source"], study.getPhasePop("xpEHH", pop),))
    os.system("python3 %s/doHaploStats.py XPEHH %s" % (
        MEGA.haploScripts, karyo.karyotype))
    for k in range(1, 23 + 1):
        shutil.copyfile("%d.xpEHH" % (k,),
                        myDir + "/%s-%d.uxpEHH" % (supp, k,))
    os.chdir("..")
    logging.info("xpEHH Done")
    return hash
Example #3
0
def doiHS(study, force, pop):
    logging.info("Starting iHS")
    shutil.rmtree("iHS", True)
    os.mkdir("iHS")
    os.chdir("iHS")
    setIndivs = study.getStatIndivs("iHS", pop)
    logging.info("numIndivs: %d", len(setIndivs))
    hash = MEGA.getHash(setIndivs)
    myDir = MEGA.cacheDB + "/sets/" + karyo.karyotype + "/" + hash
    logging.info("iHS: %s hash: %s phase: %s",
                 pop, hash, study.getPhasePop("iHS", pop))
    if not force:
        if os.path.isfile(myDir + "/22.uiHS"):
            logging.info("Already done and not forced")
            os.chdir("..")
            return
    name = "study/%s/iHS/%s" % (study.name, pop)
    sql.addId(name, hash)
    stats.doBasicInfoSet(setIndivs, force)
    w = open(tmpDir + "/iHS/inds", "w")
    for famId, sampId in setIndivs:
        w.write("%s\t%s\n" % (famId, sampId))
    w.close()
    os.system("python3 %s/doHaploStats.py prepareData %s %s inds %s %s" %
              (MEGA.haploScripts, karyo.karyotype, study.name,
               study.iHSConf["source"], study.getPhasePop("iHS", pop)))
    os.system("python3 %s/doHaploStats.py iHS %s %s" % (MEGA.haploScripts,
              karyo.karyotype, study.name))

    for k in range(1, 23 + 1):
        try:
            shutil.copyfile("%d.uiHS" % k, myDir + "/%d.uiHS" % k)
        except IOError:
            pass

    os.chdir("..")
    logging.info("iHS Done")
    return hash
Example #4
0
def doPop(pop):
    indivs = MEGA.getIndivs(pop)
    popHash = stats.doBasicInfoSet(indivs)
    sql.addId("pop/" + pop, popHash)