@@ -0,0 +1,2492 @@
+import sys%0Aimport os%0Aimport progressbar%0A%0Aimport pandas as pd%0Aimport numpy as np%0Aimport camoco as co%0Afrom collections import OrderedDict%0A%0Adef simulateGWAS(args):%0A    if args.out != sys.stdout:%0A        args.out = %22%7B%7D_GWASSim.csv%22.format(args.out.replace('.csv',''))        %0A    if os.path.dirname(args.out) != '':%0A        os.makedirs(os.path.dirname(args.out),exist_ok=True)%0A    if os.path.exists(%22%7B%7D_GWASSim.csv%22.format(args.out.replace('.csv',''))):%0A        print(%0A            %22%7B%7D_GWASSim.csv exists! Skipping!%22.format(%0A                args.out.replace('.csv','')%0A            )%0A        )%0A        return None%0A%0A    go = co.GOnt(args.GOnt)%0A    cob = co.COB(args.cob)%0A    terms = (x for x in go.iter_terms() %5C%0A            if len(x.loci) %3E= args.min_term_size %5C%0A            and len(x.loci) %3C= args.max_term_size %0A    )%0A    results = %5B%5D%0A    for i,term in enumerate(terms):%0A        cob.log('On term %7B%7D',i)   %0A        window_size = args.candidate_window_size%0A        flank_limit =  args.candidate_flank_limit%0A        # Generate a series of densities for parameters%0A        num_genes = len(term.loci)%0A        eloci = term.effective_loci(%0A            window_size=window_size%0A        )%0A        candidates = cob.refgen.candidate_genes(%0A            eloci,%0A            flank_limit=flank_limit%0A        )%0A        if len(candidates) == 0:%0A            density = np.NaN%0A            trans_density = np.NaN%0A            pval = np.NaN%0A        else:%0A            density = cob.density(%0A                candidates%0A            )%0A            trans_density = cob.trans_locus_density(%0A                eloci,%0A                flank_limit=flank_limit%0A            )%0A            bootstraps = np.array(%5B%0A                cob.trans_locus_density(%0A                    eloci,%0A                    flank_limit=flank_limit,%0A                    iter_name = x,%0A                    bootstrap=True%0A                ) for x in range(args.num_bootstraps)%0A            %5D)%0A            pval = sum(%5Bx%3E=trans_density for x in bootstraps%5D)/args.num_bootstraps%0A        results.append(OrderedDict(%5B%0A            ('COB',cob.name),%0A            ('GO',term.id),%0A            ('NumGenes',num_genes),%0A            ('WindowSize',window_size),%0A            ('FlankLimit',flank_limit),%0A            ('NumEffective',len(eloci)),%0A            ('NumCandidates',len(candidates)),%0A            ('Density',density),%0A            ('TransDensity',trans_density),%0A            ('Pval',pval)%0A        %5D))%0A    results = pd.DataFrame.from_dict(results)%0A    results.to_csv(args.out)%0A

add new simualteGWAS command