import InputProcessor import SoftmaxLayer ''' SemiEnd to end BOWIMG model (excluding preprocessing) ''' if __name__ == "__main__": #files that depend on set #constant files mostFreqAnswersFile = '/home/jwong/Documents/LinuxWorkspace/Visual-Question-Answering/resources/1000MostFreqAnswers.csv' vocabBOWfile = '/home/jwong/Documents/LinuxWorkspace/Visual-Question-Answering/resources/BOWdimensions.csv' #1-25 train batches #miniBatchPath = '/media/jwong/Transcend/VQADataset/TrainSet/trainMiniBatches/TrainMiniBatch' print('Loading files...') questionFile = '/media/jwong/Transcend/VQADataset/TrainSet/Questions_Train_mscoco/Preprocessed/processedOpenEnded_trainQns.json' imageFile = '/media/jwong/Transcend/VQADataset/TrainSet/ExtractedImageFeatures/VQAImgFeatures_Train.json' trainProcessor = InputProcessor.InputProcessor(questionFile, vocabBOWfile, imageFile, mostFreqAnswersFile) testQnFile = '/media/jwong/Transcend/VQADataset/ValSet/Questions_Val_mscoco/preprocessedValQnsOpenEnded.json' testImgFile = '/media/jwong/Transcend/VQADataset/ValSet/VQAImgFeatures_Test.json' testProcessor = InputProcessor.InputProcessor(testQnFile, vocabBOWfile, testImgFile, mostFreqAnswersFile) Decider = SoftmaxLayer.SoftmaxLayer() Decider.runSoftmaxLayer(trainProcessor, testProcessor) print('Done.')
dest="pdb_name", required=True, help="The path name to file location under PDB_Struct dir or the PDB ID" ) args = parser.parse_args() return args # Retrieve file the file object cli_args = cli_options() file_to_process = cli_args.filename pdb_name = cli_args.pdb_name # generate the group: [id, seq], ... dictionary group_id_seq = ip.InputProcessor(file_to_process).process_input() # extract sequence from PDB pdb_ds = pp.PdbParser(pdb_name).pdb_processing() # generate a list of fasta files for multiple alignment multi_align_fasta_files = fg.FastaGen(group_id_seq, pdb_ds).process_seqs() # perfrom multiple alignment for each file all_aligned = OrderedDict() for fasta in multi_align_fasta_files: aligned_key = fasta.split('.')[0] all_aligned[aligned_key] = ma.MultiAlign( clustal_input=fasta, clustal_output='out_{}'.format(fasta), clustalw='clustalw2').perform_alignment() # print(all_aligned) # OrderedDict([('group_1', {seq_id: seq}), # ...
def startGame(self): n = Network() self.teamID = int(n.getData()) playerString = "TEAMID: " + str(self.teamID) self.guiClient = self.gui.render(playerString, False, (225, 225, 250)) interface = Interface.Interface(self.screen, self.teamID, self.gui) self.inProc = InputProcessor.InputProcessor(self.teamID, interface.globalActions) self.resources = {'$': 50, 'ß': 0, '¶': 8} self.makeResText() buildingSpacing = (self.screenHeight * 2 / 3) / 8 for b in range(7): xMod = -0.00065 * ( (b * buildingSpacing) - self.screenHeight / 3)**2.0 + 96 self.buildingList[0].append( Buildings.EmptySpace(0, xMod, b * buildingSpacing + 72, self.gui)) self.buildingList[1].append( Buildings.EmptySpace(1, self.screenWidth - xMod, b * buildingSpacing + 72, self.gui)) # dictionary formatting: # { unitID : [teamID, x, y, health, imageIndex, direction, targetX, currentState, healthMod, unitType] } # currentState: 0 is idle, 1 is moving, 2 is attacking depthSortTimer = 8 moneyTimer = 60 peopleTimer = 600 while self.started: prevResources = self.resources.copy() for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_t: ssName = "screenshot.png" pygame.image.save(self.screen, ssName) if event.key == pygame.K_ESCAPE: sys.exit() # draw the background self.drawBG(self.screen) # per server communication or whatever: # signature = self.teamID # sent buildings list setup self.buildingsToSend = [ b.sprID for b in self.buildingList[self.teamID] ] # sent unit making list setup unitsToSend = [ b.queuedUnit for b in self.buildingList[self.teamID] if b.queuedUnit ] # reset queued units for b in self.buildingList[self.teamID]: b.queuedUnit = None selections = self.inProc.updateSelection(self.unitList, self.screen) self.inProc.updateBuildingSelection(self.buildingList, pygame.mouse) self.inProc.checkButtonsClicked(pygame.mouse, self.resources) states = -1 for i in range(len(interface.globalActions)): b = interface.globalActions[i] if b.clicked: states = i self.inProc.drawSelection(self.screen, self.unitList) # print(selections) keys = pygame.key.get_pressed() # print([(i, v) for i, v in enumerate(keys) if v == 1] toSend = { "keys": keys, "selections": selections, "buildings": self.buildingsToSend, "units": unitsToSend, "moveState": states } n.send(self.jEncode(toSend)) # ^ SEND STUFF v PROCESS RECEIVED STUFF self.receivedData = self.jDecode(n.getData()) # print([(uID, params[3], params[4], params[7]) for uID, params in self.receivedData.items()]) for unitID, paramList in self.receivedData['units'].items(): unitID = int(unitID) found = False u = None for un in self.unitList: if un.unitID == unitID: found = True u = un break if not found: u = self.spawnUnit(unitID, paramList[9], paramList[0], paramList[1], paramList[2], paramList[8]) # make spawning effect self.fxList.append( Effects.SpawnEffect(paramList[1], paramList[2])) u.x = paramList[1] u.y = paramList[2] u.health = paramList[3] u.imageIndex = paramList[4] u.direction = paramList[5] u.updateSprites(paramList[6]) if paramList[7] == 0: u.sprite = u.spriteIdle elif paramList[7] == 1: u.sprite = u.spriteMoving elif paramList[7] == 2: u.sprite = u.spriteAttack if u.health <= 0: self.unitList.remove(u) for u in self.unitList: if str(u.unitID) not in self.receivedData['units']: u.selected = False self.unitList.remove(u) # this updates enemy building sprites based on their upgrades self.updateBuildings() # money gain timers here if moneyTimer > 0: moneyTimer -= 1 else: moneyTimer = 60 self.resources['$'] += 1 self.makeResText() if peopleTimer > 0: peopleTimer -= 1 else: peopleTimer = 600 self.resources['¶'] += 1 self.makeResText() if depthSortTimer > 0: depthSortTimer -= 1 else: depthSortTimer = 8 self.unitList.sort(key=lambda x: x.y * -1, reverse=True) for bL in self.buildingList: for b in bL: b.action(self.screen) i = 0 for b in self.buildingList[self.teamID]: # 'harvests' resources generated by buildings if b.generatedResources[1] > 0: self.resources[ b.generatedResources[0]] += b.generatedResources[1] b.generatedResources[1] = 0 if b.markedForDelete: self.buildingList[self.teamID][i] = b.upgradeBuilding if self.inProc.selectedBuilding == b: print("updating selection to new building") b.selected = False self.buildingList[self.teamID][i].selected = True self.inProc.selectedBuilding = self.buildingList[ self.teamID][i] i += 1 for u in self.unitList: u.draw(self.screen) for f in self.fxList: f.draw(self.screen) for f in self.fxList: if f.markedForDelete: self.fxList.remove(f) del f # updates rendered resources text of the player self.updateResText(prevResources) # self.inProc.draw(self.screen) self.screen.blit(self.guiClient, (22, 22)) interface.draw(self.screen) self.inProc.drawSelectionInterface(self.screen) # draw the resources of the player ((somewhere)) self.screen.blit(self.resourceGui, (self.screenWidth - 280, self.screenHeight - 24)) self.clock.tick(60) pygame.event.pump() if self.screenScalingEnabled: self.scaledScreen.blit(pygame.transform.scale2x(self.screen), (0, 0)) else: self.scaledScreen.blit(self.screen, (0, 0)) pygame.display.update()