class MainApplication(tk.Frame): def __init__(self, parent, *args, **kwargs): tk.Frame.__init__(self, parent, *args, **kwargs) self.parent = parent LC_result = None old_age_choice = None old_gender_choices = None old_smk_years_choices = None old_qt_years_choices = None old_cpd_choices = None old_race_choices = None old_emp_choices = None old_flt_choices = None old_bmi_entry = None old_edu6_choices = None # init reading data table life_table = read_life_table_from_file( "input/Copy of Lung cancer_7-19-2019.xlsx") local_cancer = read_LC_table_from_file( "input/Copy of Lung cancer_7-19-2019.xlsx") regional_cancer = read_regional_cancer_table_from_file( "input/Copy of Lung cancer_7-19-2019.xlsx") distant_cancer = read_distant_cancer_table_from_file( "input/Copy of Lung cancer_7-19-2019.xlsx") # initiate the basehaz and the model_coef array to calculate the LCRAT_1mon_risk basehaz_G = get_basehaz_from_file("input/lcrisk_tool.xlsx", 6) basehaz_H = get_basehaz_from_file("input/lcrisk_tool.xlsx", 7) basehaz_J = get_basehaz_from_file("input/lcrisk_tool.xlsx", 9) model_coef_D = get_model_coef_from_file("input/lcrisk_tool.xlsx", 3) model_coef_F = get_model_coef_from_file("input/lcrisk_tool.xlsx", 5) self.memubar = MenuBar(parent) self.statusbar = StatusBar(self) self.toolbar = ToolBar(self) self.navbar = NavigationBar(self) self.main = Main(root) self.statusbar.pack(side="bottom", fill="x") self.toolbar.pack(side="top", fill="x") self.navbar.pack(side="left", fill="y") self.main.pack(side="right", fill="both", expand=True) def set_new_changing_state(p): global old_age_choice, old_gender_choices, old_smk_years_choices, old_qt_years_choices, old_cpd_choices, \ old_race_choices, old_emp_choices, old_flt_choices, old_bmi_entry, old_edu6_choices old_age_choice = p.age old_gender_choices = p.gender old_smk_years_choices = p.smkyears old_qt_years_choices = p.qtyears old_cpd_choices = p.cpd old_race_choices = p.race old_emp_choices = p.emp old_flt_choices = p.fam_lung_trend old_bmi_entry = p.bmi old_edu6_choices = p.edu6
def test_order_wout_certain_items(): """ Checks that even if one item is not enough in inventory, an empty shipment is sent. """ order = {"banana": 2, "orange": 25} warehouses = [ { "name": "owd", "inventory": { "apple": 2, "orange": 2 } }, { "name": "amazon", "inventory": { "banana": 2, "orange": 3 } }, { "name": "dm", "inventory": { "apple": 5, "banana": 1, "orange": 4 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = {} assert shipment == expected
def test_cheapest_takes_priority(): """ Checks if a complete warehouse is preferred over a cheaper partial options. """ order = {"banana": 2, "orange": 5} warehouses = [ { "name": "owd", "inventory": { "apple": 2, "orange": 2 } }, { "name": "amazon", "inventory": { "banana": 2, "orange": 3 } }, { "name": "dm", "inventory": { "apple": 5, "banana": 1, "orange": 5 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = {'amazon': {'banana': 2}, 'dm': {'orange': 5}} assert shipment == expected
def test_calculate_smog_contamination_for_given_cell(): main = Main(5, 5) fill_city_map(main.city_map) assert 80 == main.calculate_smog_contamination_for_given_cell( starting_cell[0], starting_cell[1]) assert 50 == main.calculate_smog_contamination_for_given_cell( starting_cell[0] - 1, starting_cell[1])
class MainTest(unittest.TestCase): def setUp(self): self.app = wx.App() self.app.MainLoop = Mock() self.frame = wx.Frame(None) self.frame.Show = Mock() self.main = Main() self.main.app = self.app self.main.frame = self.frame def test_start_application_main_loop(self): self.main.open() self.app.MainLoop.assert_called_with() def test_show_application_main_frame(self): self.main.open() self.frame.Show.assert_called_with()
def test_priority_to_shipment(): """ Another tests for checking handling of multiple warehouses and orders. """ order = {"apple": 5, "banana": 10} warehouses = [ { "name": "owd", "inventory": { "apple": 2, "banana": 10 } }, { "name": "amazon", "inventory": { "apple": 3, "banana": 5 } }, { "name": "flipkart", "inventory": { "apple": 3, "banana": 5 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = {"owd": {"apple": 2, "banana": 10}, "amazon": {"apple": 3}} assert shipment == expected
def test_empty_order(): """ Checks if an empty order returns an empty shipment """ order = {} warehouses = [ { "name": "owd", "inventory": { "apple": 2, "orange": 2 } }, { "name": "amazon", "inventory": { "banana": 2, "apple": 3 } }, { "name": "dm", "inventory": { "apple": 5, "banana": 2, "orange": 2 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = {} assert shipment == expected
def generatePrimer3Input(outputFile, POI): """ generates the primers depending on the POI (id and sequence) :param outputFile: position to save the primer design settings and inputs :param POI: dictionary with ID and sequence :return: """ Main.logger.debug("generatePrimer3Input: o." + outputFile + " p." + str(len(POI))) outputFilePart = outputFile.split(".") outputDir = outputFilePart[0] Main.makeDirectory(outputDir) outputFile = file(outputFile, mode='w') for key, value in POI.iteritems(): outputFile.write("SEQUENCE_ID=POI" + key + "\n") outputFile.write("SEQUENCE_TEMPLATE=" + value + "\n") outputFile.write("PRIMER_MIN_SIZE=15\n" "PRIMER_MAX_SIZE=21\n" "PRIMER_PICK_LEFT_PRIMER=1\n" "PRIMER_PICK_RIGHT_PRIMER=1\n" "PRIMER_NUM_NS_ACCEPTED=0\n" "PRIMER_PRODUCT_SIZE_RANGE=200-500\n" # change this to change the wanted product size "PRIMER_PRODUCT_OPT_SIZE=300\n" "P3_FILE_FLAG=0\n" "PRIMER_PICK_INTERNAL_OLIGO=0\n" "PRIMER_EXPLAIN_FLAG=1\n" "PRIMER_THERMODYNAMIC_PARAMETERS_PATH=/mnt/apps/primer3-2.3.0/src/primer3_config/\n" "=\n") outputFile.close() workLine = "/mnt/apps/primer3-2.3.0/src/primer3_core -format_output -output=" + outputDir +\ "/PrimerList.txt " + outputFile.name Main.execute(workLine, "Running primer3") return
def setUp(self): self.main = Main("Unit Tests") lines = [] path = os.path.dirname(__file__) os.chdir(path) fileName = "TestData.txt" with open(fileName, 'r') as testFile: for line in testFile: lines.append(line.strip("\n")) testFile.close() self.correctSysLine = lines[0].split("\t") self.corruptMissingDataSysLine = lines[1].split("\t") self.corruptWrongDataSysLine = lines[2].split("\t") self.trimTestData = [ lines[3], lines[4], lines[5], lines[6], lines[7], lines[8] ] self.trimBadData = [lines[9]] self.addGateGoodData = lines[10].split("\t") self.addGateMissingData = lines[11].split("\t") self.addGateCorruptData = lines[12].split("\t") self.systemsRouteTestData = [ lines[13].split("\t"), lines[14].split("\t"), lines[15].split("\t"), lines[16].split("\t"), lines[17].split("\t"), lines[18].split("\t"), lines[19].split("\t"), lines[20].split("\t"), lines[21].split("\t"), lines[22].split("\t") ]
def runIntersect(coordsFile, outputName): """ runs bedtools intersect to find the intersection between read information :param coordsFile: file with the coordinations of the alignment :param outputName: location of the gff output file :return: gff file name """ Main.logger.debug("runIntersect: c." + str(len(coordsFile)) + " o." + outputName) numb = len(coordsFile) while len(coordsFile) > 1: coordsFileList = list() workLine = "" workList = list() for i, coordsFile in enumerate(coordsFile): if i != 0: outPutDir = Main.workDir + "/" + str(numb) + ".bed" numb += 1 workList.append(outPutDir) workLine += " -b " + coordsFile + " > " + outPutDir coordsFileList.append(outPutDir) Main.execute(workLine, "Running intersect, please wait") workLine = "intersectBed -a " + coordsFile coordsFile = coordsFileList fromBED = open(coordsFile[0], mode="r") toGFFFileName = Main.workDir + outputName toGFF = open(toGFFFileName, mode="w") for i, line in enumerate(fromBED): line = line.split("\t") toGFF.write(line[0] + "\t" + "." + "\t" + "CDS" + "\t" + line[1] + "\t" + line[ 2].rstrip() + "\t" + "." + "\t" + "+" + "\t" + "0" + "\t" + "ID=" + str(i) + "\n") return toGFFFileName
class TestTaker(TestCase): def setUp(self): self.program = Main([taker]) self.program.start() time.sleep(0.5) def tearDown(self): self.program.stop() def test_alive(self): response = requests.get("http://127.0.0.1:7000") self.assertEqual(200, response.status_code) def test_taking(self): data = { "account": None, "object": { "login": "******", "password": "******" }, "action": "add" } data_dumped = json.dumps(data) response = requests.post("http://127.0.0.1:7000", data_dumped) response_data = json.loads(response.content) self.assertEqual(data, response_data)
class TestMain(unittest.TestCase): def setUp(self): self.main = Main('172.16.33.1', '172.16.33.144', range(21, 25), 'vmnet8') logger.debug("setUp(): done") def test_main(self): self.main.start()
def customResults(depot_index, lp1, lp2, speed, buffalo_size, trial_size, bg_not_updating, max_demands): with app.app_context(): data = [] main = Main() results = main.generateResults(depot_index, [lp1, lp2], speed, buffalo_size, trial_size, bg_not_updating, max_demands) if results is None: return jsonify(message='Error Happens'), 500 if results['status'] is False: return jsonify(message=results['message']), 500 for res in results['data']: data.append({ 'buffalo_no': res['buffalo_no'], 'total_demands': res['total_demands'], 'routes': res['real_nodes'], 'graph': { 'name': res['graph'].getLocationNames(), 'coor': res['graph'].getLongLat(), 'node': res['graph'].getNodes(), 'demands': res['graph'].getDemands() }, 'cost': res['buffalo'].getTotalDistance() }) response = jsonify(data) return response
def test_reusing_the_warehouses(): """ Checks if existing warehouses could be used to prepare a new shipment """ order = {"orange": 4, "banana": 4} warehouses = [ { "name": "dm", "inventory": { "apple": 5, "banana": 2, "orange": 3 } }, { "name": "amazon", "inventory": { "banana": 3, "apple": 3 } }, { "name": "owd", "inventory": { "apple": 2, "orange": 3 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = { 'owd': { 'orange': 1 }, 'amazon': { 'banana': 2 }, 'dm': { 'orange': 3, 'banana': 2 } } assert shipment == expected new_order = {"apple": 5, "orange": 2, "banana": 1} new_shipment = main.use_existing_warehouses_for_order(new_order) new_shipment_expected = { 'dm': { 'apple': 5 }, 'owd': { 'orange': 2 }, 'amazon': { 'banana': 1 } } assert new_shipment == new_shipment_expected
def loop(self): running = True self.main = Main(self.selected_vol, self.selected_music) self.mini = MiniGames() while running: self.selected_vol, self.selected_music, value = self.main.game_intro( ) if value == "mini": value = self.mini.loop()
def samToBam(self): """ Transfers the SAM file to a sorted BAM file. The sorted BAM file is important to speed up other processes :return: """ Main.logger.debug("BamTools samToBam:") workLine = "samtools view -bS " + self.samFile + ".sam | samtools sort -o " + self.samFile + ".sorted" Main.execute(workLine, "Creating sorted BAM file from SAM file") return
def bamToBai(self): """ Generates a index file from a sorted BAM file for speed access to certain position in the genome :return: """ Main.logger.debug("Bamtools bamToBai:") workLine = "samtools index " + self.samFile + ".sorted " + self.samFile + ".bai" Main.execute(workLine, "Creating index from BAM file") return
def snpCalling(self): """ Finds the SNP between the reference and the mapped reads. :return: """ Main.logger.debug("Bamtools snpCalling:") workLine = "samtools mpileup -ugf " + Main.genomeAdd + Main.refGenomeList[0] + " " + self.samFile +\ ".sorted | bcftools call -vmO v -o " + self.samFile + ".vcf" Main.execute(workLine, "Variance calling") return
def setUp(self): self.main = Main([twisted_taker]) self.main.start() lists_writer.delete({}) accounts_writer.delete({}) group_writer.delete({}) sessions_writer.delete({}) following_account_writer.delete({}) following_group_writer.delete({}) following_list_writer.delete({}) sleep(0.5)
def runMethodSubstract(coordsFile, outputName): """ removes the intersection from the subsets, and makes a new subset with only unique regions for that method :param coordsFile: coordsfile like mapper and intersection :param outputName: outputfile like mapperunique :return: file location """ Main.logger.debug("runMethodSubstract: c." + str(len(coordsFile)) + " o." + outputName) workLine = "subtractBed -a " + coordsFile[0] + " -b " + coordsFile[1] + " > " + outputName Main.execute(workLine, "Running substraction, please wait") return outputName
def runMethodIntersect(coordsFile, outputName): """ Tool to find the intersection between the tools :param coordsFile: files with the coordinations :param outputName: location of the intersection file :return: location to the intersection file """ Main.logger.debug("runMethodIntersect: c." + str(len(coordsFile)) + " o." + outputName) workLine = "intersectBed -a " + coordsFile[0] + " -b " + coordsFile[1] + " > " + outputName Main.execute(workLine, "Running method intersect, please wait") return outputName
def __init__(self): super().__init__() self.icon = QIcon("images/python-logo.png") self.database = Database('./data.db') self.sign_up_win = SignWindow() # 创建的注册窗口 self.admin_win = AdminWindow() # 创建的用户管理窗口 self.main_win = Main() # 登录后的主页面 self.admin_win.set_main_window(self.main_win) self.setWindowTitle(" Login in") self.setFixedSize(1000, 800) self.set_ui()
def __init__(self): self.time = 0 self.createCanvas() self.gui.update() self.gui.title("Traffic Light Simulation") self.lightOffset = 350 self.padding = 150 self.stateIsNew = False self.main = Main(visualizerCallback=self.updateFrame) self.environment = self.main.environment self.main.startSimulation()
def bamToBed(self): """ Generates a depth coverage per position (BED format) file from a sorted BAM file :return: """ Main.logger.debug("Bamtools bamToBed:") workLine = "genomeCoverageBed " \ "-ibam " + self.samFile + ".sorted " \ "-g workDir/" + self.referenceDB + " -d >" + self.samFile + ".bed" Main.execute(workLine, "Generating BED file from sorted BAM file") return
def bamToCoverageRate(self): """ Generates a file (CovBed) that shows the occurrence of a read depth per scaffold/chromosom and the whole genome :return: """ Main.logger.debug("Bamtools bamToCoverageRate:") workLine = "genomeCoverageBed " \ "-ibam " + self.samFile + ".sorted " \ "-g workDir/" + self.referenceDB + " > " + self.samFile + ".CovBed" Main.execute(workLine, "Generating depth info file from BAM") return
def mainmain(): from Main import Main main = Main(self.azienda, self.anagrafiche_modules, self.parametri_modules, self.anagrafiche_dirette_modules, self.frame_modules, self.permanent_frames) main.getTopLevel().connect("destroy", on_main_window_closed, self.login_window) main.show()
def aliasTool(allAlias, outputDir=Main.workDir): """ Combines all the local databases to one local database :param allAlias: names of all the local databases :param outputDir: location to save the combined database :return: """ Main.logger.debug("Blast aliasTool: a." + allAlias + " o." + outputDir) output = outputDir + "/others" workline = 'blastdb_aliastool -dblist "' + allAlias + '" -dbtype nucl -out ' + output + " -title others" Main.execute(workline, "Making one database") return
def test_run_only_first(self): self.__delete_saved_files(self._SAVE_LOAD_PATH, "lonlat_process") main = Main() main.run(0, 0) # geo_ref_product parameter may be empty cause we use saved data lonlat_process = CreateLonLat(self._PATH, "") lonlat_process.load_results(self._SAVE_LOAD_PATH) self.assert_array_not_empty(lonlat_process.lonlat) self.assert_array_not_empty(lonlat_process.pscands_ij)
def test_run_start_second_stop_second(self): self.__delete_saved_files(self._SAVE_LOAD_PATH, "ps_files") main = Main() main.run(1, 1) # Let's put empty arrays here. These are not needed when loading data ps_files_loaded = PsFiles(self._PATH_PATCH_FOLDER, CreateLonLat(self._PATH, "")) ps_files_loaded.load_results(self._SAVE_LOAD_PATH) # Ühest kontrollist piisab küll. Täpsemad kontrollid on juba spetsiifilises klassis self.assert_array_not_empty(ps_files_loaded.bperp)
def loginCommand(self): phone = self.phone.get() passwd = self.passwd.get() if phone.strip() == "" or passwd.strip() == "": self.warning("LOGIN WARNING",'请输入电话号码与密码') else: md5 = hashlib.md5() # 密码MD5加密存储 md5.update(passwd.encode(encoding='utf-8')) if User.validate(phone=phone,passwd = md5.hexdigest()) == True: # self.warning("LOGIN MESSAGE",'登录成功','green') self.LOGIN.destroy() main = Main(phone) main.display()
def __init__(): Main.__init__() try: responce = Main.start_Project() #print (responce) responce = Processes.project_Flag(responce) #print (responce) Choise = responce[0] #print (Choise) DST_PATH = responce[1].strip() + "\\" #print (DST_PATH) except: gc.collect() return Prints.warning() sys.exit() if Choise == "N1" or Choise == "O1" or Choise == "D1": if Choise == "N1": responce = Processes.construct_Project(DST_PATH) print("responce = ", responce) responce = Processes.project_Flag(responce) gc.collect() code = responce[0] print(code) msg = responce[1] + " -> " + responce[2] return code, msg elif Choise == "O1": #responce = Processes.Disply_Project(DST_PATH) responce = Processes.exist_Project(DST_PATH) responce = Processes.project_Flag(responce) gc.collect() code = responce[0] msg = responce[1] + " -> " + responce[2] return code, msg elif Choise == "D1": #responce = Processes.Disply_Project(DST_PATH) responce = Processes.remove_Project(DST_PATH) responce = Processes.project_Flag(responce) gc.collect() code = responce[0] msg = responce[1] + " -> " + responce[2] return code, msg else: gc.collect() code = responce[0] msg = responce[2].strip("> ") return code, msg
def extract_all(): for n in map(lambda x: x.name, ProjectName): m = Main() m.set_project_enum(n) m.choose_versions(version_num=3, algorithm='bin', version_type=VersionType["Untyped"], strict=False) m.set_version_selection(version_num=3, algorithm='bin', version_type=VersionType["Untyped"], strict=False, selected_config=0) m.extract()
def bowTie2Index(self, referenceFileName, outputdir): """ Generates an index database for mapping the reads against (for use in Bowtie2) :param referenceFileName: the reference genome full file name, input by user :param outputdir: the location to save the index database :return: """ Main.logger.debug("Bowtie2 bowTie2Index: r." + referenceFileName + " o." + outputdir) Main.logger.info("Working on generating an index database for Bowtie2") referenceName = referenceFileName.split(".") referenceName = referenceName[0] workLine = "bowtie2-build " + Main.genomeAdd + referenceFileName + " " + outputdir + referenceName Main.execute(workLine, "Making index, please wait") self.referenceDB = referenceName return
def test_all_partial(): """ Checks if all orders could be filled by combination of warehouses. """ order = {"apple": 6, "orange": 4, "banana": 4} warehouses = [ { "name": "owd", "inventory": { "apple": 2, "orange": 2 } }, { "name": "amazon", "inventory": { "banana": 2, "apple": 3 } }, { "name": "dm", "inventory": { "apple": 5, "banana": 2, "orange": 2 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = { 'owd': { 'apple': 2, 'orange': 2 }, 'amazon': { 'apple': 3, 'banana': 2 }, 'dm': { 'apple': 1, 'orange': 2, 'banana': 2 } } assert shipment == expected
def extract_all(repo_path): m = Main() for proj in ProjectName: if proj.value.github_name.lower() in repo_path.lower(): m.set_project_enum(proj.name) break m.choose_versions(version_num=3, algorithm='bin', version_type=VersionType["Untyped"], strict=False) m.set_version_selection(version_num=3, algorithm='bin', version_type=VersionType["Untyped"], strict=False, selected_config=0) m.extract(False)
def __init__(self, handle): activity.Activity.__init__(self, handle, False) self.set_title('JAMClock') # self.set_toolbox(activity.ActivityToolbox(self)) w = Gdk.Screen.width() h = Gdk.Screen.height() - 1 * GRID_CELL_SIZE # Start the Game activity self.game = Main((w, h)) # Build the Pygame canvas and start the game running # (self.game.run is called when the activity constructor # returns). self._pygamecanvas = canvas.PygameCanvas( self, main=self.game.run, modules=[pygame.display]) # Note that set_canvas implicitly calls read_file when # resuming from the Journal. self._pygamecanvas.set_size_request(w, h) self.set_canvas(self._pygamecanvas) self._pygamecanvas.grab_focus() # Build the activity toolbar. self.build_toolbar()
def get_run_game(self): self.eventbox.socket.window.set_cursor(None) print "Lanzando CantaBichos." pygame.init() x, y, w, y = self.eventbox.get_allocation() Main((w, y)) return False
def __init__(self): self.chooseadvance() self.predictor = [] self.tandf = [] self.name = 0 self.main = Main() self.mdlPredict = ModelPredict() root.geometry("1200x600") root.title("Data Predictor") self.button1 = Button(root, text="Select a File", command=lambda: [self.getfile()]) self.button1.pack(side=TOP, pady=5) self.button2 = Button(root, text="Quit", command=lambda: [self.exit()]) self.button2.pack(side=BOTTOM, pady=5) root.mainloop()
def __init__(self): QtGui.QDialog.__init__(self) self.ventana = Main() self.ventana.setupUi(self) self.connect(self.ventana.pushButton_2, QtCore.SIGNAL('clicked()'), self.abrir_ventana_agregar) self.connect(self.ventana.pushButton, QtCore.SIGNAL('clicked()'), self.abrir_ventana_buscar)
def test_ordering_of_items_in_order_does_not_matter(): """ Uses order from Test Case 13, but checks if ordering of items matter. """ order = {"orange": 4, "banana": 4, "apple": 6} warehouses = [ { "name": "owd", "inventory": { "apple": 2, "orange": 2 } }, { "name": "amazon", "inventory": { "banana": 2, "apple": 3 } }, { "name": "dm", "inventory": { "apple": 5, "banana": 2, "orange": 2 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = { 'owd': { 'apple': 2, 'orange': 2 }, 'amazon': { 'apple': 3, 'banana': 2 }, 'dm': { 'apple': 1, 'orange': 2, 'banana': 2 } } assert shipment == expected
def test_valid_input_2(): """ Checks if floats are handled. """ order = {"apple": 3} warehouses = [ { "name": "owd", "inventory": { "apple": 6.0 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = {"owd": {"apple": 3}} assert shipment == expected
def test_inventory_not_enough(): """ Checks that the allocator returns an empty list when no sufficient quantity is found. """ order = {"apple": 5} warehouses = [ { "name": "owd", "inventory": { "apple": 4 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = {} assert shipment == expected
def test_simple(): """ Checks a simple case """ order = {"apple": 5} warehouses = [ { "name": "owd", "inventory": { "apple": 6 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = {"owd": {"apple": 5}} assert shipment == expected
def test_invalid_input_2(): """ Checks if the shipment is empty when order is string """ order = {"apple": 'four'} warehouses = [ { "name": "owd", "inventory": { "apple": 6 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = {} assert shipment == expected
def test_invalid_input_3(): """ Checks if the shipment is empty when warehouse quantity is negative """ order = {"apple": 3} warehouses = [ { "name": "owd", "inventory": { "apple": -2 } }, ] main = Main(order, warehouses) shipment = main.find_cheapest_shipment() expected = {} assert shipment == expected
def makeDatabase(genomeFile, outputDir): """ Makes a local database from genome file :param genomeFile: location to genome file :param outputDir: location to store the local database :return: """ Main.logger.debug("Blast makeDatabase: g." + genomeFile + " o." + outputDir) workline = ( "makeblastdb -in " + Main.genomeAdd + genomeFile + " -parse_seqids -dbtype nucl -out " + outputDir + "/" + genomeFile ) Main.execute(workline) return
def quast(contigs): """ Quast is used to export the quality of the de novo assembly. Before running Quast, a gff file is transformed as a gene indicator for QUAST. The location of QUAST is hardcoded. if you want to use this module, update the location to your location :param contigs: :return: """ Main.logger.debug("Quast: "+contigs) if Main.gffFile is not None: geneFile = Assemblers.gffChanger(Main.gffFile) geneCommand = " -G " + geneFile + " " else: geneCommand = " " workline = "/mnt/apps/quast/quast-2.3/quast.py -o " + Main.resultDir + " -R " + Main.genomeAdd +\ Main.refGenomeList[0] + geneCommand + contigs Main.execute(workline, "Running quast, please wait!") return
def setUp(self): self.app = wx.App() self.app.MainLoop = Mock() self.frame = wx.Frame(None) self.frame.Show = Mock() self.main = Main() self.main.app = self.app self.main.frame = self.frame
def run(self): """ Run is called upon by making an instance of the class spades, and then start(). this is a normal method for threaded classes. The function calls upon the executer, which runs a terminal command. the command is to make a de novo assembly by pairwise reads, and with the output in an unique map for each assembly. The location of SPAdes is hardcoded. if you want to use this module, update the location to your location :return: """ Main.logger.debug("Spades run:") outputName = self.fileForward.split(".") outputName = outputName[0] self.outputDir = self.workDir+"/"+outputName workline = '/mnt/apps/SPAdes-3.1.1-Linux/bin/spades.py -1 ' + Main.fastQAdd + self.fileForward+' -2 ' \ + Main.fastQAdd + self.fileReversed+' -o ' + self.outputDir Main.execute(workline, "Running spades, please wait") os.rename(self.outputDir+"/contigs.fasta", self.outputDir+"/"+outputName+".fa") self.outputDir = self.outputDir+"/"+outputName+".fa" return
def bowTie2Map(self, outputDir): """ Method to map the reads against the generated index database by Bowtie2 :param outputDir: the location to save the SAM file :return: """ Main.logger.debug("Bowtie2 bowtie2map: o." + outputDir) fastQName = self.fastQFile1.split(".")[0] if outputDir == "": samFile = fastQName + ".sam" else: samFile = outputDir + "/Bow" + self.referenceDB + fastQName + ".sam" workLine = "bowtie2 -x " + outputDir + self.referenceDB + \ " -1 " + Main.fastQAdd + self.fastQFile1 + \ " -2 " + Main.fastQAdd + self.fastQFile2 + \ " -a --score-min \"L,-0.06,-0.06\" --phred33 " \ "--fr --very-sensitive --un-conc-gz " + fastQName + ".unalign.gz -S " + samFile Main.execute(workLine, "Running Bowtie2, please wait") self.samFile = samFile.replace(".sam", "") return
def test_main(self): with open ("testdata/testdata_manygood", "r") as myfile: self.manygood = myfile.readlines() allSms = SmsStorage(self.manygood) mailer = Mailer() prg = Main(mailer) prg.processLoop(allSms) self.assertEquals(prg.db.getEmailFor("+36209303349"),"*****@*****.**") self.assertEquals(prg.db.getEmailFor("+36209301112"),"*****@*****.**") self.assertEquals(prg.db.getEmailFor("+36209301113"),"*****@*****.**") self.assertEquals(prg.db.getEmailFor("+36209301114"),"*****@*****.**") self.assertEquals(prg.db.getEmailFor("+36209301115"),"*****@*****.**") with open ("testdata/testdata_updates", "r") as myfile: self.updates = myfile.readlines() allSms = SmsStorage(self.updates) prg.processLoop(allSms) self.assertEquals(prg.db.getEmailFor("+36209303349"),"*****@*****.**") self.assertEquals(prg.db.getEmailFor("+36209301112"),"*****@*****.**") self.assertEquals(prg.db.getEmailFor("+36209301113"), None) self.assertEquals(prg.db.getEmailFor("+36209301114"), None) self.assertEquals(prg.db.getEmailFor("+36209301115"),"*****@*****.**")
def doBlast(self, outputDir=Main.workDir): """ Runs the blast based on the local database and the query. Before this, a local database should be made named others :param outputDir: location where the blast results are saved :return: """ Main.logger.debug("Blast doBlast: o." + outputDir) workline = ( "blastn -db " + outputDir + "/others -query " + self.query + " -out " + outputDir + "/blastResult" + str(self.y) + '.csv -outfmt "10 std"' ) Main.execute(workline, "Running blast") return
class Principal(QtGui.QDialog): def __init__(self): QtGui.QDialog.__init__(self) self.ventana = Main() self.ventana.setupUi(self) self.connect(self.ventana.pushButton_2, QtCore.SIGNAL('clicked()'), self.abrir_ventana_agregar) self.connect(self.ventana.pushButton, QtCore.SIGNAL('clicked()'), self.abrir_ventana_buscar) def abrir_ventana_agregar(self): self.w = Agregar() self.w.show() def abrir_ventana_buscar(self): bDia = str(self.ventana.comboDia.currentText()) bAnio = str(self.ventana.comboAnio.currentText()) bMes = str(self.ventana.comboMes.currentText()) bFecha = bDia +"-"+ bMes +"-"+ bAnio bHora = str(self.ventana.comboHora.currentText()) bTipo = str(self.ventana.comboBox.currentText()) self.w = Buscar() self.w.show()
def setUp(self): main = Main("Unit Tests") main.loadSystems() main.loadGates() self.systems = main.systems self.sysNames = main.sysNames lines = [] path = os.path.dirname(__file__) os.chdir(path) fileName= "TestData.txt" with open(fileName, 'r') as testFile: for line in testFile: lines.append(line.strip("\n")) testFile.close() self.testSysLine = lines[0].split("\t") self.testRoutes = [] for i in xrange(0, len(lines)): if 13 <= i <= 22: self.testRoutes.append(lines[i].split("\t")) for i in xrange(0, len(self.testRoutes)): self.testRoutes[i][0] = self.systems[self.sysNames[self.testRoutes[i][0]]] self.testRoutes[i][1] = self.systems[self.sysNames[self.testRoutes[i][1]]]
class DownloadScheduler(): logging.basicConfig() def __init__(self, socketio): self.main = Main(socketio) self.execute_now() cron = Scheduler(daemon=True) cron.start() @cron.interval_schedule(hours=1) def job_function(): # Do your work here self.main.start() # Shutdown your cron thread if the web process is stopped atexit.register(lambda: cron.shutdown(wait=False)) def execute_now(self): thread.start_new_thread(self.main.start, ())
def __init__(self, socketio): self.main = Main(socketio) self.execute_now() cron = Scheduler(daemon=True) cron.start() @cron.interval_schedule(hours=1) def job_function(): # Do your work here self.main.start() # Shutdown your cron thread if the web process is stopped atexit.register(lambda: cron.shutdown(wait=False))
def setUp(self): self.main = Main("Unit Tests") lines = [] path = os.path.dirname(__file__) os.chdir(path) fileName= "TestData.txt" with open(fileName, 'r') as testFile: for line in testFile: lines.append(line.strip("\n")) testFile.close() self.correctSysLine = lines[0].split("\t") self.corruptMissingDataSysLine = lines[1].split("\t") self.corruptWrongDataSysLine = lines[2].split("\t") self.correctGateData = [lines[23].split("\t"), lines[24].split("\t"), lines[25].split("\t")] self.corruptMissingGateData = lines[26].split("\t") self.corruptWrongGateData = lines[27].split("\t") self.secondSys = lines[28].split("\t") self.distances = lines[29].split("\t")
def setUp(self): self.main = Main("Unit Tests") lines = [] path = os.path.dirname(__file__) os.chdir(path) fileName= "TestData.txt" with open(fileName, 'r') as testFile: for line in testFile: lines.append(line.strip("\n")) testFile.close() self.correctSysLine = lines[0].split("\t") self.corruptMissingDataSysLine = lines[1].split("\t") self.corruptWrongDataSysLine = lines[2].split("\t") self.trimTestData = [lines[3], lines[4], lines[5], lines[6], lines[7], lines[8]] self.trimBadData = [lines[9]] self.addGateGoodData = lines[10].split("\t") self.addGateMissingData = lines[11].split("\t") self.addGateCorruptData = lines[12].split("\t") self.systemsRouteTestData =[lines[13].split("\t"), lines[14].split("\t"),lines[15].split("\t"), lines[16].split("\t"), lines[17].split("\t"), lines[18].split("\t"), lines[19].split("\t"), lines[20].split("\t"), lines[21].split("\t"), lines[22].split("\t")]
def startCrawling(self,url): Main.start(url)
route = routeFinder.getRoute('j') dtime = int(round(time.time()*1000))-dtime file.write("Avoidence Type 1: " + start.getName() + "\t" + end.getName() + "\t" + str(len(route)-1) + "\t" + str(dtime) + "\n") except GeneralError as e: file.write(start.getName() + "\t" + end.getName() + "\t" + "Caught General Error / out of systems running Avoidence Type 1\n") except Exception as e: file.write(start.getName() + "\t" + end.getName() + "\t" + "Caught unknown error running Avoidence type 1\t" + str(e) + "\n") finally: return [route, dtime] def test2(routeFinder, file, dtime,start,end): route = "" try: ctime = int(round(time.time()*1000)) route = routeFinder.getRoute('jtest') ctime = int(round(time.time()*1000))-ctime file.write("Avoidence Type 2: " +start.getName() + "\t" + end.getName() + "\t" + str(len(route)-1) + "\t" + str(ctime) + "\n") except GeneralError as e: file.write(start.getName() + "\t" + end.getName() + "\t" + "Caught General Error / out of systems running Avoidence Type 2\n") except Exception as e: file.write(start.getName() + "\t" + end.getName() + "\t" + "Caught unknown error running Avoidence type 2\t" + str(e) + "\n") finally: return[route, ctime] if __name__ == "__main__": main = Main() print("Starting") runRandomTester(main) main.cleanUp() main = ""