def _insert(self): """ Insert records """ if self.debug: print " Creating BD for %s" % self.test_file + FILE_EXT_JSON file_list = [self.test_file + FILE_EXT_JSON] else: file_list = Files.get_file_list(self.generated_folder) for json_file in file_list: if not Files.file_exists(self.generated_folder + json_file): continue data = json.load(open(self.generated_folder + json_file)) sub_tables = OrderedDict() for (_key, _value) in data.items(): # images are not saved in the db if _key == __classmap__[self.name].FIELD_IMAGE: del data[_key] continue if isinstance(_value, dict): sub_tables[_key] = data[_key] del data[_key] del _key self._parse_data("", data, sub_tables)
def save(self): data = self._get_header() + \ self._index + \ ''.join(self._index_data) + \ ''.join(self._data) Files.write_binary(data, self.get_bin_filename(), DataFile.SAVE_FOLDER)
def __init__(self, Player, Scene, Game_State): #self, Class self.stumbles = 0 self.attack_spells = [Player.Fire["Name"], Player.Ice["Name"], Player.Lightning["Name"], Player.Water["Name"], Player.Wind["Name"], Player.Drain["Name"]] self.duration_spells = [Player.Curse["Name"], Player.Sand["Name"], Player.Regen["Name"], Player.Protect["Name"], Player.Shell["Name"]] self.items = Player.Inventory self.yes = ["Yes", "Yup", "Yeah", "Ye", "Correct", "Y", "Sure", "Always", "Ok", "Fine"] self.no = ["No", "Nope", "Nah", "Negative", "Incorrect", "N", "Never", "Pass"] self.attack = ["Attack", "Hit", "Damage", "Kill", "Hurt", "Smack", "Slap", "Strike", "Whack", "Bludgeon", "Fight"] self.exit = ["Back", "Exit", "Return", "Cancel", "Leave"] self.up = ["Up", "Ascend"] self.down = ["Down", "Descend"] self.resume = ["Continue", "Resume"] self.recipes = ["Recipe", "Recipes", "Instructions"] self.inventory = ["Items", "Inventory", "Potions", "Ethers", "Elixirs"] self.examine = ["Examine", "Inspect", "Observe", "Look", "Check"] self.spellbook = ["Magic", "Spells", "Spell", "Spellbook"] self.help = ["Help", "Commands", "Terms", "Glossary", "Words"] self.status = ["Status", "Stats", "Self", "Scan"] self.save = ["Save"] self.Cheat = "Pumpkin Eater" self.bools = {"Yes": False, "No": False, "Attack": False, "Exit": False, "Up": False, "Down": False, "Resume": False, "Inventory": False, "Examine": False, "Spellbook": False, "Help": False, "Status": False, "Recipes": False} file = Files() self.path = file.doc_path file.__delete__() self.Scene = Scene self.Game_State = Game_State
def downloading(self, download_callback=None, download_complete=print): files = Files() while True: if not files.empty(): download_file = files.get() download_from_ip = download_file.file_from.ip download_from_card = download_file.file_from.essid download_url = 'http://%s/cgi-bin/wifi_download?fn=%s' % ( download_from_ip, download_file.get_path()) download_to = Storage().dir() if self.separate: download_to = os.path.join(download_to, download_from_card) if not os.path.exists(download_to): os.mkdir(download_to) download_to = os.path.join(download_to, download_file.get_name()) try: urllib.urlretrieve(download_url, download_to, download_callback) Storage().add(File(download_file.get_name())) if download_complete: download_complete(download_to) except urllib.ContentTooShortError: print('Oops!!') time.sleep(0.1)
def test_file_exists(self): """ Test file_exists() """ Files.write("empty", "file1.txt", TEST_PATH) self.assertTrue(Files.file_exists(TEST_PATH + "file1.txt")) Files.delete_files(TEST_PATH + "file1.txt")
def __init__(self, name): #self, "name" name = name.title() self.Info = {"Name": name} file = Files() self.path = file.doc_path file.__delete__() source = xlrd.open_workbook(self.path) Sheet = source.sheet_by_index(6) row = 0 while Sheet.cell(row, 0).value != self.Info["Name"]: row += 1 if str(Sheet.cell(row, 0).value) == self.Info["Name"]: #-------------------------------------------------------------- # Set Values #-------------------------------------------------------------- #Set 'Key Item' status self.Info["Key"] = Sheet.cell(row, 1).value #Set Consumable status self.Info["Consumable"] = Sheet.cell(row, 2).value #Set Value if Sheet.cell(row, 3).value: self.Info["Value"] = Sheet.cell(row, 3).value #Set Affected Stats if Sheet.cell(row, 4).value: if ', ' in Sheet.cell(row, 4).value: stats = Sheet.cell(row, 4).value self.Info["Restores"] = stats.split(', ') else: self.Info["Restores"] = Sheet.cell(row, 4).value #Set Ingredient Status self.Info["Ingredient"] = Sheet.cell(row, 5).value
def test_can_exclude_file(self): """ Test can_include_file() """ Files.write("some content", "file1.txt", TEST_PATH) file_list = Files.get_file_list(TEST_PATH, ["file1.txt"]) self.assertTrue(len(file_list) == 0) Files.delete_files(TEST_PATH + "file1.txt")
def test_get_raw_contents(self): """ Test get_raw_contents() """ Files.write("some content", "file1.txt", TEST_PATH) content = Files.get_raw_contents(TEST_PATH + "file1.txt") self.assertTrue(content == "some content") Files.delete_files(TEST_PATH + "file1.txt")
def delete_cache(self): """ Delete cache files for a site """ if self.debug: print " Deleting %s files " % self.name Files.delete_folder(self.generated_folder) Files.delete_folder(self.image_folder)
def listener_thread(self): files = Files() sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((self.ip, 5566)) while self.thread_listener: message = sock.recv(1024) new_files = message.split('\00') for x in new_files: if x: files.put(File(str(x[1:]), self))
def download_image(self, url, filename): """ Download an image and save it to a location :param url: The url :param filename: The filename """ if self.debug: print " Downloading: %s\n => %s" % \ (url, self.image_folder + filename) if path.isfile(self.image_folder + filename): return data = Download.download_page(url) Files.write(data, filename, self.image_folder)
def __init__( self, database, settings, suppress_exceptions = False ): """ Create a new Root object with the given settings. @type database: controller.Database @param database: database to use for all controllers @type settings: dict @param settings: CherryPy-style settings @rtype: Root @return: newly constructed Root """ self.__database = database self.__settings = settings self.__users = Users( database, settings[u"luminotes.http_url"], settings[u"luminotes.https_url"], settings[u"luminotes.support_email"], settings[u"luminotes.payment_email"], settings[u"luminotes.rate_plans"], settings[u"luminotes.download_products"], ) self.__groups = Groups( database, self.__users ) self.__files = Files( database, self.__users, settings[u"luminotes.download_products"], settings[u"luminotes.web_server"], ) self.__notebooks = Notebooks( database, self.__users, self.__files, settings[ u"luminotes.https_url"] ) self.__forums = Forums( database, self.__notebooks, self.__users ) self.__blog = Forum( database, self.__notebooks, self.__users, u"blog" ) self.__suppress_exceptions = suppress_exceptions # used for unit tests
def main_menu(self, Player, Controller, Scene): Scene.clear_screen() self.menu = True Scene.screen.addstr( Scene.line, 1, "-----------------------------------------------------------------------------------------------------------------------" ) Scene.line += 1 Scene.screen.addstr( Scene.line, 1, " Spell Caster", Scene.cyan) Scene.screen.addstr(Scene.line, 110, "Ver: ") Scene.screen.addstr("2.01", Scene.cyan) Scene.line += 1 Scene.screen.addstr( Scene.line, 1, "-----------------------------------------------------------------------------------------------------------------------" ) Scene.line += 1 #Type your selection Scene.screen.addstr( Scene.line, 1, Scene.print_header(Scene.make_line(92, "Menu", {}))) Scene.line += 3 selection = [ "About", "New Game", "Continue", "Options", "Cheats", "Credits", "Quit" ] file = Files() for x in range(len(selection)): if selection[x] != "Continue" and selection[x] != "Options": Scene.screen.addstr(Scene.line, 1, "* ", Scene.yellow) Scene.screen.addstr(selection[x]) Scene.line += 1 else: if file.Continue() == True: Scene.screen.addstr(Scene.line, 1, "* ", Scene.yellow) Scene.screen.addstr(selection[x]) Scene.line += 1 else: continue self.loop = True while self.loop == True: Controller.line = Scene.line Controller.get_command(Player, file, self, Scene) file.__delete__()
def is_valid_site(site): """ Check if the site is valid :param site: The site :return boolean """ sites = Files.get_file_list(SITE_PATH, [".urls"]) return site + ".py" in sites
def test_get_file_list(self): """ Test get_file_list() """ Files.write("empty", "file1.txt", TEST_PATH) Files.write("empty", "file2.txt", TEST_PATH) file_list = Files.get_file_list(TEST_PATH) self.assertTrue(len(file_list) == 2) self.assertTrue(file_list[1] == "file2.txt") Files.delete_files(TEST_PATH + "file1.txt") Files.delete_files(TEST_PATH + "file2.txt")
def kbd_listener(q: Queue, music_folder: str): files = Files(os.path.expanduser(music_folder)) loop = True while loop: tags = files.get_tag_dirs() print_menu(tags) kbd_input = "" while kbd_input == "": kbd_input = input("> ") if kbd_input == "q": print("Stopping kbd_listener") loop = False q.put(kbd_input) elif is_int(kbd_input) and 0 < int(kbd_input) <= len(tags): q.put(tags[int(kbd_input) - 1])
def download(self): """ Download HTML web pages """ if self.debug: print " Downloading: %s" % self.test_file + FILE_EXT_HTML url_list = [self.base_url + self.test_file + FILE_EXT_HTML] else: url_list = Files.get_raw_contents(self.name + ".urls", "./") for web_file in url_list: cached_file = web_file.replace(self.base_url, "") if not Files.file_exists(self.download_folder + cached_file): data = Download.download_page(web_file) Files.write(data, cached_file, self.download_folder) elif self.debug: print " File %s already exists" % (self.download_folder + cached_file)
def _import_csv(self): """ Import CSV file to a list """ if not Files.file_exists(self._input_file): return "" with codecs.open(self._input_file, 'rb', encoding='utf-8') as data: self._raw_data = list(csv.reader(data)) self._raw_data.sort(key=operator.itemgetter(0))
def main(): music_folder = os.path.expanduser("~/Music/SamPi/") files = Files(music_folder) audio_files = [] print("init MFRC522") reader = SimpleMFRC522() playing = None none_counter = 0 while True: # read tag id = reader.read_id_no_block() # no tag if not id: none_counter += 1 if none_counter > 1 and playing: print("stopping playback") playing = None Audio.stop() else: none_counter = 0 # new tag detected if playing != id: none_counter = 0 Audio.stop() audio_files = files.get_audio_files(str(id)) audio_files.sort() if audio_files: print("playing {}".format(id)) playing = id audio_files = Audio.play(audio_files) else: print("unknown tag:", id) # continue playback elif audio_files: audio_files = Audio.play(audio_files)
def test_something(self, mock_new_log): # self.client = MongoClient("mongodb://localhost") self.update = mock.MagicMock() self.funcname = mock.MagicMock() self.update.message.text = 'something important' self.update.effective_user.first_name = 'meaningless name' self.update.message.chat.id = 'some long integer' self.funcname.name = 'some function' # database = self.client.get_database("test-db") # database.create_collection("unittest") # uselles_function(self.update) Files.new_log(self, self.update, self.funcname) # print(mock_new_log(self, self.update, self.funcname)) self.assertEqual( mock_new_log(self, self.update, self.funcname), { 'user': '******', 'user id': 'some long integer', 'function': 'some function', 'message': 'something important', 'time': datetime.now().strftime("%Y-%m-%d %H.%M") })
def _get_index_position(self, index, start, length): data = Files.read_binary_file( self._input_file, start, length ) data = [int(x) for x in data.split(self.FIELD_DELIMITER)] if index not in data: return None return data.index(index)
def test_write_binary(self): """ Test can_include_file() """ Files.write_binary("test", "binary.bin", TEST_PATH) self.assertTrue(Files.file_exists(TEST_PATH + "binary.bin")) content = Files.get_raw_contents(TEST_PATH + "binary.bin") self.assertTrue(content == "74657374") Files.delete_files(TEST_PATH + "binary.bin")
def diff(self, path='/mnt/sd/DCIM'): storage = Storage() download_url = ('http://%s/cgi-bin/wifi_filelist?fn=' + path) % (self.ip, ) data = urllib.urlopen(download_url) tree = ET.parse(data) root = tree.getroot() for child in root: if child.attrib['type'] == '1': self.diff(path + '/' + child.attrib['name']) else: file_instance = File(child.attrib['name']) if file_instance not in storage: Files().put(File(path + '/' + child.attrib['name'], self))
def test_json(self): """ Test jSon files """ if self.debug: print " Testing SQL: %s" % self.test_file + FILE_EXT_JSON file_list = [self.test_file + FILE_EXT_JSON] else: file_list = Files.get_file_list(self.generated_folder) for json_file in file_list: if not Files.file_exists(self.generated_folder + json_file): continue data = json.load(open(self.generated_folder + json_file)) test_data = __classmap__[self.name].get_test_data() ret = self._check_json(data, test_data) if isinstance(ret, str): print " ** TEST Failed for: %s => %s" % (json_file, ret)
def download_images(self): """ Download images for a page (listed in the json file) """ if self.debug: print " Downloading Images: %s" % self.test_file + FILE_EXT_JSON file_list = [self.test_file + FILE_EXT_JSON] else: file_list = Files.get_file_list(self.generated_folder) for json_files in file_list: if not Files.file_exists(self.generated_folder + json_files): continue data = json.load(open(self.generated_folder + json_files)) # define the base name for all images base_name = json_files.replace(FILE_EXT_JSON, "") images = __classmap__[self.name].parse_images(base_name, data) for (filename, url) in images.items(): self.download_image(url, filename)
def main(music_folder: str, disable_menu: bool, enable_rfid: bool): music_folder = os.path.expanduser(music_folder) files = Files(music_folder) audio_files = [] queue = Queue() t = Menu.start_kbd_listener_thread(queue, music_folder) # main loop loop = True while loop: if audio_files: audio_files = Audio.play(audio_files) if not queue.empty(): key = queue.get() if key == "q": print("The End") t.join() loop = False else: print("{} was selected".format(key)) Audio.stop() audio_files = files.get_audio_files(key) audio_files = Audio.play(audio_files)
def nsuite(): n = unittest.TestSuite() n.addTest(Signup.SignUp("test")) n.addTest(General.general()) n.addTest(Lists.lists()) n.addTest(Views.views()) n.addTest(Subtasks.subtasks()) n.addTest(Files.files()) n.addTest(Recurrence.recurrence()) n.addTest(Positioning.positioning()) n.addTest(DefaultFolder.default_folder()) n.addTest(Sharing.sharing()) n.addTest(ListSharing.list_sharing()) n.addTest(Login.login()) return n
def _get_index_data(self, index, start, index_position): length = len(str(index)) + 2 + (self.ZERO_FILL * 2) data = Files.read_binary_file( self._input_file, start + (index_position * length), length ) if not data: return False data = data.split(self.FIELD_DELIMITER) for (key, value) in enumerate(data): data[key] = int(value) return data
def _get_binary_header(self, index): data = Files.read_binary_file( self._input_file, 0, self.NUMBER_RECORD_HEADER * self.ZERO_FILL ) chunks, chunk_size = len(data), len(data) / self.NUMBER_RECORD_HEADER header = map(int, [data[i:i + chunk_size] for i in range( 0, chunks, chunk_size)]) if header[0] == 0: return False if index < header[4] or index > header[5]: return "" return header
def execute(source, action, binary_file, search): """ Execute the action for a site :param source: the source :param action: the action :param binary_file: the binary/data file :param search: the index/key to search for """ if not Params.valid_action(action): print ERROR_INVALID_ACTION return if not Params.is_valid_source(source): print ERROR_INVALID_SOURCE return if binary_file: if not Files.file_exists(binary_file): print ERROR_FILE_NOT_FOUND % binary_file return if source == "phone": if action == ACTION_READ: from lib.PhoneRead import PhoneRead print PhoneRead.read(binary_file, int(search)) elif action == ACTION_WRITE: from lib.PhoneWrite import PhoneWrite phone = PhoneWrite() phone.save() elif source == "zip_codes": pass if action == ACTION_READ: from lib.ZipCodeRead import ZipCodeRead print ZipCodeRead.read(binary_file, int(search)) elif action == ACTION_WRITE: from lib.ZipCodeWrite import ZipCodeWrite zips = ZipCodeWrite() zips.save()
def __init__(self, name, debug): self.debug = debug self.name = name self.base_url = __classmap__[name].BASE_URL self.test_file = __classmap__[name].TEST_FILE self.download_folder = DOWNLOAD_PATH + self.name + "/" self.generated_folder = GENERATED_PATH + self.name + "/" self.image_folder = IMAGE_PATH + self.name + "/" Files.create_folder(self.download_folder) Files.create_folder(self.generated_folder) Files.create_folder(self.image_folder) if self.debug: print "DEBUG Mode Enabled"
def read(self, index): """ Get the record for an key :param index: The index :return: list """ header = self._get_binary_header(index) if not header: return "" index_length = int(header[1]) index_start = int(header[2]) index_position = self._get_index_position(index, index_start, index_length) if index_position is None: return False index_data_start = index_length + index_start index_data = self._get_index_data(index, index_data_start, index_position) position = index_data_start + index_data[1] + header[3] if not index_data: return "" data = Files.read_binary_file( self._input_file, position, index_data[2] ) return data.split(self.FIELD_DELIMITER)
def test_read_binary(self): """ Test can_include_file() """ Files.write_binary("test", "binary.bin", TEST_PATH) content = Files.read_binary_file(TEST_PATH + "binary.bin", 0, 8) self.assertTrue(content == "test")
from nltk.classify import SklearnClassifier from sklearn.naive_bayes import BernoulliNB from sklearn.svm import SVC from sklearn.metrics import precision_recall_curve from sklearn.preprocessing import LabelEncoder from keras.utils import np_utils import matplotlib.pyplot as plt # ## 1. Analyse the structure of the data # To give an example of the shape of the raw data, below it is shown a short section of one of the articles used, containing sentences of its corresponding abstract and introduction. # In[3]: sample = Files().get_sample_file(path="SentenceCorpus/labeled_articles/", extension="1.txt") sample # As observed above, the raw data is mostly preprocessed. Each of the section names is sorrounded by a set of "#" characters. Each of the labeled sentences is preceded by its corresponding label, which is in capital letters. # # Moreover, (it is not observed above but) all citations contained in the articles have been replaced with the word "CITATION". All numbers have been replaced with the mark "NUMBER". All equations and symbols were replaced with the mark "SYMBOL". # # In general, the number and lenght of sentences contained in the abstract are smaller than the sentences of the introduction. In addition, it is quite rare that the abstract sentences contains equations (that is "SYMBOL" marks) or CITATION marks, but it is quite common that these marks appear in the introduction sentences. # # Similarly, there are different patterns observed in sentences of each class like CITATION marks for the case the class CONT. # # We took advantage of all these observations in order to select the most relevant features that could lead to a competitive performance during the automatic labelling process. # ## 2. Preprocess data
def translate_room_command(self, response, Player, Room, Game_State, Scene): #self, "response", Class, Class, Class, Class response = response.title() #--------------------------------------------------------------------- # Room Command #--------------------------------------------------------------------- if response in Room.Commands: #Room Commands must only have these vars passed Room.Commands[response](Scene, self, Game_State) #--------------------------------------------------------------------- # Change Floors #--------------------------------------------------------------------- elif self.bools["Up"] == True and type(Room) is not Dungeon: if Room.Solved == True: Game_State.change_floors(Player, Scene, self, 1) else: Scene.screen.addstr(Scene.line, 1, Scene.make_line(107, "Story", {})) Scene.line += 1 elif self.bools["Up"] == True and type(Room) is Dungeon: Game_State.change_floors(Player, Scene, self, 1) elif self.bools["Down"] == True and type(Room) is Dungeon: if Room.Solved == True: Game_State.change_floors(Player, Scene, self, -1) else: Scene.screen.addstr(Scene.line, 1, Scene.make_line(107, "Story", {})) Scene.line += 1 elif self.bools["Down"] == True and type(Room) is not Dungeon: Game_State.change_floors(Player, Scene, self, -1) #--------------------------------------------------------------------- # Study #--------------------------------------------------------------------- elif response == "Study": Player.study_magic(Scene, self, Game_State) #--------------------------------------------------------------------- # Spellbook #--------------------------------------------------------------------- elif self.bools["Spellbook"] == True: Player.study_magic(Scene, self, Game_State) #--------------------------------------------------------------------- # Items #--------------------------------------------------------------------- elif response in self.items: item = Item(response) item.use_consumable_item(Player, Scene, Game_State) item.__delete__() elif response in self.inventory: Player.get_inventory(Scene) elif self.bools["Recipes"] == True: Player.view_recipes(self, Scene) #--------------------------------------------------------------------- # Cure #--------------------------------------------------------------------- elif response == Player.Cure["Name"]: #Cure Spell if Player.known_spell(response) == True: placeholder = Actor(1, "") Player.cast_Spell(Player.Cure["Name"], placeholder, Game_State, Scene) placeholder.__delete__() else: #You don't know that spell yet! Scene.screen.addstr(Scene.line, 1, Scene.make_line(6, "Menu", {})) Scene.line += 1 #--------------------------------------------------------------------- # Status #--------------------------------------------------------------------- elif self.bools["Status"] == True: Scene.screen.addstr(Player.Scan(Scene)) #--------------------------------------------------------------------- # Continue Walking Through Dungeon #--------------------------------------------------------------------- elif self.bools["Attack"] == True or self.bools["Resume"] == True and type(Room) is Dungeon: #Take next step in dungeon if Room.Steps_Taken < Room.Steps: Room.action = False else: #Continue Fighting Room.start_battle(Player, Scene, self, Game_State) #--------------------------------------------------------------------- # Save #--------------------------------------------------------------------- elif response in self.save: save = Files() save.save(Player, Game_State, Scene) save.__delete__() #--------------------------------------------------------------------- # Debug #--------------------------------------------------------------------- elif response == "Pockets" and Game_State.Debug == True: self.fill_inventory(Player) Scene.screen.addstr(" * Debug: Inventory Filled") elif response == "Solve" and Game_State.Debug == True: self.solve(Room) Scene.screen.addstr(" * Debug: Room Solved") elif response == "No MP" and Game_State.Debug == True: self.depletemp(Player) Scene.screen.addstr(" * Debug: MP Depleted") elif response == "No HP" and Game_State.Debug == True: self.depletehp(Player) Scene.screen.addstr(" * Debug: HP Depleted") elif response == "Level" and Game_State.Debug == True: self.levelup(Player, Scene) elif response == "Ten" and Game_State.Debug == True: counter = 0 while counter < 10: self.levelup(Player, Scene) counter += 1 elif response == "Textbook" and Game_State.Debug == True: Player.Upgrades["Value"] += 10 Scene.screen.addstr(" * Debug: Upgrades available") elif response == "Know It All" and Game_State.Debug == True: self.learn_all_spells(Player) Scene.screen.addstr(" * Debug: Spells Learned") elif response == "Interactables" and Game_State.Debug == True: for a in range(len(Room.Interactables)): Scene.screen.addstr(str(Room.Interactables[a].Name)) for b in range(len(Room.Interactables[a].Keys)): Scene.screen.addstr(Room.Interactables[a].Keys) elif response == self.Cheat: if Game_State.Debug == True: Game_State.Debug = False Scene.screen.addstr(" * Debug disabled") else: Game_State.Debug = True Scene.screen.addstr(" * Debug enabled") #--------------------------------------------------------------------- # Misc #--------------------------------------------------------------------- elif self.bools["Help"] == True: self.get_help(Game_State) elif response == "Quit": Game_State.quit(Player, self, Scene)
if __name__ == '__main__': ''' aligment = [ "XTQNPQWLWQEVLQEQQLSRPTYETTT", "MTQNPQWLWQEVLTKLRPTYET", #"MTQNPQWLLSRPTYET", "MTQNPQWLWQEVLTKLERPTYET", "MTQNPQWLWQEVLTKLEQQLSRPTYET", "MTQNPQWLWQEVLTKLEQQSRPTYET", "MTQNPQWLWQQLSRPTYET", "CTQNPQWLWQEVLQEQQLSRPTYETTT" ] ''' files = Files() files.open("input.fasta") nj = NeighborJoining(files.getLabels(), files.getSequencias()) #nj.execute() #print(files.getSequencias()) #print(files.getLabels()) saga = Saga(population_size=20, num_generations=100) print("Parameters:") print("Polulation size = 20") print("um generations = 100") print(files.getSequencias()) print() saga.execute(files.getSequencias()) print("Fim execução!!")
#!/usr/bin/env python3 # -*- coding: utf-8 -* from NeighbourJoining import NeighbourJoining from Files import Files if __name__ == '__main__': files = Files() files.open("arq.fasta") nj = NeighbourJoining(files.getLabels(), files.getSequencias()) nj.execute() print("Fim de execução!!")
def setup_menu(self): #sets up menu items for root files = Files() user = '******' dev = '| DEV |' spacer = ' ' #used just for separation on menubar tips = '| TIPS |' self.root.option_add('*tearOff', False) #removes the -- from menu options menubar = tkinter.Menu( self.root, background='#ff0000', activebackground='#00ff00') #creates menu widget self.root['menu'] = menubar #attaches menu widget to root user_menu = tkinter.Menu( menubar, #creates user menu on menubar background=self.styles.config.lookup('menu_item_color', 'background'), foreground=self.styles.config.lookup('menu_item_color', 'foreground'), activebackground=self.styles.config.lookup('menu_item_color', 'activebackground'), activeforeground=self.styles.config.lookup('menu_item_color', 'activeforeground')) menubar.add_cascade(menu=user_menu, label=user) #adds to menubar user_menu.add_command(label='New', command=self.items.killTree) user_menu.add_command(label='Open', command=lambda: files.load_file(self.items)) user_menu.add_command(label='Save', command=lambda: files.save_file(self.items)) user_menu.add_separator() user_menu.add_command(label='Exit', command=sys.exit) #used only to put space between menu options spacer_menu = tkinter.Menu(menubar) menubar.add_cascade(menu=spacer_menu, label=spacer, state='disabled') dev_menu = tkinter.Menu( menubar, #creates dev menu on menubar background=self.styles.config.lookup('menu_item_color', 'background'), foreground=self.styles.config.lookup('menu_item_color', 'foreground'), activebackground=self.styles.config.lookup('menu_item_color', 'activebackground'), activeforeground=self.styles.config.lookup('menu_item_color', 'activeforeground')) menubar.add_cascade(menu=dev_menu, label=dev) #adds menu to menubar dev_menu.add_command(label='Erase All Data', command=self.items.killTree) dev_menu.add_command(label='Generate Data', command=self.items.generateTree) dev_menu.add_separator() dev_menu.add_command(label='Exit', command=sys.exit) tip_menu = tkinter.Menu( menubar, #creates tip menu on menubar background=self.styles.config.lookup('menu_item_color', 'background'), foreground=self.styles.config.lookup('menu_item_color', 'foreground'), activebackground=self.styles.config.lookup('menu_item_color', 'activebackground'), activeforeground=self.styles.config.lookup('menu_item_color', 'activeforeground')) menubar.add_cascade(menu=tip_menu, label=tips) #adds menu to menubar tip_menu.add_command(label='Hotkeys', command=self.hotkeys) return None
def onGameComplete(self, win, spies): self.addTargetsToTrainingSet(spies) FileReadWriter().writeToFile(self.trainingSet, Files().newTrainingSet_txt)