elif words[0] == "r": RANDOM_TYPE = int(words[1]) elif words[0] == "ls": TIME_FOR_SEARCH = float(words[1]) elif words[0] == "d": MIN_TRANSFER_DIST = int(words[1]) elif words[0] == "rd": RANDOM = int(words[1]) elif words[0] == "ts": THRESHOLD_CONSTRAINTS = float(words[1]) else: print "unused parameter (bad format):", p name_constraint_file = parameters[1] tree = script_tree.readTree(open(parameters[0], "r").readline()) constraints = open(name_constraint_file, "r").readlines() root = script_tree.getRoot(tree) print name_constraint_file def maximum_spearman(n): if n % 2 == 0: m = n / 2 return 2 * m * m else: m = (n - 1) / 2 return 2 * m * m + 2 * m
mots = fichier_ensembl[l].split() species = mots[1].split("_")[0].title() + "_" + mots[1].split( "_")[1] genes[mots[2]] = [ species, mots[3], int(mots[4]), int(mots[5]), mots[6] ] l = l + 1 adjacence_file = open(analysisDir + "/deco_adjacences_" + name, "w") gene_file = open(analysisDir + "/deco_genes_" + name, "w") restricted_genes = [] for line in tree_file: tree = script_tree.readTree(line) leaves = script_tree.getLeavesNames(tree) for l in leaves: restricted_genes.append(l) print len(tree_file), len(restricted_genes) #print restricted_genes def compare(x, y): #print x,y if genes[x][0] != genes[y][0]: return cmp(genes[x][0], genes[y][0]) elif genes[x][1] != genes[y][1]: return cmp(genes[x][1], genes[y][1])
import sys, script_tree, random, time, math, string MINIMUM_SUPPORT_WITHIN_A_FAMILY = 0.05 MINIMUM_FAMILY_SIZE = 5 #MAXIMUM_DIFFERENCE_WITH_PROFILE = 6000 OUTPUT_FILE_REC = "constraints_from_recs" OUTPUT_FILE_TRF = "constraints_from_transfers" parameters = sys.argv[1:] species_tree = script_tree.readTree(open(parameters[0], "r").readline()) extant_species = script_tree.getLeavesNames(species_tree) gene_tree_file = parameters[1] gene_trees = [] for gt in open(gene_tree_file, "r").readlines(): gene_trees.append(gt.strip()) nodes = script_tree.getNodes(species_tree) for n in nodes: script_tree.setLength(species_tree, n, 1.0) def distance_from(x, y): nodes = script_tree.getNodes(species_tree) for n in nodes: if script_tree.isLeaf(species_tree, n): name = script_tree.getName(species_tree, n) else: name = script_tree.getBootstrap(species_tree, n) if name == x: A = n if name == y:
import sys,script_tree,random,time,math,string MINIMUM_SUPPORT_WITHIN_A_FAMILY = 0.05 MINIMUM_FAMILY_SIZE = 5 #MAXIMUM_DIFFERENCE_WITH_PROFILE = 6000 OUTPUT_FILE_REC = "constraints_from_recs" OUTPUT_FILE_TRF = "constraints_from_transfers" parameters = sys.argv[1:] species_tree = script_tree.readTree(open(parameters[0],"r").readline()) extant_species = script_tree.getLeavesNames(species_tree) gene_tree_file = parameters[1] gene_trees = [] for gt in open(gene_tree_file,"r").readlines(): gene_trees.append(gt.strip()) nodes = script_tree.getNodes(species_tree) for n in nodes: script_tree.setLength(species_tree,n,1.0) def distance_from(x,y): nodes = script_tree.getNodes(species_tree) for n in nodes: if script_tree.isLeaf(species_tree,n): name = script_tree.getName(species_tree,n) else: name = script_tree.getBootstrap(species_tree,n) if name == x: A = n
genes = {} l = 0 while l < len(fichier_ensembl): if fichier_ensembl[l][:3] == "SEQ": mots = fichier_ensembl[l].split() species = mots[1].split("_")[0].title()+"_"+mots[1].split("_")[1] genes[mots[2]] = [species,mots[3],int(mots[4]),int(mots[5]),mots[6]] l = l + 1 adjacence_file = open(analysisDir+"/deco_adjacences_"+name,"w") gene_file = open(analysisDir+"/deco_genes_"+name,"w") restricted_genes = [] for line in tree_file: tree = script_tree.readTree(line) leaves = script_tree.getLeavesNames(tree) for l in leaves: restricted_genes.append(l) print len(tree_file),len(restricted_genes) #print restricted_genes def compare(x,y): #print x,y if genes[x][0] != genes[y][0]: return cmp(genes[x][0],genes[y][0]) elif genes[x][1] != genes[y][1]: return cmp(genes[x][1],genes[y][1]) else: return cmp(genes[x][2],genes[y][2])
nodes = script_tree.getNodes(tree) root = script_tree.getRoot(tree) for n in nodes: if not script_tree.isLeaf(tree, n): order.append(n) # print order order.sort(lambda x, y: cmp(script_tree.distanceFrom(tree, x, root), script_tree.distanceFrom(tree, y, root))) for i in range(len(order)): order[i] = script_tree.getBootstrap(tree, order[i]) return order with open((parameters[0])) as f1: for line_number, mt in enumerate(f1): tree = script_tree.readTree(mt.strip()) root = script_tree.getRoot(tree) # useful variables nodes = script_tree.getNodes(tree) leaves = script_tree.getLeavesNames(tree) root = script_tree.getRoot(tree) internal_nodes = [] order_tree = order_from_tree(tree) with open(parameters[1]) as f2: all_orders = f2.readlines() morders = random.sample(all_orders, 100) for morder in morders: order_input = morder.strip().split(",")
while len(pile) > 0 and (not (b in marques)): sommet = pile[-1] del pile[-1] voisins = g[sommet] for v in voisins: if not v in marques: marques.append(v) pile.append(v) if b in marques: return True else: return False tree = script_tree.readTree(open(parameters[0],"r").readline()) constraints = open(parameters[1],"r").readlines() root = script_tree.getRoot(tree) def value(order): index = {} for i in range(len(order)): index[order[i]] = i result = 0 for e in edge_keys: sommets = e.split(",") if index.has_key(sommets[0]) and index.has_key(sommets[1]) and index[sommets[0]] > index[sommets[1]]: result = result + edge[e] return result def optimisation_locale(order,duration):