def read_file(): locus_tag = product = protein_id = translation = gen = "N/A" start = stop = codon_start = table = strand = 0 Info = namedtuple('Info', 'locus, gene, protein_id, product, length') gene = Gene() for feature in record.features: if "CDS" in feature.type: for value in feature.qualifiers: if 'protein_id' in feature.qualifiers.keys(): protein_id = paran(feature.qualifiers['protein_id']) if 'translation' in feature.qualifiers.keys(): translation = paran(feature.qualifiers['translation']) if 'product' in feature.qualifiers.keys(): product = paran(feature.qualifiers['product']) if 'locus_tag' in feature.qualifiers.keys(): locus_tag = paran(feature.qualifiers['locus_tag']) if 'transl_table' in feature.qualifiers.keys(): table = paran(feature.qualifiers['transl_table']) if 'codon_start' in feature.qualifiers.keys(): codon_start = paran(feature.qualifiers['codon_start']) if 'gene' in feature.qualifiers.keys(): gen = paran(feature.qualifiers['gene']) strand = feature.strand start = feature.location.start.position stop = feature.location.end.position gene = Gene(locus_tag, gen, start, stop, codon_start, table, product, protein_id, translation, strand) # noqa data = Info(locus=locus_tag, gene=gen, protein_id=protein_id, product=product, length=stop - start) # noqa genome.add_node(data, gene) # noqa
def mutate_nodes(node_mutation_rate): # DONE global current_pop, global_genes, global_num_nodes for xi in range(len(current_pop)): if random.uniform(0, 1) < node_mutation_rate: model = current_pop[xi] genes = model.get_genes() ind = random.randint(0, len(genes)) num_nodes = current_pop[xi].get_num_nodes() # will use num nodes to set the new node to the new max number of nodes, and then disable one gene, and either duplicate 2 previously made genes, or add two new genes. num_nodes += 1 current_pop[xi].disable_gene(ind) # append a new gene to the global genes, and then add to the model using .add() as it is new to the model no matter what test = True # for i in range(len(global_genes)-1): # will check to see if two consecutive (inno nums) genes form a line to the highest node at that point (what happens if I sort it?) # # if node already exists # if global_genes[i].get_node_in() == genes[ind].get_node_in(): # if (global_genes[i+1].get_node_out() == genes[ind].get_node_out()) and (global_genes[i+1].get_inno_num() == global_genes[i].get_inno_num() + 1): # if they have consecutive inno nums, and the same output array = node_already_exists(model, genes, ind): if array[0]: current_pop[xi].add(global_genes[array[1]]) else: # creating a new gene because global does not have it pre_len = len(global_genes) n_num = current_pop[xi].get_num_nodes() + 1 current_pop[xi].set_num_nodes(n_num) # increases the number of local nodes by 1 global_genes.append(Gene(genes[ind].get_node_in(), n_num, global_genes[pre_len-1].get_inno_num()+1)) current_pop[xi].add(global_genes[pre_len]) if array[2]: current_pop[xi].add(global_genes[array[3]]) else: pre_len = len(global_genes) global_num_nodes += 1 global_genes.append(Gene(n_num, genes[ind].get_node_out(), global_genes[pre_len-1].get_inno_num()+1)) current_pop[xi].add(global_genes[pre_len])
def calculate_fitness_score(self, input_chromosome): if not isinstance(input_chromosome, Chromosome): raise TypeError( "Invalid argument - Only object of type Chromosome is expected." ) _data = input_chromosome.get_gene_sequence()[:] _non_attacking_queen = [0 for i in range(self._length_of_chromosome)] for index in range(len(_data)): current_point = Gene(index, _data[index]) # current_point.print("Current Queen :: ") attacking_queen = 0 current_attacking_points = self.get_all_attacking_points_from_dictionary( current_point) for i in range(len(_data)): if i == index: continue other_queen = Gene(i, _data[i]) for attacking_point in current_attacking_points: if other_queen.equals(attacking_point): attacking_queen = attacking_queen + 1 # other_queen.print("Attacking Queen :: ") _non_attacking_queen[index] = ((len(_data) - 1) - attacking_queen) # print(non_attacking_queen) input_chromosome.fitness_score = np.sum(_non_attacking_queen) return input_chromosome.fitness_score
def mutate_by_node_addition(self, history: List) -> None: """ Mutate the neural network by: 1. choose a random gene, then disable it 2. create 2 new connections: + 1 between starting_node of disabled gene and a new added node + 1 between the new added node and the ending_node of disabled gene """ # randomly add a connection between 2 genes if there are currently no connections between any genes if len(self.genes) == 0: self.add_connection(history) # enough mutation for now! return # pick a random gene to disable gene_to_disable = choice(self.genes) while gene_to_disable.starting_node is not self.nodes[ self.bias_node] and len(self.genes) != 1: gene_to_disable = choice(self.genes) gene_to_disable.enabled = False new_node_number = self.next_node self.nodes.append(Node(new_node_number)) self.get_node( new_node_number).layer = gene_to_disable.starting_node.layer + 1 self.next_node += 1 new_node = self.get_node(new_node_number) # add a new connection from starting_node of gene_to_disable to new node with weight 1 new_inno_num = self.get_inno_num(history, gene_to_disable.starting_node, new_node) self.genes.append( Gene(gene_to_disable.starting_node, new_node, 1, new_inno_num)) # add a new connection from new node to ending_node of gene_to_disable with weight of the disabled connection new_inno_num = self.get_inno_num(history, new_node, gene_to_disable.ending_node) self.genes.append( Gene(new_node, gene_to_disable.ending_node, gene_to_disable.weight, new_inno_num)) # add connection from the bias node to the new node with a weight of 0 new_inno_num = self.get_inno_num(history, self.get_node(self.bias_node), self.get_node(new_node_number)) self.genes.append( Gene(self.get_node(self.bias_node), new_node, 0, new_inno_num)) # ensure that if the layer of the new node is the same as the layer of the disabled gene's ending node then # the layers of all nodes with layer >= than the the new node's layer need to be incremented for node in self.nodes: if node.layer >= new_node.layer: node.layer += 1 # properly reconnect the nodes of the new neural network self.connect_nodes()
def test_birth_effects(): crew = initial.test_crew_infant() Gene.get_dominant(crew[0].genome[0]).birth_effects(crew[0]) Gene.get_dominant(crew[1].genome[0]).birth_effects(crew[1]) if crew[0].empathy != 1: print "Birth effects incorrectly applied to dominant child" if crew[1].empathy != -1: print "Birth effects incorrectly applied to recessive child"
def be_born(self, dad=None, mom=None): self.set_parents(dad, mom) last_name = mom.name.split(' ')[1] self.set_sex() self.set_name(last_name) self.inherit() for gene in self.genome: Gene.get_dominant(gene).birth_effects(self)
def test_adulthood_effects(): crew = initial.test_crew_adult() Gene.get_dominant(crew[0].genome[0]).adult_effects(crew[0]) Gene.get_dominant(crew[1].genome[0]).adult_effects(crew[1]) if crew[0].empathy != 1: print "Adult effects incorrectly applied to dominant adult" if crew[1].empathy != -1: print "Adult effects incorrectly applied to recessive adult"
def set_gene_subtree(self, g_parent: Gene, x_id, trunk: dict, subtree: dict, depth=1): """ 部分木を接ぎ木する """ # 左側の処理 self.g_len += 1 if self.g_len - 1 < x_id or self.g_len - 1 > x_id + len(subtree) - 1: g_id = g_parent.arg1_id g_child = copy.deepcopy(trunk[g_id]) else: st_id = subtree[self.g_len - x_id - 1].g_id g_child = copy.deepcopy(subtree[st_id]) g_child.g_id = self.g_len - 1 g_parent.arg1_id = self.g_len - 1 self.chrom_dict[g_child.g_id] = g_child if g_child.node_type == Gene.NODE_ARITHMETIC: self.set_gene_subtree(g_parent=g_child, x_id=x_id, trunk=trunk, subtree=subtree, depth=depth + 1) # 右側の処理 self.g_len += 1 if self.g_len - 1 < x_id or self.g_len - 1 > x_id + len(subtree) - 1: g_id = g_parent.arg2_id g_child = copy.deepcopy(trunk[g_id]) else: st_id = subtree[self.g_len - x_id - 1].g_id g_child = copy.deepcopy(subtree[st_id]) g_child.g_id = self.g_len - 1 g_parent.arg2_id = self.g_len - 1 self.chrom_dict[g_child.g_id] = g_child if g_child.node_type == Gene.NODE_ARITHMETIC: self.set_gene_subtree(g_parent=g_child, x_id=x_id, trunk=trunk, subtree=subtree, depth=depth + 1) # ルートの場合、chrom_dictのarg1, 2が未更新なのでここで更新 if depth == 1: self.chrom_dict[0] = g_parent # DEBUG """
def test_dominance(): gene1 = Gene() gene2 = Gene() gene1.locus = 0 gene2.locus = 0 gene2.condition = "dom" gene2.dominant = True # Gene.get_dominant(gene1) pair = [gene1, gene2] if Gene.get_dominant(pair).condition != "dom": print "Error, dominant gene isn't working"
def __crossover2genes(self, gene1, gene2): """Crossover two genes""" new_gene_n = 0 new_gene_a = [] new_gene_b = [] # Which part do you want to crossover? crossover_part = random.choice(["n", "b"]) if crossover_part == "n": # Average of two genes new_gene_n = math.ceil((gene1.n + gene2.n) / 2) for i in range(new_gene_n): if ((len(gene1.a) - 1) < i): new_gene_a.append(gene2.a[i]) elif ((len(gene2.a) - 1) < i): new_gene_a.append(gene1.a[i]) else: new_gene_a.append((gene1.a[i] + gene2.a[i]) / 2) new_gene_b = gene1.b[:] else: # Average of two genes for i in range(self.vocab_size): new_gene_b.append((gene1.b[i] + gene2.b[i]) / 2) new_gene_n = gene1.n new_gene_a = gene1.a[:] # normalization new_gene_a = [float(i) / sum(new_gene_a) for i in new_gene_a] new_gene_b = [float(i) / sum(new_gene_b) for i in new_gene_b] new_gene = Gene(new_gene_n, new_gene_a, new_gene_b) return new_gene
def init_models(num_models, input_num): global global_genes, global_num_nodes, current_pop global_num_nodes = input_num + 1 for i in range(num_models): model = Model() # model.add(Dense(output_dim=3, input_dim=input_num)) # model.add(Activation("sigmoid")) # model.add(Dense(output_dim=1)) # model.add(Activation("sigmoid")) for j in range(input_num): if len(global_genes) < input_num: global_genes.append(Gene(j, input_num, j)) model.add(global_genes[j]) model.set_num_nodes(input_num+1) # sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) # stochastic gradient descent, (lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) # model.compile(loss="mse", optimizer=sgd, metrics=["accuracy"]) current_pop.append(model) fitness.append(-100) if load_current_pool: current_pop = load_saved() for i in range(num_models): print(current_pop[i].get_weights())
def get_rsids(self): variants = {} genes = [ 'CFTR', 'CYP2C9', 'CYP4F2', 'IFNL3', 'TPMT', 'VKORC1', 'NUDT15', 'CYP2C19', 'CYP3A5', 'DPYD', 'SLCO1B1', 'UGT1A1', 'CYP2D6', 'CYP2B6', ] for g in genes: gene_definition = self.get_definition_file(g) gene = Gene(gene_definition, build=self.build, debug=self.debug) for v in gene.variants: if gene.variants[v].rsid != None: variants[gene.variants[v].rsid] = { "position": gene.variants[v].position, "ref": gene.variants[v].ref, "alt": gene.variants[v].alt } return variants
def __init__(self, _input_data_list): if not isinstance(_input_data_list, list): raise TypeError( "Invalid argument passed - only array of positive integers are allowed." ) if len(_input_data_list) < 2: raise ValueError( "Invalid argument passed - number of elements must be more than 2 in the input array." ) for _element in _input_data_list: if not isinstance(_element, int): raise TypeError( "Invalid argument passed - only array of positive integers are allowed." ) if _element < 0: raise TypeError( "Invalid argument passed - only array of positive integers are allowed." ) self._data_list = _input_data_list[:] for i in range(len(_input_data_list)): _point = Gene(i, _input_data_list[i]) self._gene_list.append(_point) _mutate_ratio = (len(set(_input_data_list)) / len(_input_data_list))
def generatePop(self, popLen, geneLen, eqString): length = geneLen for i in range(0, popLen): geneValues = [] for x in range(0,length): geneValues.append(random.randint(0,1)) self.population.append(Gene(geneValues, eqString))
def add_connection(self, history) -> None: """ Randomly add a connection between 2 nodes that are not yet connected. """ if self.fully_connected(): print("Cannot connect the neural network any further") return node1 = choice(self.nodes) node2 = choice(self.nodes) while node1.layer == node2.layer or node1.is_connected_to(node2): node1 = choice(self.nodes) node2 = choice(self.nodes) # we want node1's layer to be < node2's layer temp = None if node1.layer > node2.layer: temp = node2 node1 = node2 node2 = temp new_inno_num = self.get_inno_num(history, node1, node2) # add the new connection with a random weight self.genes.append(Gene(node1, node2, uniform(-1, 1), new_inno_num)) self.connect_nodes()
def test_constructor(self): try: gene_1 = Gene(4, "5") except TypeError: pass else: self.fail("Unknown Exception raised.")
def createGenes(self, gene=Gene(), n=1): for i in range(n): #Creates a new gene gene = deepcopy(gene) gene.randomise() #Adds the gene to the list self.genes.append(gene)
def loadGFF_UTR(self,fields,line,transcriptBeginEnd,GFF, transcripts,readOrder,genes): exonBegin=int(fields[3])-1 exonEnd=int(fields[4]) exonScore=fields[5] strand=fields[6] frame=fields[7] transcriptId=None rex=Rex() if(rex.find('transgrp[:=]\s*(\S+)',line)): transcriptId=rex[1] elif(rex.find('transcript_id[:=]?\s*"?([^\s";]+)"?',line)): transcriptId=rex[1] elif(rex.find('Parent=([^;,\s]+)',line)): transcriptId=rex[1] geneId=None if(rex.find('genegrp=(\S+)',line)): geneId=rex[1] elif(rex.find('gene_id[:=]?\s*"?([^\s\;"]+)"?',line)): geneId=rex[1] if(transcriptId is None): transcriptId=geneId if(geneId is None): geneId=transcriptId if(transcriptId is None): raise Exception(line+" : no transcript ID found") if(rex.find("(\S+);$",transcriptId)): transcriptId=rex[1] if(rex.find("(\S+);$",geneId)): geneId=rex[1] extra="" for i in range(8,len(fields)): extra+=fields[i]+" " if(exonBegin>exonEnd): (exonBegin,exonEnd)=(exonEnd,exonBegin) transcript=transcripts.get(transcriptId,None) if(not transcript): transcripts[transcriptId]=transcript= \ Transcript(transcriptId,strand) transcript.setStopCodons(self.stopCodons) transcript.readOrder=readOrder readOrder+=1 transcript.substrate=fields[0] transcript.source=fields[1] if(transcriptBeginEnd.get(transcriptId,None) is not None): (begin,end)=transcriptBeginEnd[transcriptId] transcript.setBegin(begin) transcript.setEnd(end) else: transcript.setBegin(exonBegin) transcript.setEnd(exonEnd) transcript.geneId=geneId gene=genes.get(geneId,None) if(gene is None): genes[geneId]=gene=Gene(); gene.setId(geneId) transcript.setGene(gene) exon=Exon(exonBegin,exonEnd,transcript) exon.extraFields=extra if(transcript.rawExons is not None): exon.frame=frame exon.score=exonScore exon.type=fields[2] transcript.rawExons.append(exon) elif(not transcript.exonOverlapsExon(exon)): exon.frame=frame exon.score=exonScore exon.type=fields[2] transcript.UTR.append(exon) # OK -- we sort later gene.addTranscript(transcript)
def restart_geneStep(self, PathtoOutput, OGofInterestFile, PathtoFiles, FileListOG, guidanceIter, seqcutoff, colcutoff, rescutoff, concatAlignment): OGswithTaxofInterestfile = open( self.PathtoPartialFiles + '/' + FileListOG, 'r') for line in OGswithTaxofInterestfile: self.OGList.append(line.strip()) NewGene = Gene(line, self) self.OGsofInterestList.append(NewGene) for gene in self.OGsofInterestList: gene.getAllSeqs() if not os.path.exists(self.PathtoOutput + '/Guidance/'): os.system('mkdir ' + self.PathtoOutput + '/Guidance/') gene.getSeqCodes() gene.fixGuidFile() # MACR ---- Here are some changes for Pipeline3 --------------- OGofInterestFile = self.OGofInterestFile.split('/')[-1] results_guidance = Utilities.iterGuidance( OGofInterestFile, line.strip(), self.PathtoOutput, self.guidanceIter, self.seqcutoff, self.colcutoff, self.rescutoff, self.mode) if results_guidance[1] == 'n': if self.concatAlignment == 'y': if self.mode != "nr": forConcatenation_path = results_guidance[ 0] + 'forConcatenation/' if not os.path.exists(forConcatenation_path): os.system('mkdir ' + forConcatenation_path) os.system('cp ' + results_guidance[0] + 'RAxML_bestTree.' + line.strip() + '_postguidance.fas ' + forConcatenation_path) codesDic = Utilities.build_codesDic( line.strip(), self.PathtoOutput) Utilities.renamefiles(line.strip(), results_guidance[0], codesDic) gene.removeParalogs(results_guidance[0], forConcatenation_path) else: codesDic = Utilities.build_codesDic( line.strip(), self.PathtoOutput) Utilities.renamefiles(line.strip(), results_guidance[0], codesDic) else: codesDic = Utilities.build_codesDic( line.strip(), self.PathtoOutput) Utilities.renamefiles(line.strip(), results_guidance[0], codesDic) else: codesDic = Utilities.build_codesDic( line.strip(), self.PathtoOutput) if codesDic: Utilities.renamefiles(line.strip(), results_guidance[0], codesDic)
def Create_genome(self): positions = 0 Genome = [] for i in range(0, self.nbr_gene): taille_gene = int(random.gauss(self.mean_size, 1)) Genome += [Gene(taille_gene, positions, i)] positions += taille_gene return (Genome)
def findGene(gene): searchResult = __geneFinder.find(Gene(gene)) if searchResult == GeneSearchResults.INVALID_GENE: return "Bad request", 400 elif searchResult == GeneSearchResults.FOUND: return "Valid Gen", 200 return "Not Found", 404
def add_node(self, gene_pool: GenePool, conditions: Conditions) -> Genome: """ Creates a new genome. Splits a randomly selected connection into two connections which share a new node The connection which starts at the original connections in_node is the in connection The connection which ends at the original connections out_node is the out connection Of the new connections, the in connection will have a weight of one The out connection will have the original connections weight The original connection is disabled :param conditions: Added for the node count :param gene_pool: The GenePool which provides the innovation numbers for the new connections, and the node number for the new node :return: Returns a copy of the current genome, but with a connection split with a new node added """ conditions.new_node_count += 1 splitting_gene: Gene = random.choice(self.genes) new_node = gene_pool.get_node_number(splitting_gene) in_gene = Gene(1.0, splitting_gene.in_node, new_node, 0, gene_pool=gene_pool) out_gene = Gene(splitting_gene.weight, new_node, splitting_gene.out_node, 0, gene_pool=gene_pool) new_genes = [] for gene in self.genes: if gene == splitting_gene: disabled_gene = gene.copy() disabled_gene.enabled = False new_genes.append(disabled_gene) else: new_genes.append(gene.copy()) new_genes.append(in_gene) new_genes.append(out_gene) return Genome(new_genes, self.input_size, self.output_size, gene_pool)
def linkMutate(self, forceBias): neuron1 = self.randomNeuron(False) neuron2 = self.randomNeuron(True) newLink = Gene() if neuron1 <= Inputs and neuron2 <= Inputs: #Both input nodes return if neuron2 <= Inputs: # Swap output and input temp = neuron1 neuron1 = neuron2 neuron2 = temp newLink.into = neuron1 newLink.out = neuron2 if forceBias: newLink.into = Inputs if self.contains_link(newLink): return newLink.innovation = self.pool.new_innovation() newLink.weight = random.random() * 4 - 2 self.genes.append(newLink)
def setInterestList(self): # JG - to allow running of different Pipelines, output files names have to be different #get the list of OGs for this pipeline and build gene instances for line in open(self.OGofInterestFile,'r'): self.OGList.append(line.strip()) NewGene = Gene(line,self) self.OGsofInterestList.append(NewGene)
def __init__(self, file, debug=False): self.file = file self.debug = debug # Load the data into a global object self.data = self.get_data() self.gene = Gene(self.file, debug=self.debug) self.run()
def load_test_genes(self): genes = [] data = open(self.test_genes_File) data.readline() for gene_array in data.readlines()[:100000]: idx, *gene, label = gene_array.strip().split(',') gene = Gene(np.array(gene, dtype='float32')) genes.append((gene, label)) return genes
def loadFile(self, filename, env): file = open(filename, "r") self.__init__(env) self.generation = int(file.readline().replace("\n", "")) self.maxFitness = int(file.readline().replace("\n", "")) #gui.settext(5, 8, maxFitnessLabel, "Max Fitness. " .. math.floor(pool.maxFitness)) numSpecies = int(file.readline().replace("\n", "")) for s in range(0, numSpecies): species = Species() self.species.append(species) species.topFitness = float(file.readline().replace("\n", "")) species.staleness = int(file.readline().replace("\n", "")) numGenomes = int(file.readline().replace("\n", "")) for g in range(0, numGenomes): genome = Genome(self) species.genomes.append(genome) genome.fitness = float(file.readline().replace("\n", "")) genome.maxneuron = int(file.readline().replace("\n", "")) line = file.readline().replace("\n", "") while line != "done": genome.mutationRates[line] = float(file.readline().replace( "\n", "")) line = file.readline().replace("\n", "") numGenes = int(file.readline().replace("\n", "")) for n in range(0, numGenes): gene = Gene() genome.genes.append(gene) enabled = 0 line = file.readline() data = [] for x in [x for i, x in enumerate(line.split(" "))]: try: data.append(int(x)) except ValueError: data.append(float(x)) gene.into, gene.out, gene.weight, gene.innovation, enabled = data gene.enabled = enabled == 1 file.close() while self.fitnessAlreadyMeasured(): self.nextGenome() self.initializeRun() self.currentFrame = self.currentFrame + 1
def __init__(self, is_mutant=False): self.chrom_dict = {} # 遺伝子IDをキー、遺伝子オブジェクトをバリューとした辞書 self.g_len = 1 mutant_single_node_det = np.random.rand() if is_mutant == True and mutant_single_node_det < GP.MUTANT_SINGLE_NODE_RATE: # 突然変異で単一ノードになった場合 g_single = Gene(g_id=0, node_type=Gene.NODE_OPERAND) self.chrom_dict[g_single.g_id] = g_single else: # ルートノード g_rn = Gene(g_id=0, node_type=Gene.NODE_ARITHMETIC) self.chrom_dict[g_rn.g_id] = g_rn # 枝葉を再帰的に追加していく self.append_gene(g_parent=g_rn, depth=1, is_mutant=is_mutant) # Gtypeは遺伝子ID,遺伝子コードのリスト self.gtype = self.get_GType()
def start_genomes(self, gene_pool: GenePool, conditions: Conditions) -> List[Genome]: """ Creates the starter genomes :param conditions: The conditions to use when creating new genes :param gene_pool: The gene pool to update with the starter genomes :return: A list of starter genomes """ in_size = self.simulation.get_data_size() out_size = self.simulation.get_controls_size() for in_ in range(1, in_size + 1): gene_pool.node_depths[in_] = conditions.app_start_node_depth for out_ in range(0, -out_size, -1): gene_pool.node_depths[out_] = conditions.app_end_node_depth starter_genomes = [] starter_genes = [] for in_ in range(1, in_size + 1): for out_ in range(0, -out_size, -1): gene = Gene(random.random() * (self.conditions.gene_max_weight - self.conditions.gene_min_weight) + self.conditions.gene_min_weight, in_, out_, 0, gene_pool=gene_pool) starter_genes.append(gene) for i in range(self.conditions.population_size): new_genes = [gene.copy() for gene in starter_genes] for gene in new_genes: gene.weight = (random.random() * (self.conditions.gene_max_weight - self.conditions.gene_min_weight) + self.conditions.gene_min_weight) starter_genomes.append( Genome(new_genes, in_size, out_size, gene_pool)) return starter_genomes
def __init__(self, n_codon): self.g_array = [] # 遺伝子コードの配列 self.d_array = [] # 遺伝子数値の配列 self.n_codon = n_codon # コドンの総数 self.ge = GESetting() for locus in range(self.n_codon): g = Gene() self.g_array.append(g) self.d_array.append(g.d_code)
def makeGene(self,root): gene=Gene() root["object"]=gene gene.ID=root["extra"]["ID"] children=root.get("children",None) if(children is None): return gene for child in children: obj=self.labelStructure(child) if(obj is None): continue if(type(obj)==Transcript): gene.addTranscript(obj) obj.gene=gene obj.geneId=gene.getId() extra=root["extra"] gene.extraFields="" for key in extra: gene.extraFields+=key+"="+extra[key]+";" return gene
def __init__(self, track): self.track = track Gene.__init__(self) self.bachian = False
def become_adult(self): print self.name + " crew id:" + str(self.crew_id) + " has become an adult" self.adult = True for gene in self.genome: Gene.get_dominant(gene).adult_effects(self)
def __init__(self, track): self.track = track Gene.__init__(self)