complexesToRoles[complexId].append(roleId) # Create a dictionary to map a reaction to a list of complexes as defined in the template. reactionsToComplexes = dict() for index in range(len(template['reactions'])): reactionId = template['reactions'][index]['id'] if len(template['reactions'][index]['templatecomplex_refs']) > 0: reactionsToComplexes[reactionId] = list() for complexRef in template['reactions'][index][ 'templatecomplex_refs']: # Complex ID is last element in reference. reactionsToComplexes[reactionId].append( complexRef.split('/')[-1]) # Create a worker for running the algorithm. worker = ProbAnnotationWorker(genome['id']) # Run the probabilistic annotation algorithm. try: # Convert the features in the genome object to a fasta file. fastaFile = worker.genomeToFasta(genome['features']) # Run blast using the fasta file. blastResultFile = worker.runBlast(fastaFile) # Calculate roleset probabilities. rolestringTuples = worker.rolesetProbabilitiesMarble(blastResultFile) # Calculate per-gene role probabilities. roleProbs = worker.rolesetProbabilitiesToRoleProbabilities( rolestringTuples)