Esempio n. 1
0
def run():

    if settings.input_format != 'plink':
        inp = open(settings.infile) if not settings.input_format == 'gzip' else gzip.open(settings.infile)
        line = inp.readline()
        orig_values = [float(value) for value in line.split()]
        if not settings.permutations:
            settings.permutations = sum(1 for _ in inp)
        inp.close()

        landscape = get_landscape(orig_values)
        landscape_generator = landscape_generator_file()
    else:
        inds, snps, genos = plink.read_plink(settings.infile)
        orig_values = plink.assoc(inds, genos)
        landscape = get_landscape(orig_values)
        landscape_generator = landscape_generator_plink()

    if settings.permutations > 0:
        if settings.score_evaluation == 'A1':
            pvalues, EM = get_pvalues_A1(landscape, landscape_generator)
        elif settings.score_evaluation == 'A2':
            pvalues, EM = get_pvalues_A2(landscape, landscape_generator)
        else:
            pvalues = get_pvalues_A0(landscape)
            EM = len(pvalues)
    else:
        pvalues = [1 for _ in landscape.maximal_segments]
        EM = 1

    write_results(landscape, pvalues, EM, settings)
    write_ak_text(orig_values, landscape, settings)
Esempio n. 2
0
def landscape_generator_plink():
    inds, snps, genos = plink.read_plink(settings.infile)
    random.seed(settings.random_seed)
    while 1:
        inds.pheno = np.random.permutation(inds.pheno)
        pvals = plink.assoc(inds, genos)
        yield get_landscape(pvals)