Esempio n. 1
0
def save_orth(prots=None,ncpu=1,out_file=None,inp_orth=None):
	if inp_orth != None:
		print 'using following file as orthologs', inp_orth
		inp_orth=pick.load(open(inp_orth))
		return inp_orth
	pg=PanGenomer(prots,ncpu)
	print 'now finding orthologs... it may take some time..'
	pg.run()
	orthologs=pg.orthologs
	if out_file != None:
		dumper=open(out_file,'w')
		pick.dump(orthologs, dumper)
	return orthologs
Esempio n. 2
0
		draft.build()
		bcl.launch_BLAST(fasta,all_fasta,out)
		#
		#Parse di BLASTall e costruzione grafo
		#parsed=parse_blast(out)
		parsed=parse_blast_bord(out,hit_thr,bord_thr,id_perc_thr)
		adj_list=build_adj_list(parsed,draft,bord_thr)
		network=build_network(adj_list)
		#
		#Scrivi file gexf e appendi alla lista dei network
		graph_name=output_folder+draft.graph_name
		nx.write_gexf(network,graph_name)
		networks[draft.name]=graph_name
	#predizione proteine e BBH seriale
	prots=synteny.predictor(fastas)
	pg=PanGenomer(prots,opts.ncpu)
	print 'now finding orthologs... it may take some time..'
	pg.run()
	orthologs=pg.orthologs
	relations={}
	#organizzazione delle relazioni: contigui di uno stesso genoma che condividono ortologhi con contigui di altri genomi sono raggruppati
	for k in orthologs:
		for v1 in orthologs[k]:
			for v2 in orthologs[k]:
				if v1==v2:continue
				draft1,contig1=from_gene_to_contig(v1)
				draft2,contig2=from_gene_to_contig(v2)
				relations[draft1],relations[draft2]=relations.get(draft1,{}),relations.get(draft2,{})
				relations[draft1][contig2]=relations[draft1].get(contig2,[])
				relations[draft2][contig1]=relations[draft2].get(contig1,[])
				if contig1 not in relations[draft1][contig2]: