Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main(organism, gene_id):
write_fasta = False
cache_dir = os.path.join(os.getcwd(), "cache")
ensembl_rest = EnsemblComparaRest(cache_dir)
orthologs = ensembl_rest.orthologs(organism, gene_id)
compara_tree = ensembl_rest.compara_tree(organism, gene_id)
compara_tree = '(' + compara_tree[:-1] + ');'
tree_rec = newick.parse_tree(compara_tree.strip())
d_vis = DistanceVisitor()
tree_rec.dfs_traverse(d_vis)
tree_proteins = [l.identifier for l in tree_rec.leaves]
orthologs = [(organism, gene_id)] + orthologs
out_recs = []
root_id = None
all_items = []
for o_organism, o_id in orthologs:
transcripts = ensembl_rest.transcripts(o_organism, o_id)
tx, p = [(tx, p) for (tx, p) in transcripts if p in
tree_proteins][0]
cur_item = EnsemblComparaTranscript(o_organism, o_id, tx, p)
if root_id is None:
root_id = p
cur_item.distance = networkx.dijkstra_path_length(d_vis.graph,
"'%s'" % root_id, "'%s'" % p)
def newickToTree(s):
from newick import parse_tree #http://www.brics.dk/~mailund/newick.html
t = parse_tree(s)
v = NewickVisitor()
t.dfs_traverse(v)
A = v.getAdjMap()
return A