def fast_calc_distances_task(alignment_file): rec = Alignment(alignment_file, 'phylip', True) rec.fast_compute_distances() result = dict(distances=rec.get_distances().tolist(), variances=rec.get_variances().tolist(), tree=rec.get_bionj_tree()) return result
def alignment(self): al = Alignment([self.collection[i] for i in self.indices]) al.fast_compute_distances() return al
def mrp_tree(self): trees = [ tree.newick if hasattr('newick', tree) else tree for tree in self.trees ] return Alignment().get_mrp_supertree(trees)
def calc_distances_task(pll_dict, alignment_file, model=None): rec = Alignment(alignment_file, 'phylip', True) freqs = smooth_freqs(pll_dict['partitions'][0]['frequencies']) alpha = pll_dict['partitions'][0]['alpha'] if model is None: rec.set_substitution_model('GTR' if rec.is_dna() else 'LG08+F') else: rec.set_substitution_model(model) rec.set_gamma_rate_model(4, alpha) rec.set_frequencies(freqs) if rec.is_dna(): rec.set_rates(pll_dict['partitions'][0]['rates'], 'ACGT') rec.compute_distances() result = dict(distances=rec.get_distances().tolist(), variances=rec.get_variances().tolist()) pll_dict['partitions'][0].update(result) pll_dict['nj_tree'] = rec.get_bionj_tree() return pll_dict
def simulate_task(n, model, frequencies, alpha, tree, rates=None): rec = Alignment() rec.set_substitution_model(model) rec.set_frequencies(frequencies) rec.set_gamma_rate_model(4, alpha) if rates is not None: try: rec.set_rates(rates, 'acgt') except RuntimeError: pass rec.set_simulator(tree) return rec.simulate(n)