def write_file_and_test_fitness(self):
        #this writes a file, and calls JKK's fitness code and points it to the file
        #and retrieves the lnL (aka fitness) and then cleans up the file
        #also uses a cache ("memo") to check if the fitness has already been calculated for a particular order
        #this saves on the expensive compute
        ##6/27/16, further modifications also now allow it to search through precomputed local values and pass in those
        ##in place of full estimates.
        starttime = time.time()
        fnm = sha.sha(str(self.chrom_list)).hexdigest()
        self.tag = fnm
#        print 'running', self.chrom_list, self.tag
        if fnm in self.memo:
            #print 'hit:', fnm
            self.Fitness = self.memo[fnm][0]
            self.Rates = self.memo[fnm][1]
            self.runtime = time.time() - starttime
            #update_subset_memo(self.chrom_list, self.Rates)
        else:  #we haven't tested this one yet
            b = open(fnm, 'w')
            for i in self.chrom_list:
                scaff = self.scaff_lookup[abs(i)]
                output = self.chrom_dict[scaff]
                if i < 0: output = list(reversed(output))
                for j in output: b.write(scaff+'\t'+j+'\n')
            b.close()
            myUGaps, my_R_rates = fill_in_rates_return_UGaps_and_new_R_rates(self.chrom_list, self.subset_memo)
            rates_and_lnLk = fitness(fnm, my_R_rates, myUGaps)
            rates = rates_and_lnLk[:-1]
            myfitness = rates_and_lnLk[-1]
            self.Fitness = myfitness
            self.Rates = rates
            os.remove(fnm)
            self.runtime = time.time() - starttime
Example #2
0
 def write_file_and_test_fitness(self):
     #this writes a file, and calls JKK's fitness code and points it to the file
     #and retrieves the lnL (aka fitness) and then cleans up the file
     #also uses a cache ("memo") to check if the fitness has already been calculated for a particular order
     #this saves on the expensive compute
     ##6/27/16, further modifications also now allow it to search through precomputed local values and pass in those
     ##in place of full estimates.
     starttime = time.time()
     fnm = sha.sha(str(self.chrom_list)).hexdigest()
     self.tag = fnm
     #        print 'running', self.chrom_list, self.tag
     if fnm in self.memo:
         #print 'hit:', fnm
         self.Fitness = self.memo[fnm][0]
         self.Rates = self.memo[fnm][1]
         self.runtime = time.time() - starttime
         #update_subset_memo(self.chrom_list, self.Rates)
     else:  #we haven't tested this one yet
         b = open(fnm, 'w')
         for i in self.chrom_list:
             scaff = self.scaff_lookup[abs(i)]
             output = self.chrom_dict[scaff]
             if i < 0: output = list(reversed(output))
             for j in output:
                 b.write(scaff + '\t' + j + '\n')
         b.close()
         myUGaps, my_R_rates = fill_in_rates_return_UGaps_and_new_R_rates(
             self.chrom_list, self.subset_memo)
         rates_and_lnLk = fitness(fnm, my_R_rates, myUGaps)
         rates = rates_and_lnLk[:-1]
         myfitness = rates_and_lnLk[-1]
         self.Fitness = myfitness
         self.Rates = rates
         os.remove(fnm)
         self.runtime = time.time() - starttime
    def write_file_and_test_fitness(self):
        #this writes a file, and calls JKK's fitness code and points it to the file
        #and retrieves the lnL (aka fitness) and then cleans up the file
        #also uses a cache ("memo") to check if the fitness has already been calculated for a particular order
        #this saves on the expensive compute
        ##6/27/16, further modifications also now allow it to search through precomputed local values and pass in those
        ##in place of full estimates.
        fnm = sha.sha(str(self.chrom_list)).hexdigest()
        self.tag = fnm
#        print 'running', self.chrom_list, self.tag
        if fnm in self.memo:
            print 'hit:', fnm
            self.Fitness = self.memo[fnm][0]
            self.Rates = self.memo[fnm][1]
            #update_subset_memo(self.chrom_list, self.Rates)
        else:  #we haven't tested this one yet
            b = open(fnm, 'w')
            for i in self.chrom_list:
                scaff = self.scaff_lookup[abs(i)]
                output = self.chrom_dict[scaff]
                if i < 0: output = list(reversed(output))
                for j in output: b.write(scaff+'\t'+j+'\n')
            b.close()
#            print self.tag
            myUGaps, my_R_rates = fill_in_rates_return_UGaps_and_new_R_rates(self.chrom_list, self.subset_memo,  intra_scaff = 0.31)
            #print 'run!'
            #print self.chrom_list
            #print self.Rates
            #print self.UGaps
            rates_and_lnLk = fitness(fnm, my_R_rates, myUGaps)
            full_fitness_and_rates = fitness(fnm, my_R_rates, [[], 17])
            info_dump = {'carryoverFitness': rates_and_lnLk[-1], 'fullFitness':full_fitness_and_rates[-1],
                         'carryoverRates': rates_and_lnLk[:-1], 'fullRates':full_fitness_and_rates[:-1], 'ord':self.chrom_list,
                         'num_carryover':len(myUGaps[0]) }
            self.info = info_dump
            #print rates_and_lnLk
            #print subset_memo
            #print memo
            rates = rates_and_lnLk[:-1]
            myfitness = rates_and_lnLk[-1]
            self.Fitness = myfitness
            self.Rates = rates
            os.remove(fnm)
 def write_file_and_test_fitness_full_model(self):
     starttime = time.time()
     fnm = sha.sha(str(self.chrom_list)).hexdigest()
     self.tag = fnm
     b = open(fnm, 'w')
     for i in self.chrom_list:
         scaff = self.scaff_lookup[abs(i)]
         output = self.chrom_dict[scaff]
         if i < 0: output = list(reversed(output))
         for j in output: b.write(scaff+'\t'+j+'\n')
     b.close()
     myUGaps, my_R_rates = [[], len(self.chrom_list)], [0.1 for i in range(len(chrom_list))]
     rates_and_lnLk = fitness(fnm, my_R_rates, myUGaps)
     rates = rates_and_lnLk[:-1]
     myfitness = rates_and_lnLk[-1]
     self.Fitness = myfitness
     self.Rates = rates
     os.remove(fnm)
     self.runtime = time.time() - starttime
Example #5
0
 def write_file_and_test_fitness_full_model(self):
     starttime = time.time()
     fnm = sha.sha(str(self.chrom_list)).hexdigest()
     self.tag = fnm
     b = open(fnm, 'w')
     for i in self.chrom_list:
         scaff = self.scaff_lookup[abs(i)]
         output = self.chrom_dict[scaff]
         if i < 0: output = list(reversed(output))
         for j in output:
             b.write(scaff + '\t' + j + '\n')
     b.close()
     myUGaps, my_R_rates = [[], len(self.chrom_list)
                            ], [0.1 for i in range(len(chrom_list))]
     rates_and_lnLk = fitness(fnm, my_R_rates, myUGaps)
     rates = rates_and_lnLk[:-1]
     myfitness = rates_and_lnLk[-1]
     self.Fitness = myfitness
     self.Rates = rates
     os.remove(fnm)
     self.runtime = time.time() - starttime
Example #6
0
 def write_file_and_test_fitness_full_model(self):
     #THIS VERSION DOES NOT CARRY OVER ANY RATES. INSTEAD IT RUNS FULL LIKELIHOOD MODEL
     #USED ONLY ON CONTIG ORDERS THAT BREAK THEIR WAY INTO THE ELITE GROUP.
     #I.E. WE BURN THE COMPUTES TO GET THE LIKELIHOOD REALY ACCURATE ONLY ON THE MOST PROMISING CONTIG ORDERS
     starttime = time.time()
     fnm = sha.sha(str(self.chrom_list)).hexdigest()
     self.tag = fnm
     b = open(fnm, 'w')
     for i in self.chrom_list:
         scaff = self.scaff_lookup[abs(i)]
         output = self.chrom_dict[scaff]
         if i < 0: output = list(reversed(output))
         for j in output: b.write(scaff+'\t'+j+'\n')
     b.close()
     myUGaps, my_R_rates = [[], len(self.chrom_list)], [0.1 for i in range(len(chrom_list))]
     rates_and_lnLk = fitness(fnm, my_R_rates, myUGaps)
     rates = rates_and_lnLk[:-1]
     myfitness = rates_and_lnLk[-1]
     self.Fitness = myfitness
     self.Rates = rates
     os.remove(fnm)
     self.runtime = time.time() - starttime