def __init__(self, gameSlide, gameHotspot, takenfile, menuSlide, closeupSlide=None, id=None, taken=False, onTake=lambda item: None, onUse=lambda item: None): if id: Item.rows[id] = self self.menuSlide = menuSlide if menuSlide: self.menuHotspot = Hotspot(self.menuSlide, None, onClick=self.use, cursor='grab.png', rectRel=RelativeRect((0, 0, 1, 1))) self.menuSlide.add(self.menuHotspot) self.closeupSlide = closeupSlide if self.closeupSlide: self.closeupPanel = Panel() self.closeupPanel._layer = 11 self.closeupPanel.rect = pyzzle.screen.get_rect() self.closeupHotspot = Hotspot(self.closeupSlide, None, onClick=self.exit, cursor='fwd.png', layer=-1) self.closeupHotspot.rect = pyzzle.screen.get_rect() self.closeupSlide.parent = self.closeupPanel self.closeupSlide._getRect() self.gameSlide = gameSlide if type(gameHotspot) == Hotspot: self.gameHotspot = gameHotspot else: self.gameHotspot = Hotspot(self.gameSlide, None, rectRel=gameHotspot) self.gameHotspot.cursor = 'grab.png' self.gameHotspot.onClick = self.take self.gameHotspot.parent = self.gameSlide self.takenfile = takenfile self.taken = taken if taken and self.menuSlide: self.inventory.add(self.menuSlide) elif gameSlide: gameSlide.add(self.gameHotspot) self.onUse = onUse self.onTake = onTake
def __hotspot_variants(self, logger): logger.info("Beginning variant hotspotting...") hotspotter = Hotspot(self.project_config, self.mongodb, logger) hotspotter.hotspot_variants(self.args['cpu_number']) self.mongodb.open_connection() self.project_config = self.mongodb.get_project_config(self.args['project_name']) self.mongodb.close_connection() logger.info("Variant hotspotting successfully completed")
def hotspot(self): hotspot = Hotspot() if "new" == self.args['number']: hotspot.run() else: try: number = int(self.args['number']) hotspot.run(number) except ValueError: self.logger.error("The number you specified is not a proper integer number") sys.exit()
def main(): # method to check if exit was entered anywhere, exit the program with 0 as the exit status def check_exit(input_to_check): if input_to_check == "exit": sys.exit(0) print('Welcome to WiFiFi a small windows hotspot application, Type exit to close the program at anytime') # ask for existing profile and create a new one if none exists while True: yes = input('Do you have an existing profile?, Enter Yes to proceed or No to create a new one\n') yes.lower() check_exit(yes) if yes == "yes": hotspot = Hotspot() hotspot.start() break # capture the username and password from the user elif yes == "no": name = input("Enter the Name of the New network:\n") password = "" check_exit(name) while len(password) < 8: password = input("""Enter the password for the network hint: password must be at least eight characters: """) hotspot = Hotspot(name, password) hotspot.initialize_hotspot() hotspot.start() break else: print("Invalid option please enter Yes or No:\n") continue # prompt the user to end the active hotspot session while True: stop = input("type stop to stop the wireless network:\n") stop.lower() if stop == "stop": hotspot.stop() # should modify the check_exit function to accept an optional argument instead of using sys sys.exit(0) else: print('invalid option type stop to stop the wireless network:\n') continue
def test_filter_genes(): """ Ensure genes with no expression are pre-filtered """ # Simulate some data N_CELLS = 100 N_DIM = 10 N_GENES = 10 N_GENES_ZERO = 5 latent = sim_data.sim_latent(N_CELLS, N_DIM) latent = pd.DataFrame(latent) umi_counts = sim_data.sim_umi_counts(N_CELLS, 2000, 200) umi_counts = pd.Series(umi_counts) gene_exp = np.random.rand(N_GENES + N_GENES_ZERO, N_CELLS) gene_exp[N_GENES:] = 0 gene_exp = pd.DataFrame( gene_exp, index=['Gene{}'.format(i + 1) for i in range(gene_exp.shape[0])], columns=latent.index) hs = Hotspot(gene_exp, model='normal', latent=latent, umi_counts=umi_counts) assert hs.counts.shape[0] == N_GENES
def hotspotDirective(_context, name, obj=None, interface=None, resource=[], considerparams=[]): if not obj and not interface and not resource: raise ConfigurationError(u"Du solltest dich entscheiden, Jonny!") hotspot = Hotspot(obj, interface, resource, considerparams) utility(_context, provides=IHotspot, component=hotspot, name=name)
def hotspot(self): """ This carries out the hotspotting option. :return: """ hotspot = Hotspot() # If "new" is specified as the hotspot option. if "new" == self.args['number']: hotspot.run() else: try: # Make sure that the number given is an actual number. number = int(self.args['number']) hotspot.run(number) except ValueError: self.logger.error("The number you specified is not a proper integer number") sys.exit()
def test_models(): """ Ensure each model runs """ # Simulate some data N_CELLS = 100 N_DIM = 10 N_GENES = 10 latent = sim_data.sim_latent(N_CELLS, N_DIM) latent = pd.DataFrame( latent, index=['Cell{}'.format(i + 1) for i in range(N_CELLS)]) umi_counts = sim_data.sim_umi_counts(N_CELLS, 2000, 200) umi_counts = pd.Series(umi_counts) gene_exp = np.random.rand(N_GENES, N_CELLS) gene_exp = pd.DataFrame( gene_exp, index=['Gene{}'.format(i + 1) for i in range(gene_exp.shape[0])], columns=latent.index) for model in ['danb', 'bernoulli', 'normal', 'none']: hs = Hotspot(gene_exp, model=model, latent=latent, umi_counts=umi_counts) hs.create_knn_graph(False, n_neighbors=30) hs.compute_hotspot() assert isinstance(hs.results, pd.DataFrame) assert hs.results.shape[0] == N_GENES hs.compute_autocorrelations() assert isinstance(hs.results, pd.DataFrame) assert hs.results.shape[0] == N_GENES hs.compute_local_correlations(gene_exp.index) assert isinstance(hs.local_correlation_z, pd.DataFrame) assert hs.local_correlation_z.shape[0] == N_GENES assert hs.local_correlation_z.shape[1] == N_GENES hs.create_modules(min_gene_threshold=2, fdr_threshold=1) assert isinstance(hs.modules, pd.Series) assert (hs.modules.index & gene_exp.index).size == N_GENES assert isinstance(hs.linkage, np.ndarray) assert hs.linkage.shape == (N_GENES - 1, 4) hs.calculate_module_scores() assert isinstance(hs.module_scores, pd.DataFrame) assert (hs.module_scores.index == gene_exp.columns).all()
threading.Thread(target=self.monitor_log, args=(stop_flag, )).start() # Monitors the log file and upates the text field when new data arrives def monitor_log(self, stop_flag): log_file = os.path.join(self.root.base_dir, self.root.log_file) with open(log_file) as log: while not stop_flag.is_set(): line = log.readline() if line: self.text.insert('end', line) self.text.see('end') if __name__ == "__main__": # Turns off autorepeat behaviour of os (enables detecting keyRelease and keyPress) os.system('xset r off') # Turn on hotspot Hotspot.open_hotspot() # Open the GUI and let it run until closed gui = Gui() gui.mainloop() # Close hotspot before exiting #Hotspot.close_hotspot() # Turn aurorepeat back on before exiting os.system('xset r on')
def hotspot(): """ Hotspot route """ if request.method == "POST": valid_form = functions.validate_form(request.form) # Display error if any field is empty if not valid_form["valid"]: return render_template("index.html", error=valid_form["error"], data_chosen=valid_form["datachosen"], setup=setup) else: # Setup the hotspot # hotspot = functions.setup_hotspot(request.form, units) hotspot = Hotspot(request.form, units) if hotspot.datafile.endswith(".csv"): datafile_as_dict = parse.csv_to_dict(hotspot.filter_value, hotspot.filter_column, hotspot.datafile) hotspot.getis, hotspot.conf_levels = functions.calculate_hotspot( hotspot, datafile_as_dict, "getis") hotspot.data = functions.calculate_hotspot( hotspot, datafile_as_dict) elif hotspot.datafile.endswith(".log"): hotspot.data, hotspot.getis, hotspot.conf_levels = functions.calculate_hotspot( hotspot) if hotspot.save_me: print("Saving aoristic csv...") functions.save_csv(hotspot.data, "static/maps/", hotspot.title, "_aoristic.csv") print("Saving getis csv...") functions.save_csv(hotspot.getis, "static/maps/", hotspot.title, "_gi.csv") # Creates the getis hotspot getis_hotspot = functions.create_hotspot(hotspot, "getis", hotspot.pvalue) # Save getis hotspot as png functions.save_figure(getis_hotspot, "static/maps/", hotspot.title, "_gi.png") # Creates the aoristic hotspot aoristic_hotspot = functions.create_hotspot(hotspot, "data") # Save aoristic hotspot as png functions.save_figure(aoristic_hotspot, "static/maps/", hotspot.title, "_aoristic.png") # Save the html table of confidence levels functions.save_table(hotspot.title, hotspot.conf_levels) # Get the saved pngs filelist = functions.get_saved_png(hotspot.title) #os.listdir('static/maps/' + hotspot["title"]) return render_template("hotspot.html", folder=hotspot.title, hotspots=filelist, lisa=hotspot.conf_levels)