def write_file_and_test_fitness_full_model(self, error_file, intrascaff_file, f2_file): #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)-1], [0.01 for i in range(len(chrom_list)-1)] rates_and_lnLk = fitness(fnm, my_R_rates, myUGaps, lines_file = f2_file, error_rates = error_file, intra_scaff_rates_file=intrascaff_file) 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_full_model(self, error_file, intrascaff_file, f2_file): # 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) - 1], [0.01 for i in range(len(chrom_list) - 1)] rates_and_lnLk = fitness( fnm, my_R_rates, myUGaps, lines_file=f2_file, error_rates=error_file, intra_scaff_rates_file=intrascaff_file ) 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, error_file, intrascaff_file, f2_file): #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 if fnm in self.memo: self.Fitness = self.memo[fnm][0] self.Rates = self.memo[fnm][1] self.runtime = time.time() - starttime 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, lines_file = f2_file, error_rates = error_file, intra_scaff_rates_file=intrascaff_file) rates = rates_and_lnLk[:-1] myfitness = rates_and_lnLk[-1] self.Fitness = myfitness self.Rates = rates os.remove(fnm) self.runtime = time.time() - starttime