Пример #1
0
	def load_from_file(self, tree_fname=None, virus_fname = None):
		if tree_fname is None: tree_fname = self.intermediate_tree_fname
		if os.path.isfile(tree_fname):
			self.tree = json_to_dendropy(read_json(tree_fname))
		if virus_fname is None: virus_fname = self.clean_virus_fname
		if os.path.isfile(virus_fname):
			self.viruses = read_json(virus_fname)
		if os.path.isfile(self.frequency_fname):
			self.frequencies = read_json(self.frequency_fname)
Пример #2
0
def main(tree, viruses):
	from seq_util import json_to_Bio_alignment
	from tree_util import json_to_dendropy
	print "--- Ancestral inference at " + time.strftime("%H:%M:%S") + " ---"
	aln = json_to_Bio_alignment(viruses)
	print "--- Set-up ancestral inference at " + time.strftime("%H:%M:%S") + " ---"
	anc_seq = ancestral_sequences(tree, aln, seqtype='str')
	anc_seq.calc_ancestral_sequences()
	anc_seq.cleanup_tree()
	out_fname = "data/tree_ancestral.json"
	return json_to_dendropy(anc_seq.T.seed_node)
Пример #3
0
def main(tree, viruses):
	from seq_util import json_to_Bio_alignment
	from tree_util import json_to_dendropy
	print "--- Ancestral inference at " + time.strftime("%H:%M:%S") + " ---"
	aln = json_to_Bio_alignment(viruses)
	print "--- Set-up ancestral inference at " + time.strftime("%H:%M:%S") + " ---"
	anc_seq = ancestral_sequences(tree, aln, seqtype='str')
	anc_seq.calc_ancestral_sequences()
	anc_seq.cleanup_tree()
	out_fname = "data/tree_ancestral.json"
	return json_to_dendropy(anc_seq.T.seed_node)
Пример #4
0
def test(params):
    from io_util import read_json
    from tree_util import json_to_dendropy, to_Biopython, color_BioTree_by_attribute
    from Bio import Phylo
    tree_fname = 'data/tree_refine_10y_50v.json'
    tree = json_to_dendropy(read_json(tree_fname))
    fm = fitness_model(tree, predictors=params['predictors'], verbose=2)
    fm.predict(niter=params['niter'])
    #btree = to_Biopython(tree)
    #color_BioTree_by_attribute(btree, 'fitness')
    #Phylo.draw(btree, label_func=lambda x:'')
    return fm
Пример #5
0
def test(params):
	from io_util import read_json
	from tree_util import json_to_dendropy, to_Biopython, color_BioTree_by_attribute
	from Bio import Phylo
	tree_fname='data/tree_refine_10y_50v.json'
	tree =  json_to_dendropy(read_json(tree_fname))
	fm = fitness_model(tree, predictors = params['predictors'], verbose=2)
	fm.predict(niter = params['niter'])
	#btree = to_Biopython(tree)
	#color_BioTree_by_attribute(btree, 'fitness')
	#Phylo.draw(btree, label_func=lambda x:'')
	return fm
Пример #6
0
def test():
    from Bio import Phylo
    tree = json_to_dendropy(read_json('auspice/tree.json'))
    print "calculate local branching index"
    T2 = get_average_T2(tree, 365)
    tau = T2 * 2**-4
    print "avg pairwise distance:", T2
    print "memory time scale:", tau
    calc_delta_LBI(tree, tau, datetime.datetime(2014, 1, 1))
    bioTree = to_Biopython(tree)
    color_BioTree_by_attribute(bioTree, 'date')
    Phylo.draw(bioTree)
Пример #7
0
def main():

    print "--- Tree LBI at " + time.strftime("%H:%M:%S") + " ---"

    tree = json_to_dendropy(read_json('data/tree_refine.json'))

    print "calculate local branching index"
    T2 = get_average_T2(tree, 365)
    tau = T2 * 2**-4
    print "avg pairwise distance:", T2
    print "memory time scale:", tau
    calc_LBI(tree, tau=tau)

    write_json(dendropy_to_json(tree.seed_node), "data/tree_LBI.json")
Пример #8
0
def main(params):
    import time
    from io_util import read_json
    from io_util import write_json
    from tree_util import json_to_dendropy, dendropy_to_json

    print "--- Start fitness model optimization at " + time.strftime("%H:%M:%S") + " ---"

    tree_fname = "data/tree_refine.json"
    tree = json_to_dendropy(read_json(tree_fname))
    fm = fitness_model(tree, predictors=params["predictors"], verbose=1)
    fm.predict(niter=params["niter"])
    out_fname = "data/tree_fitness.json"
    write_json(dendropy_to_json(tree.seed_node), out_fname)
    return out_fname
Пример #9
0
def main(params):
	import time
	from io_util import read_json
	from io_util import write_json	
	from tree_util import json_to_dendropy, dendropy_to_json
	
	print "--- Start fitness model optimization at " + time.strftime("%H:%M:%S") + " ---"

	tree_fname='data/tree_refine.json'
	tree =  json_to_dendropy(read_json(tree_fname))
	fm = fitness_model(tree, predictors = params['predictors'], verbose=1)
	fm.predict(niter = params['niter'])
	out_fname = "tree_fitness.json"
	write_json(dendropy_to_json(tree.seed_node), out_fname)
	return out_fname
Пример #10
0
def main(in_fname='data/tree_refine.json', tree=True):

	print "--- Mutational tolerance at " + time.strftime("%H:%M:%S") + " ---"
	viruses = read_json(in_fname)
	if tree:
		viruses = json_to_dendropy(viruses)

	assign_fitness(viruses)

	if tree:
		out_fname = "data/tree_tolerance.json"
		write_json(dendropy_to_json(viruses.seed_node), out_fname)
	else:
		out_fname = "data/virus_tolerance.json"
		write_json(viruses, out_fname)
	return out_fname, viruses
Пример #11
0
def main(in_fname='tree_refine.json', tree=True):

	print "--- Mutational tolerance at " + time.strftime("%H:%M:%S") + " ---"
	viruses = read_json(in_fname)
	if tree:
		viruses = json_to_dendropy(viruses)

	assign_fitness(viruses)

	if tree:
		out_fname = "tree_tolerance.json"
		write_json(dendropy_to_json(viruses.seed_node), out_fname)
	else:
		out_fname = "virus_tolerance.json"
		write_json(viruses, out_fname)
	return out_fname, viruses
Пример #12
0
def main(tree_fname = 'data/tree_refine.json'):

	print "--- Testing predictor evaluations ---"
	tree =  json_to_dendropy(read_json(tree_fname))

	print "Calculating epitope distances"
	calc_epitope_distance(tree)

	print "Calculating nonepitope distances"
	calc_nonepitope_distance(tree)

	print "Calculating LBI"
#	calc_LBI(tree)

	print "Writing decorated tree"
	out_fname = "data/tree_predictors.json"
	write_json(dendropy_to_json(tree.seed_node), out_fname)
	return out_fname