コード例 #1
0
ファイル: master.py プロジェクト: JohnCEarls/tcDirac
def genRMS(comm,sd,mi,k_neighbors):
   
    #get and distribute pws and strains 
    pws = None
    if comm.rank == 0:
        pws = sd.getPathways()
        strain_list = mi.getStrains()

    pws = comm.bcast(pws)
    strain_list = comm.bcast(strain_list)

    
    for cstrain in strain_list:

        logging.info('Starting strain [%s]' % cstrain)
        
        mypws = [pw for i,pw in enumerate(pws) if i%comm.size == comm.rank]
        alleles = mi.getNominalAlleles(cstrain)
        indexes = ["%s_%s" % (pw,allele) for pw,allele in  itertools.product(mypws,alleles)]
        samples = mi.getSampleIDs(cstrain)

        #preallocate results dataframe 
        results = pandas.DataFrame(np.empty((len(indexes), len(samples)), dtype=float), index=indexes, columns=samples)
        for pw in mypws:
            #partition samples by strain/allele
            samples = partitionSamplesByAllele( alleles, mi, cstrain)

            #generate pw srts for all samples partitioned by strain/allele
            srts = getSRTSByAllele(alleles,pw,samples)

            for allele_base in alleles:
                for allele_compare in alleles:
                    r_index = "%s_%s" % (pw,allele_compare)
                    #list of samples with comparison allele
                    compare_list = samples[allele_compare]
                    for age, samp in samples[allele_base]:

                        samp_compare = kNearest(compare_list,samp_name, samp_age, k_neighbors)

                        comp_exp = srts[allele_compare].loc[:,samp_compare]
                        rt = dirac.getRT(comp_exp)
                        results[samp][r_index] =  dirac.getRMS(srts[allele_base][samp],rt)

        comm.barrier()
        return results
コード例 #2
0
ファイル: worker.py プロジェクト: JohnCEarls/tcDirac
 def getRMS(self, rt, srt):
     return dirac.getRMS( srt, rt )
コード例 #3
0
ファイル: worker.py プロジェクト: JohnCEarls/tcDirac
 def getRMS(self, rt, srt):
     return dirac.getRMS(srt, rt)