def doAction(self, umlObjects: List[OglObject], selectedObjects: List[OglObject], umlFrame: UmlFrame): """ Args: umlObjects: list of the uml objects of the diagram selectedObjects: list of the selected objects umlFrame: the frame of the diagram """ if len(selectedObjects) != 1: dlg = MessageDialog(None, _("You must select at most a single class"), _("Warning"), OK | ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return filename: str = ToFastEdit.FAST_EDIT_TEMP_FILE file: TextIO = open(filename, "w") self.write(selectedObjects[0], file) file.close() if sysPlatform == PyutConstants.THE_GREAT_MAC_PLATFORM: osSystem(f'open -W -a {self._editor} {filename}') else: osSystem(f'{self._editor} {filename}') file = open(filename, "r") self.read(selectedObjects[0], file) file.close() self._setProjectModified() self._cleanupTempFile()
def timeout(): if (game.isPlay): # "loop" du jeu game.update() if ((game.gameCounter % game.current_time_modulo) == 0): ui.gameWidget.update() game.gameCounter += 1 osSystem("clear") print("STEP : " + str(game.gameCounter)) #print("BLUE SCORE : " + str(blueScore)) #print("RED SCORE : " + str(redScore)) #timer.stop() timePeriod = game.current_time_period
def _launchAppropriateEditor(self, filename: str) -> None: """ Launches the configured editor in a platform appropriate way. Assumes this blocks until the end-user exits the launched editor Args: filename: The file to pass to the editor """ if sysPlatform == PyutConstants.THE_GREAT_MAC_PLATFORM: osSystem(f'open -W -a {self._editor} {filename}') else: osSystem(f'{self._editor} {filename}')
def _file_cleanup(fnamelist, include_directories=False): """ """ for fname in fnamelist: if osPathExists(str(fname)): try: osRemove(str(fname)) except OSError: if osPathIsdir(str(fname)) and include_directories: osSystem("rm -rf %s" % fname) except: # failed !? on cluster computing, this # could be the case when an identical filename # is created/owned by another user. # I suspect this might happen for formatdb.log ;-) pass
def _file_cleanup(fnamelist,include_directories=False): """ """ for fname in fnamelist: if osPathExists(str(fname)): try: osRemove(str(fname)) except OSError: if osPathIsdir(str(fname)) and include_directories: osSystem("rm -rf %s" % fname) except: # failed !? on cluster computing, this # could be the case when an identical filename # is created/owned by another user. # I suspect this might happen for formatdb.log ;-) pass
def uploadAsync(self, program): self.boardBusy = True try: if self.board != -1: self.board.close() self.board = -1 result = osSystem( "\"" + os.path.join( os.path.normpath( os.path.dirname(os.path.realpath(__file__)) + os.sep + os.pardir) + "\\arduino\\arduino_debug") + "\" --verbose --board arduino:avr:mega:cpu=atmega2560 --port " + str(self.port) + " --upload " + self.programs[program]["path"]) if result == 0: self.hasDirectProgram = self.programs[program][ "isDirectProgram"] print("\r\nDONE !") self.easyPopup(_('Success !'), _('Upload finished successfully !')) else: self.easyPopup( _('Oopsie...'), _('Something went wrong, try again or report a bug') + "\nError code " + str(result)) except Exception as e: self.easyPopup( _('Oopsie...'), _('Something went wrong, try again or report a bug') + "\n" + str(e)) self.boardBusy = False self.refresh()
def _runPdfDiff(self, baseFileName: str, standardFileName) -> int: status: int = osSystem( f'{TestDiagramParent.EXTERNAL_PDF_DIFF_SCRIPT} {baseFileName} {standardFileName}' ) return status
def _runDiff(self, baseFileName: str, standardFileName) -> int: status: int = osSystem( f'{TestDiagramParent.EXTERNAL_DIFF_PROGRAM} {baseFileName} {standardFileName}' ) return status
def run_make_all_vs_all_fasta(infname,outfname,reportfname,verbose=False): """ Make pairwise combinations of sequences in input file with prep_launch.py @type infname: string @param infname: (absolute) path to protein multi fasta @type outfname: string @param outfname: (absolute) path to prep_launch.py output file @type reportfname: string @param reportfname: (absolute) path to prep_launch.py report file @type verbose: Boolean @param verbose: debugging messages to STDOUT (True) or not (False, default) @attention: requires global variable EXECUTABLE_cexpander_ALLVSALL @attention: this used to be called `make_all_vs_all_fasta.py` @rtype: Boolean @return: True """ command = "python %s %s %s %s" % ( EXECUTABLE_cexpander_ALLVSALL, infname, outfname, reportfname, ) if verbose: print command _retval = osSystem(command) return True
def run_make_all_vs_all_fasta(infname, outfname, reportfname, verbose=False): """ Make pairwise combinations of sequences in input file with prep_launch.py @type infname: string @param infname: (absolute) path to protein multi fasta @type outfname: string @param outfname: (absolute) path to prep_launch.py output file @type reportfname: string @param reportfname: (absolute) path to prep_launch.py report file @type verbose: Boolean @param verbose: debugging messages to STDOUT (True) or not (False, default) @attention: requires global variable EXECUTABLE_cexpander_ALLVSALL @attention: this used to be called `make_all_vs_all_fasta.py` @rtype: Boolean @return: True """ command = "python %s %s %s %s" % ( EXECUTABLE_cexpander_ALLVSALL, infname, outfname, reportfname, ) if verbose: print command _retval = osSystem(command) return True
def run_cbalignp(infname,outfname,commandline="",verbose=False): """ Run the cbalignp program by specifying input & output filenames etc. @type infname: string @param infname: (absolute) path to make_all_vs_all_fasta.py output file @type outfname: string @param outfname: (absolute) path to cbalignp output file @type commandline: string @param commandline: literal additional command line arguments for cbalignp @type verbose: Boolean @param verbose: print debugging messages to STDOUT (True) or not (False, default) @attention: requires global variable EXECUTABLE_CEXPANDER_CBALIGNP @attention: see cbalignp for (additional) command line options @attention: only a subset of cbalignp commandline options are supported! @rtype: Boolean @return: True """ command = "%s -i %s %s > %s " % ( EXECUTABLE_CEXPANDER_CBALIGNP, infname, commandline, outfname ) if verbose: print command _retval = osSystem(command) return True
def run_cbalignp(infname, outfname, commandline="", verbose=False): """ Run the cbalignp program by specifying input & output filenames etc. @type infname: string @param infname: (absolute) path to make_all_vs_all_fasta.py output file @type outfname: string @param outfname: (absolute) path to cbalignp output file @type commandline: string @param commandline: literal additional command line arguments for cbalignp @type verbose: Boolean @param verbose: print debugging messages to STDOUT (True) or not (False, default) @attention: requires global variable EXECUTABLE_CEXPANDER_CBALIGNP @attention: see cbalignp for (additional) command line options @attention: only a subset of cbalignp commandline options are supported! @rtype: Boolean @return: True """ command = "%s -i %s %s > %s " % (EXECUTABLE_CEXPANDER_CBALIGNP, infname, commandline, outfname) if verbose: print command _retval = osSystem(command) return True
def main(): global LEADERBOARD_CH_ID, QUEUE_CH_IDS, REPORT_CH_IDS token = getDiscordToken() if (token == ""): token = updateDiscordToken( input( "No Discord Bot token found. Paste your Discord Bot token below and hit ENTER.\ntoken: " )) # clear screen to hide token if osName == "nt": _ = osSystem("cls") else: _ = osSystem("clear") AWS.init() channels = getChannelIds() LEADERBOARD_CH_ID = channels["leaderboard_channel"] QUEUE_CH_IDS = channels["queue_channels"] REPORT_CH_IDS = channels["report_channels"] if (len(QUEUE_CH_IDS) > 0): client.loop.create_task(stale_queue_timer()) else: print( "Stale queue feature disabled as no queue channel id was specified." ) try: client.run(token) except discord.errors.LoginFailure: print( "! There was an error with the token you provided. Please verify your bot token and try again.\n" "If you need help locating the token for your bot, visit https://www.writebots.com/discord-bot-token/" ) sleep(5) except Exception as e: print(e)
def runcexpander(fname_fasta, cbalignp_commandline=" -y", output='binary'): """ Run the complete cascade of cexpander algorithms on an input multi fasta file and return the output as a CexpanderOutput object @type fname_fasta: string @param fname_fasta: path to input multi fasta file @type cbalignp_commandline: string @param cbalignp_commandline: (extra) command line for cbalignp @type min_cols: integer @param min_cols: minimal number of uniformly matched positions (cols) required to report transfer blocks for (>= 0) @type projected_on: string @param projected_on: apply fasta seqeunce header which to use for projection; apply ':::' to do projections on all input sequences @attention: requires global variable EXECUTABLE_cexpander_ALLVSALL @attention: requires global variable EXECUTABLE_CEXPANDER_CBALIGNP @attention: requires global variable EXECUTABLE_CEXPANDER_CEXPANDER @attention: see cexpander_dr for (additional) command line options @attention: only a subset of cexpander_dr commandline options are supported! @rtype: CexpanderOutput object @return: CexpanderOutput object """ if not fname_fasta: raise "NoProperFunctionArguments" if not osPathIsfile(fname_fasta): raise "FileDoesNotExist" # (0) create (~unique) filenames uniquetag = get_random_string_tag() fname_allvsall = ".".join([fname_fasta, uniquetag, "allvsall"]) fname_report = ".".join([fname_fasta, uniquetag, "report"]) fname_aligned = ".".join([fname_fasta, uniquetag, "aligned"]) fname_settings = ".".join([fname_fasta, uniquetag, "settings"]) fname_cexpander = ".".join([fname_fasta, uniquetag, "cexpander"]) # (1) create complete .fa -> cexpanderstring command command = """ python %s %s %s %s; %s -i %s %s > %s; %s < %s; """ % ( EXECUTABLE_CEXPANDER_ALLVSALL, fname_fasta, fname_allvsall, fname_report, EXECUTABLE_CEXPANDER_CBALIGNP, fname_allvsall, cbalignp_commandline, fname_aligned, EXECUTABLE_CEXPANDER_CEXPANDER, fname_settings, ) # (2) create fname_settings file binorfloat = "$dumpcv" if output == "float": binorfloat = "$dumpcvc" fh = open(fname_settings, 'w') content = "\n\n".join([ "$load\n%s\n%s" % (fname_report, fname_aligned), "$addquery\n-1", "$run", "$dumpentries", "$cv_linear", "%s" % (binorfloat), # BINARY == $dumpcv, FLOAT = $dumpcvc "$exit\n\n", ]) fh.write(content) fh.close() # (3) run the command ci, co, ce = osPopen3(command) ci.close() # output of EXECUTABLE_CEXPANDER_ALLVSALL is cast to STDOUT as well! cexpanderdata = co.read() co.close() error = ce.read() ce.close() # (4) parse fname_cexpander to CexpanderOutput object cxpdr = parse_cexpander(cexpanderdata, fname_fasta) # (5) cleanup files osSystem("rm -f %s %s.%s.*" % (fname_fasta, fname_fasta, uniquetag)) # (6) return the output object return cxpdr
def sim(): #VARIABLE INITIALIZATION #CLINICAL VARIABLES #Glucose level/concentration of the blood in mg/dL glucose_blood_level = 100.0 #Glucose present in the blood in mg glucose_blood = 4617.5 #Glycogen stored in the liver in mg glycogen_liver = 100000 #Glycogen stored in the muscles in mg glycogen_muscles = 500000 #Insulin present in the blood in μU/mL insulin_blood = 15.0 #Glucagon present in the blood in in pg/mL glucagon_blood = 20.00 #Amount of mg of carbohydrate that one unit of insulin will metabolize/cover carb_insulin_ratio = 15000 #Grams of glycogen that one unit/one pg of glucagon will release #NOT FACTUAL, FOR SIMULATION TESTING PURPOSES ONLY glycogenolysis_ratio = 1 #Grams of glycogen that one gram of glucose will synthesize #NOT FACTUAL, FOR SIMULATION TESTING PURPOSES ONLY glycogenesis_ratio = 1 #Grams of glucose released from one gram of glycogen #NOT FACTUAL, FOR SIMULATION TESTING PURPOSES ONLY glycogen_to_glucose_ratio = 1 #Nonessential (burnable) fat stored in adipose tissue in grams fat_nonessential = 16983.0 #Essential (non-burnable) fat stored in adipose tissue in grams fat_essential = 2830.0 #Total fat in adipose tissue in grams fat_total = 19813.0 #Number used to represent metabolic activity of the body #NOT FACTUAL, FOR SIMULATION OF METABOLIC ACTIVITY #TO ENHANCE REALISM OF SIMULATION ONLY metabolic_rate = 3 #Volume of blood in dL blood_volume = 46.175 #Insulin Sensitivity insulin_sensitivity = 1 currentTime = 0 #DATA FOR GRAPHING #Blood Glucose Level bgDataX = [] bgDataY = [] #Blood Glucose Level within target range (crrently unused) bgNormDataX = [] bgNormDataY = [] #Blood Glucose Level higher than tgarget range (currently unused) bgHighDataX = [] bgHighDataY = [] #Blood GLucose Level lower than target range (currently unused) bgLowDataX = [] bgLowDataY = [] #Blood Insulin Concentration insulinDataX = [] insulinDataY = [] #Blood Glucagon Concentration glucagonDataX = [] glucagonDataY = [] #Rate of Change Prediction ROC_predictionX = [] ROC_predictionY = [] #Metabolic Rate metabolic_rateX = [] metabolic_rateY = [] #GLycogen in liver glycogenDataX = [] glycogenDataY = [] #Loop the program forever. while (1 == 1): #CALCULATE NUMBERS currentTime += 1 #currentTime = str(datetime.now()) #currentTime = currentTime.replace("-", "") #currentTime = currentTime.replace(":", "") #currentTime = currentTime.replace(".", "") #currentTime = currentTime.replace(" ", "") #glucose_blood_level = (glucose_blood_level - insulin_blood + (glucagon_blood*12.5) - (metabolic_rate)) #- (carb_insulin_ratio*insulin_blood) + (glycogenolysis_ratio*glucagon_blood*glycogen_to_glucose_ratio)) if glycogen_liver > 0: #Release glycogen & convert to glucose glycogen_liver -= (glucagon_blood * glycogenolysis_ratio) glucose_blood += (glucagon_blood * glycogenolysis_ratio * glycogen_to_glucose_ratio) if glycogen_liver < 100000: #Absorb glucose & convert to glycogen glycogen_liver += ((insulin_blood / 1000000) * carb_insulin_ratio * glycogenesis_ratio) glucose_blood -= ((insulin_blood / 1000000 * blood_volume / 10) * carb_insulin_ratio) glucose_blood -= metabolic_rate * 10 glucose_blood_level = (glucose_blood / blood_volume) #glycogen_liver -+ (insulin_blood* #insulin_blood = insulin_blood - insulin_blood #glucagon_blood = glucagon_blood - glucagon_blood if glucose_blood_level < 0.0: glucose_blood_level = 0.0 insulinDataX.append(currentTime) insulinDataY.append(insulin_blood) glucagonDataX.append(currentTime) glucagonDataY.append(glucagon_blood) bgDataX.append(currentTime) bgDataY.append(glucose_blood_level) metabolic_rateX.append(currentTime) metabolic_rateY.append(metabolic_rate) glycogenDataX.append(currentTime) glycogenDataY.append(glycogen_liver) #nan = float('nan') if glucose_blood_level >= 80 and glucose_blood_level <= 180: bgNormDataX.append(currentTime) bgNormDataY.append(glucose_blood_level) if glucose_blood_level > 180: bgHighDataX.append(currentTime) bgHighDataY.append(glucose_blood_level) if glucose_blood_level < 80: bgLowDataX.append(currentTime) bgLowDataY.append(glucose_blood_level) if len(bgDataX) >= 3: bgRateOfChange = ((bgDataY[-1] - bgDataY[-2]) + (bgDataY[-2] - bgDataY[-3])) / 2 #Steady #ROC Prediction ROC_predictionX = [] ROC_predictionY = [] iterations = 1 for x in range(0, 6): ROC_predictionX.append(currentTime + iterations) ROC_predictionY.append(glucose_blood_level + (bgRateOfChange * iterations)) iterations += 1 if bgRateOfChange < 1 and bgRateOfChange > -1: ROC_arrows_WB = "→" ROC_arrows = "-> steady" #Rising if bgRateOfChange >= 1 and bgRateOfChange < 2: ROC_arrows_WB = "↗" ROC_arrows = "/^ slowly rising" if bgRateOfChange >= 2 and bgRateOfChange > 3: ROC_arrows_WB = "↑" ROC_arrows = "^|^ rising" if bgRateOfChange >= 3: ROC_arrows_WB = "⇈" ROC_arrows = "^|^ ^|^ rapidly rising" #Falling if bgRateOfChange <= -1 and bgRateOfChange > -2: ROC_arrows_WB = "↘" ROC_arrows = "\\v slowly falling" if bgRateOfChange <= -2 and bgRateOfChange > -3: ROC_arrows_WB = "↓" ROC_arrows = "v|v falling" if bgRateOfChange <= -3: ROC_arrows_WB = "⇊ RAPIDLY FALLING!" ROC_arrows = "v|v v|v RAPIDLY FALLING /!\\" else: bgRateOfChange = 0 ROC_arrows_WB = "N/A" ROC_arrows = "N/A" ROC_widget = Paragraph(text=ROC_arrows_WB, width=50, height=25) #UPDATE DISPLAY #Clear the terminal window if sysPlatform() == "Windows": osSystem('cls') else: osSystem("clear") #Print basic textual UI to the terminal window print("GlucoSim v0.2.2-alpha") print("2015 - 2017, created by John Kozlosky") print("") print("Blood glucose level: " + str(round(glucose_blood_level, 2)) + "mg/dL " + ROC_arrows) print("Blood glucose: " + str(round((glucose_blood / 1000), 2)) + "g") print("Glycogen: " + str(round((glycogen_liver / 1000), 2)) + "g hepatic, " + str(round(glycogen_muscles, 2) / 1000) + "g muscular") print("Blood insulin: " + str(round(insulin_blood, 2)) + "uU/mL") print("Blood glucagon: " + str(round(glucagon_blood, 2)) + "pg/mL") #print ("Fat: " + str(round(fat_total)) + "g total, " + str(round(fat_nonessential)) + "g nonessential, " + str(round(fat_essential)) + "g essential") print("Metabolic activity level: " + str(round(metabolic_rate, 4))) print("") #Make graphs using Bokeh #Blood glucose level if len(bgDataX) >= 100: bgGraph = figure() #x_axis_type="datetime") bgGraph.line(bgDataX[-100:], bgDataY[-100:], color="black") bgGraph.circle(bgDataX[-100:], bgDataY[-100:], fill_color="white", line_color="black", size=8) bgGraph.circle(ROC_predictionX, ROC_predictionY, fill_color="white", line_color="gray", size=8) #bgGraph.circle(bgNormDataX[0,100], bgNormDataY[0,100], fill_color = "white", line_color = "black", size = 8) #bgGraph.circle(bgHighDataX[0,100], bgNormDataY[0,100], fill_color = "white", line_color = "yellow", size = 8) #bgGraph.circle(bgLowDataX[0,100], bgLowDataY[0,100], fill_color = "white", line_color = "red", size = 8) bgGraph.title.text = "Blood Glucose" bgGraph.xaxis.axis_label = "Time" bgGraph.yaxis.axis_label = "Blood Glucose (mg/dL)" #bgGraph.yaxis.bounds = (0, 400) else: bgGraph = figure() #x_axis_type="datetime") bgGraph.line(bgDataX, bgDataY, color="black") bgGraph.circle(bgDataX, bgDataY, fill_color="white", line_color="black", size=8) bgGraph.circle(ROC_predictionX, ROC_predictionY, fill_color="white", line_color="gray", size=8) #bgGraph.circle(bgNormDataX, bgNormDataY, fill_color = "white", line_color = "black", size = 8) #bgGraph.circle(bgHighDataX, bgNormDataY, fill_color = "white", line_color = "yellow", size = 8) #bgGraph.circle(bgLowDataX, bgLowDataY, fill_color = "white", line_color = "red", size = 8) bgGraph.title.text = "Blood Glucose" bgGraph.xaxis.axis_label = "Time" bgGraph.yaxis.axis_label = "Blood Glucose (mg/dL)" #bgGraph.yaxis.bounds = (0, 400) #Insulin if len(insulinDataX) >= 100: insulinGraph = figure() #x_axis_type="datetime") insulinGraph.line(insulinDataX[-100:], insulinDataY[-100:], color="CadetBlue") insulinGraph.circle(insulinDataX[-100:], insulinDataY[-100:], fill_color="white", line_color="CadetBlue", size=8) insulinGraph.title.text = "Insulin" insuinGraph.xaxis.axis_label = "Time" insulinGraph.yaxis.axis_label = "Blood Insulin (μU/mL)" #insulinGraph.yaxis.bounds = (0, 400) else: insulinGraph = figure() #x_axis_type="datetime") insulinGraph.line(insulinDataX, insulinDataY, color="CadetBlue") insulinGraph.circle(insulinDataX, insulinDataY, fill_color="white", line_color="CadetBlue", size=8) insulinGraph.title.text = "Insulin" insulinGraph.xaxis.axis_label = "Time" insulinGraph.yaxis.axis_label = "Blood Insulin (μU/mL)" #insulinGraph.yaxis.bounds = (0, 400) #Glucagon if len(glucagonDataX) >= 100: glucagonGraph = figure() #x_axis_type="datetime" glucagonGraph.line(glucagonDataX[-100:], glucagonDataY[-100:], color="GoldenRod") glucagonGraph.circle(glucagonDataX[-100:], glucagonDataY[-100:], fill_color="white", line_color="GoldenRod", size=8) glucagonGraph.title.text = "Glucagon" glucagonGraph.xaxis.axis_label = "Time" glucagonGraph.yaxis.axis_label = "Blood Glucagon (pg/mL)" #glucagonGraph.yaxis.bounds = (0, 700) else: glucagonGraph = figure() #x_axis_type="datetime") glucagonGraph.line(glucagonDataX, glucagonDataY, color="GoldenRod") glucagonGraph.circle(glucagonDataX, glucagonDataY, fill_color="white", line_color="GoldenRod", size=8) glucagonGraph.title.text = "Glucagon" glucagonGraph.xaxis.axis_label = "Time" glucagonGraph.yaxis.axis_label = "Blood Glucagon (pg/mL)" #glucagonGraph.yaxis.bounds = (0, 700) #Metabolic rate if len(metabolic_rateX) >= 100: metabolicGraph = figure() metabolicGraph.line(metabolic_rateX[-100:], metabolic_rateY[-100:], color="black") metabolicGraph.circle(metabolic_rateX[-100:], metabolic_rateY[-100:], fill_color="white", line_color="black", size=8) metabolicGraph.title.text = "Metabolic Rate" metabolicGraph.xaxis.axis_label = "Time" metabolicGraph.yaxis.axis_label = "Metabolic Rate (simulated number)" else: metabolicGraph = figure() metabolicGraph.line(metabolic_rateX, metabolic_rateY, color="black") metabolicGraph.circle(metabolic_rateX, metabolic_rateY, fill_color="white", line_color="black", size=8) metabolicGraph.title.text = "Metabolic Rate" metabolicGraph.xaxis.axis_label = "Time" metabolicGraph.yaxis.axis_label = "Metabolic Rate (simulated number)" #Hepatic Glycogen if len(glycogenDataX) >= 100: glycogenGraph = figure() glycogenGraph.line(glycogenDataX[-100:], glycogenDataY[-100:], color="black") glycogenGraph.circle(glycogenDataX[-100:], glycogenDataY[-100:], fill_color="white", line_color="black", size=8) glycogenGraph.title.text = "Hepatic Glycogen" glycogenGraph.xaxis.axis_label = "Time" glycogenGraph.yaxis.axis_label = "Hepatic Glycogen (mg)" else: glycogenGraph = figure() glycogenGraph.line(glycogenDataX, glycogenDataY, color="black") glycogenGraph.circle(glycogenDataX, glycogenDataY, fill_color="white", line_color="black", size=8) glycogenGraph.title.text = "Hepatic Glycogen" glycogenGraph.xaxis.axis_label = "Time" glycogenGraph.yaxis.axis_label = "Hepatic Glycogen (mg)" #Combine the blood glucose, insulin, and glucagon graphs into a grid #grid = gridplot([bgGraph, insulinGraph, glucagonGraph], ncols=2, plot_width=600, plot_height=350) grid = layout([ [bgGraph], [insulinGraph, glucagonGraph], [metabolicGraph, glycogenGraph], [widgetbox(ROC_widget)], ], sizing_mode='stretch_both') #Write the graphs to an HTML file output_file('infoGraph.html') #GET USER COMMAND command = str(input(">")) if command == "set bg": glucose_blood = float(input("New blood glucose: ")) * blood_volume if command == "set insulin": insulin_blood = float(input("New insulin level: ")) if command == "set glucagon": glucagon_blood = float(input("New glucagon level: ")) if command == "set glycogen_liver": glycogen_liver = float(input("New hapatic glycogen level: ")) if command == "set glycogen_muscles": glycogen_muscles = float(input("New muscular glycogen level: ")) if command == "set fat_total": fat_total = float(input("New total fat: ")) if command == "set fat_nonessential": fat_nonessential = float(input("New nonessential fat: ")) if command == "set fat_essential": fat_essential = float(input("New essential fat: ")) if command == "set metabolic_rate": metabolic_rate = float(input("New metabolic activity level: ")) if command == "set blood_volume": blood_volume = float(input("New blood volume: ")) #if command == "inject bolus": #bolus = float(input("Novolog bolus size (U): ")) #if command == "ingest carb": #carb = float(input("Ingest carbs (g): ")) if command == "show": show(grid) if command == "exit": if input("Are you sure you want to exit? (y/n): ") == "y": exit() if command == "help": print("SIMULATION CONTROL") print("-----------------------") print("set bg - set new value for blood glucose level") print("set insulin - set new value for blood insulin level") print("set glucagon - set new value for blood glucagon level") print("set glycogen_liver - set new value for glycogen in liver") print( "set glycogen_muscles - set new value for glycogen in muscles") print("set metabolic_rate - set metabolic activity level") print("") print("OTHER") print("----------------------") print("help - show this menu") print("exit - exit the program") print("show - display graphs") print("") osSystem('pause')
def clearConsole(): if osName == "nt": osSystem("cls") else: osSystem("clear")
def qtrain(): global q_table_E1, q_table_E2, total_reward_bleu, total_reward_rouge list_total_reward = [0 for agent in game.list_agent] list_action = [None for agent in game.list_agent] list_state = [None for agent in game.list_agent] total_reward_bleu = [0 for i in range(TRAINING_N_EPISODE)] total_reward_rouge = [0 for i in range(TRAINING_N_EPISODE)] total_pommes_bleu = [0 for i in range(TRAINING_N_EPISODE)] total_pommes_rouge = [0 for i in range(TRAINING_N_EPISODE)] total_victimes_bleu = [0 for i in range(TRAINING_N_EPISODE)] total_victimes_rouge = [0 for i in range(TRAINING_N_EPISODE)] #Pour chaque partie for i in range(TRAINING_N_EPISODE): # variation du nombre des agents a chaque episode #game.window_nb_agents_E1 = rd.randint(1, 5) #game.window_nb_agents_E2 = rd.randint(0, 5) game.reset() #vider les lists p = np.floor(1000 * i / TRAINING_N_EPISODE) / 10 list_total_reward = [0 for agent in game.list_agent] list_action = [None for agent in game.list_agent] list_state = [None for agent in game.list_agent] osSystem("clear") #Vider la console #Message affiché à chaque itération runTime = np.floor(time.time() - startTime) timeLeft = np.floor((TRAINING_N_EPISODE - i) * (runTime / (i or 1))) runTime_h = int(runTime / 3600) runTime_m = int(runTime / 60) % 60 runTime_s = int(runTime % 60) timeLeft_h = int(timeLeft / 3600) timeLeft_m = int(timeLeft / 60) % 60 timeLeft_s = int(timeLeft % 60) runTime_h = (runTime_h < 10 and "0" or " ") + str(runTime_h) runTime_m = (runTime_m < 10 and ":0" or ":") + str(runTime_m) runTime_s = (runTime_s < 10 and ":0" or ":") + str(runTime_s) timeLeft_h = (timeLeft_h < 10 and "0" or " ") + str(timeLeft_h) timeLeft_m = (timeLeft_m < 10 and ":0" or ":") + str(timeLeft_m) timeLeft_s = (timeLeft_s < 10 and ":0" or ":") + str(timeLeft_s) print("Entrainement en cours...") print("Episode : " + str(i) + "/" + str(TRAINING_N_EPISODE)) print("(" + str(p) + "%)") print("Time elapsed: " + runTime_h + runTime_m + runTime_s) print("Estimated time left: " + timeLeft_h + timeLeft_m + timeLeft_s) print("\nQ_table sizes:") print("BLUE: " + str(len(q_table_E1.keys())) + " RED: " + str(len(q_table_E2.keys()))) #initialisation ETAT agent for k in range(len(game.list_agent)): list_state[k] = State(game.list_agent[k], game.objectsList) #Stock les etats de chaque agent #Debut partie for j in range(TRAINING_N_STEP): list_action = takeAllActions(list_state) game.update() updateQTable(list_state, list_action, list_total_reward) #stockage des total rewards for k in range(len(game.list_agent)): if game.list_agent[k].team == 1: # BLEU total_reward_bleu[ i] = total_reward_bleu[i] + list_total_reward[k] total_pommes_bleu[i] = total_pommes_bleu[i] + game.list_agent[ k].pommesMangees total_victimes_bleu[ i] = total_victimes_bleu[i] + game.list_agent[k].victimes elif game.list_agent[k].team == 2: # ROUGE total_reward_rouge[ i] = total_reward_rouge[i] + list_total_reward[k] total_pommes_rouge[i] = total_pommes_rouge[ i] + game.list_agent[k].pommesMangees total_victimes_rouge[ i] = total_victimes_rouge[i] + game.list_agent[k].victimes #print("R_bleu = " + str(total_reward_bleu)) #print("R_rouge = " + str(total_reward_rouge)) print("P_bleu = " + str(total_pommes_bleu)) print("P_rouge = " + str(total_pommes_rouge)) print("V_bleu = " + str(total_victimes_bleu)) print("V_rouge = " + str(total_victimes_rouge))
#print("BLUE SCORE : " + str(blueScore)) #print("RED SCORE : " + str(redScore)) #timer.stop() timePeriod = game.current_time_period #timer.start(timePeriod) app = QApplication(sys.argv) game = Game() if "-l" in sys.argv: load_q_tables() if "-t" in sys.argv: game.isTraining = True startTime = time.time() qtrain() save_q_tables() #plt.plot(np.linspace(1,TRAINING_N_EPISODES,TRAINING_N_EPISODES,dtype = int), total_reward_bleu) #plt.plot(np.linspace(1,TRAINING_N_EPISODES,TRAINING_N_EPISODES,dtype = int), total_reward_rouge) #plt.show() sys.exit() else: fenetre = Fenetre(game) ui = Ui_MainWindow() # classe cree par QtDesigner ui.setupUi(fenetre) game.update_parametres() osSystem("clear") timer = QTimer() timer.timeout.connect(timeout) timePeriod = ui.SpinBoxTimePeriod.value() timer.start(timePeriod) sys.exit(app.exec_())
def sim(): #VARIABLE INITIALIZATION #CLINICAL VARIABLES #Glucose level/concentration of the blood in mg/dL glucose_blood_level = 100.0 #Glucose present in the blood in mg glucose_blood = 4617.5 #Glycogen stored in the liver in mg glycogen_liver = 100000 #Glycogen stored in the muscles in mg glycogen_muscles = 500000 #Insulin present in the blood in μU/mL insulin_blood = 15.0 #Glucagon present in the blood in in pg/mL glucagon_blood = 20.00 #Amount of mg of carbohydrate that one unit of insulin will metabolize/cover carb_insulin_ratio = 15000 #Grams of glycogen that one unit/one pg of glucagon will release #NOT FACTUAL, FOR SIMULATION TESTING PURPOSES ONLY glycogenolysis_ratio = 1 #Grams of glycogen that one gram of glucose will synthesize #NOT FACTUAL, FOR SIMULATION TESTING PURPOSES ONLY glycogenesis_ratio = 1 #Grams of glucose released from one gram of glycogen #NOT FACTUAL, FOR SIMULATION TESTING PURPOSES ONLY glycogen_to_glucose_ratio = 1 #Nonessential (burnable) fat stored in adipose tissue in grams fat_nonessential = 16983.0 #Essential (non-burnable) fat stored in adipose tissue in grams fat_essential = 2830.0 #Total fat in adipose tissue in grams fat_total = 19813.0 #Number used to represent metabolic activity of the body #NOT FACTUAL, FOR SIMULATION OF METABOLIC ACTIVITY #TO ENHANCE REALISM OF SIMULATION ONLY metabolic_rate = 3 #Volume of blood in dL blood_volume = 46.175 #Insulin Sensitivity insulin_sensitivity = 1 currentTime = 0 #DATA FOR GRAPHING #Blood Glucose Level bgDataX = [] bgDataY = [] #Blood Glucose Level within target range (crrently unused) bgNormDataX = [] bgNormDataY = [] #Blood Glucose Level higher than tgarget range (currently unused) bgHighDataX = [] bgHighDataY = [] #Blood GLucose Level lower than target range (currently unused) bgLowDataX = [] bgLowDataY = [] #Blood Insulin Concentration insulinDataX = [] insulinDataY = [] #Blood Glucagon Concentration glucagonDataX = [] glucagonDataY = [] #Rate of Change Prediction ROC_predictionX = [] ROC_predictionY = [] #Metabolic Rate metabolic_rateX = [] metabolic_rateY = [] #GLycogen in liver glycogenDataX = [] glycogenDataY = [] #Loop the program forever. while(1==1): #CALCULATE NUMBERS currentTime+=1 #currentTime = str(datetime.now()) #currentTime = currentTime.replace("-", "") #currentTime = currentTime.replace(":", "") #currentTime = currentTime.replace(".", "") #currentTime = currentTime.replace(" ", "") #glucose_blood_level = (glucose_blood_level - insulin_blood + (glucagon_blood*12.5) - (metabolic_rate)) #- (carb_insulin_ratio*insulin_blood) + (glycogenolysis_ratio*glucagon_blood*glycogen_to_glucose_ratio)) if glycogen_liver > 0: #Release glycogen & convert to glucose glycogen_liver -= (glucagon_blood*glycogenolysis_ratio) glucose_blood += (glucagon_blood*glycogenolysis_ratio*glycogen_to_glucose_ratio) if glycogen_liver < 100000: #Absorb glucose & convert to glycogen glycogen_liver += ((insulin_blood/1000000)*carb_insulin_ratio*glycogenesis_ratio) glucose_blood -= ((insulin_blood/1000000*blood_volume/10)*carb_insulin_ratio) glucose_blood -= metabolic_rate*10 glucose_blood_level = (glucose_blood/blood_volume) #glycogen_liver -+ (insulin_blood* #insulin_blood = insulin_blood - insulin_blood #glucagon_blood = glucagon_blood - glucagon_blood if glucose_blood_level < 0.0: glucose_blood_level = 0.0 insulinDataX.append(currentTime) insulinDataY.append(insulin_blood) glucagonDataX.append(currentTime) glucagonDataY.append(glucagon_blood) bgDataX.append(currentTime) bgDataY.append(glucose_blood_level) metabolic_rateX.append(currentTime) metabolic_rateY.append(metabolic_rate) glycogenDataX.append(currentTime) glycogenDataY.append(glycogen_liver) #nan = float('nan') if glucose_blood_level >= 80 and glucose_blood_level <= 180: bgNormDataX.append(currentTime) bgNormDataY.append(glucose_blood_level) if glucose_blood_level > 180: bgHighDataX.append(currentTime) bgHighDataY.append(glucose_blood_level) if glucose_blood_level < 80: bgLowDataX.append(currentTime) bgLowDataY.append(glucose_blood_level) if len(bgDataX) >=3: bgRateOfChange = ((bgDataY[-1] - bgDataY[-2]) + (bgDataY[-2] - bgDataY[-3]))/2 #Steady #ROC Prediction ROC_predictionX = [] ROC_predictionY = [] iterations = 1 for x in range (0,6): ROC_predictionX.append(currentTime + iterations) ROC_predictionY.append(glucose_blood_level + (bgRateOfChange*iterations)) iterations += 1 if bgRateOfChange < 1 and bgRateOfChange > -1: ROC_arrows_WB = "→" ROC_arrows = "-> steady" #Rising if bgRateOfChange >= 1 and bgRateOfChange < 2: ROC_arrows_WB = "↗" ROC_arrows = "/^ slowly rising" if bgRateOfChange >= 2 and bgRateOfChange > 3: ROC_arrows_WB = "↑" ROC_arrows = "^|^ rising" if bgRateOfChange >= 3: ROC_arrows_WB = "⇈" ROC_arrows = "^|^ ^|^ rapidly rising" #Falling if bgRateOfChange <= -1 and bgRateOfChange > -2: ROC_arrows_WB = "↘" ROC_arrows = "\\v slowly falling" if bgRateOfChange <= -2 and bgRateOfChange > -3: ROC_arrows_WB = "↓" ROC_arrows = "v|v falling" if bgRateOfChange <= -3: ROC_arrows_WB = "⇊ RAPIDLY FALLING!" ROC_arrows = "v|v v|v RAPIDLY FALLING /!\\" else: bgRateOfChange = 0 ROC_arrows_WB = "N/A" ROC_arrows = "N/A" ROC_widget = Paragraph(text=ROC_arrows_WB, width=50, height=25) #UPDATE DISPLAY #Clear the terminal window if sysPlatform() == "Windows": osSystem('cls') else: osSystem("clear") #Print basic textual UI to the terminal window print ("Diabetes/Body Energy Simulation Project") print ("2015 - 2016, created by John Kozlosky") print ("") print ("Blood glucose level: " + str(round(glucose_blood_level, 2)) + "mg/dL " + ROC_arrows) print ("Blood glucose: " + str(round((glucose_blood/1000), 2)) + "g") print ("Glycogen: " + str(round((glycogen_liver/1000), 2)) + "g hepatic, " + str(round(glycogen_muscles, 2)/1000) + "g muscular") print ("Blood insulin: " + str(round(insulin_blood, 2)) + "uU/mL") print ("Blood glucagon: " + str(round(glucagon_blood, 2)) + "pg/mL") #print ("Fat: " + str(round(fat_total)) + "g total, " + str(round(fat_nonessential)) + "g nonessential, " + str(round(fat_essential)) + "g essential") print ("Metabolic activity level: " + str(round(metabolic_rate, 4))) print ("") #Make graphs using Bokeh #Blood glucose level if len(bgDataX) >= 100: bgGraph = figure()#x_axis_type="datetime") bgGraph.line(bgDataX[-100:], bgDataY[-100:], color = "black") bgGraph.circle(bgDataX[-100:], bgDataY[-100:], fill_color = "white", line_color = "black", size = 8) bgGraph.circle(ROC_predictionX, ROC_predictionY, fill_color = "white", line_color = "gray", size = 8) #bgGraph.circle(bgNormDataX[0,100], bgNormDataY[0,100], fill_color = "white", line_color = "black", size = 8) #bgGraph.circle(bgHighDataX[0,100], bgNormDataY[0,100], fill_color = "white", line_color = "yellow", size = 8) #bgGraph.circle(bgLowDataX[0,100], bgLowDataY[0,100], fill_color = "white", line_color = "red", size = 8) bgGraph.title.text = "Blood Glucose" bgGraph.xaxis.axis_label = "Time" bgGraph.yaxis.axis_label = "Blood Glucose (mg/dL)" #bgGraph.yaxis.bounds = (0, 400) else: bgGraph = figure()#x_axis_type="datetime") bgGraph.line(bgDataX, bgDataY, color = "black") bgGraph.circle(bgDataX, bgDataY, fill_color = "white", line_color = "black", size = 8) bgGraph.circle(ROC_predictionX, ROC_predictionY, fill_color = "white", line_color = "gray", size = 8) #bgGraph.circle(bgNormDataX, bgNormDataY, fill_color = "white", line_color = "black", size = 8) #bgGraph.circle(bgHighDataX, bgNormDataY, fill_color = "white", line_color = "yellow", size = 8) #bgGraph.circle(bgLowDataX, bgLowDataY, fill_color = "white", line_color = "red", size = 8) bgGraph.title.text = "Blood Glucose" bgGraph.xaxis.axis_label = "Time" bgGraph.yaxis.axis_label = "Blood Glucose (mg/dL)" #bgGraph.yaxis.bounds = (0, 400) #Insulin if len(insulinDataX) >= 100: insulinGraph = figure()#x_axis_type="datetime") insulinGraph.line(insulinDataX[-100:], insulinDataY[-100:], color = "CadetBlue") insulinGraph.circle(insulinDataX[-100:], insulinDataY[-100:], fill_color = "white", line_color = "CadetBlue", size = 8) insulinGraph.title.text = "Insulin" insuinGraph.xaxis.axis_label = "Time" insulinGraph.yaxis.axis_label = "Blood Insulin (μU/mL)" #insulinGraph.yaxis.bounds = (0, 400) else: insulinGraph = figure()#x_axis_type="datetime") insulinGraph.line(insulinDataX, insulinDataY, color = "CadetBlue") insulinGraph.circle(insulinDataX, insulinDataY, fill_color = "white", line_color = "CadetBlue", size = 8) insulinGraph.title.text = "Insulin" insulinGraph.xaxis.axis_label = "Time" insulinGraph.yaxis.axis_label = "Blood Insulin (μU/mL)" #insulinGraph.yaxis.bounds = (0, 400) #Glucagon if len(glucagonDataX) >= 100: glucagonGraph = figure()#x_axis_type="datetime" glucagonGraph.line(glucagonDataX[-100:], glucagonDataY[-100:], color = "GoldenRod") glucagonGraph.circle(glucagonDataX[-100:], glucagonDataY[-100:], fill_color = "white", line_color = "GoldenRod", size = 8) glucagonGraph.title.text = "Glucagon" glucagonGraph.xaxis.axis_label = "Time" glucagonGraph.yaxis.axis_label = "Blood Glucagon (pg/mL)" #glucagonGraph.yaxis.bounds = (0, 700) else: glucagonGraph = figure()#x_axis_type="datetime") glucagonGraph.line(glucagonDataX, glucagonDataY, color = "GoldenRod") glucagonGraph.circle(glucagonDataX, glucagonDataY, fill_color = "white", line_color = "GoldenRod", size = 8) glucagonGraph.title.text = "Glucagon" glucagonGraph.xaxis.axis_label = "Time" glucagonGraph.yaxis.axis_label = "Blood Glucagon (pg/mL)" #glucagonGraph.yaxis.bounds = (0, 700) #Metabolic rate if len(metabolic_rateX) >= 100: metabolicGraph = figure() metabolicGraph.line(metabolic_rateX[-100:], metabolic_rateY[-100:], color = "black") metabolicGraph.circle(metabolic_rateX[-100:], metabolic_rateY[-100:], fill_color = "white", line_color = "black", size = 8) metabolicGraph.title.text = "Metabolic Rate" metabolicGraph.xaxis.axis_label = "Time" metabolicGraph.yaxis.axis_label = "Metabolic Rate (simulated number)" else: metabolicGraph = figure() metabolicGraph.line(metabolic_rateX, metabolic_rateY, color = "black") metabolicGraph.circle(metabolic_rateX, metabolic_rateY, fill_color = "white", line_color = "black", size = 8) metabolicGraph.title.text = "Metabolic Rate" metabolicGraph.xaxis.axis_label = "Time" metabolicGraph.yaxis.axis_label = "Metabolic Rate (simulated number)" #Hepatic Glycogen if len(glycogenDataX) >= 100: glycogenGraph = figure() glycogenGraph.line(glycogenDataX[-100:], glycogenDataY[-100:], color = "black") glycogenGraph.circle(glycogenDataX[-100:], glycogenDataY[-100:], fill_color = "white", line_color = "black", size = 8) glycogenGraph.title.text = "Hepatic Glycogen" glycogenGraph.xaxis.axis_label = "Time" glycogenGraph.yaxis.axis_label = "Hepatic Glycogen (mg)" else: glycogenGraph = figure() glycogenGraph.line(glycogenDataX, glycogenDataY, color = "black") glycogenGraph.circle(glycogenDataX, glycogenDataY, fill_color = "white", line_color = "black", size = 8) glycogenGraph.title.text = "Hepatic Glycogen" glycogenGraph.xaxis.axis_label = "Time" glycogenGraph.yaxis.axis_label = "Hepatic Glycogen (mg)" #Combine the blood glucose, insulin, and glucagon graphs into a grid #grid = gridplot([bgGraph, insulinGraph, glucagonGraph], ncols=2, plot_width=600, plot_height=350) grid = layout([ [bgGraph], [insulinGraph, glucagonGraph], [metabolicGraph, glycogenGraph], [widgetbox(ROC_widget)], ], sizing_mode='stretch_both') #Write the graphs to an HTML file output_file('infoGraph.html') #GET USER COMMAND command = str(input(">")) if command == "set bg": glucose_blood = float(input("New blood glucose: "))*blood_volume if command == "set insulin": insulin_blood = float(input("New insulin level: ")) if command == "set glucagon": glucagon_blood = float(input("New glucagon level: ")) if command == "set glycogen_liver": glycogen_liver = float(input("New hapatic glycogen level: ")) if command == "set glycogen_muscles": glycogen_muscles = float(input("New muscular glycogen level: ")) if command == "set fat_total": fat_total = float(input("New total fat: ")) if command == "set fat_nonessential": fat_nonessential = float(input("New nonessential fat: ")) if command == "set fat_essential": fat_essential = float(input("New essential fat: ")) if command == "set metabolic_rate": metabolic_rate = float(input("New metabolic activity level: ")) if command == "set blood_volume": blood_volume = float(input("New blood volume: ")) #if command == "inject bolus": #bolus = float(input("Novolog bolus size (U): ")) #if command == "ingest carb": #carb = float(input("Ingest carbs (g): ")) if command == "show": show(grid) if command == "exit": if input("Are you sure you want to exit? (y/n): ") == "y": exit() if command == "help": print("SIMULATION CONTROL") print("-----------------------") print("set bg - set new value for blood glucose level") print("set insulin - set new value for blood insulin level") print("set glucagon - set new value for blood glucagon level") print("set glycogen_liver - set new value for glycogen in liver") print("set glycogen_muscles - set new value for glycogen in muscles") print("set metabolic_rate - set metabolic activity level") print("") print("OTHER") print("----------------------") print("help - show this menu") print("exit - exit the program") print("show - display graphs") print("") osSystem('pause')
def runcexpander(fname_fasta,cbalignp_commandline=" -y",output='binary'): """ Run the complete cascade of cexpander algorithms on an input multi fasta file and return the output as a CexpanderOutput object @type fname_fasta: string @param fname_fasta: path to input multi fasta file @type cbalignp_commandline: string @param cbalignp_commandline: (extra) command line for cbalignp @type min_cols: integer @param min_cols: minimal number of uniformly matched positions (cols) required to report transfer blocks for (>= 0) @type projected_on: string @param projected_on: apply fasta seqeunce header which to use for projection; apply ':::' to do projections on all input sequences @attention: requires global variable EXECUTABLE_cexpander_ALLVSALL @attention: requires global variable EXECUTABLE_CEXPANDER_CBALIGNP @attention: requires global variable EXECUTABLE_CEXPANDER_CEXPANDER @attention: see cexpander_dr for (additional) command line options @attention: only a subset of cexpander_dr commandline options are supported! @rtype: CexpanderOutput object @return: CexpanderOutput object """ if not fname_fasta: raise "NoProperFunctionArguments" if not osPathIsfile(fname_fasta): raise "FileDoesNotExist" # (0) create (~unique) filenames uniquetag = get_random_string_tag() fname_allvsall = ".".join([fname_fasta,uniquetag,"allvsall"]) fname_report = ".".join([fname_fasta,uniquetag,"report"]) fname_aligned = ".".join([fname_fasta,uniquetag,"aligned"]) fname_settings = ".".join([fname_fasta,uniquetag,"settings"]) fname_cexpander = ".".join([fname_fasta,uniquetag,"cexpander"]) # (1) create complete .fa -> cexpanderstring command command = """ python %s %s %s %s; %s -i %s %s > %s; %s < %s; """ % ( EXECUTABLE_CEXPANDER_ALLVSALL, fname_fasta, fname_allvsall, fname_report, EXECUTABLE_CEXPANDER_CBALIGNP, fname_allvsall, cbalignp_commandline, fname_aligned, EXECUTABLE_CEXPANDER_CEXPANDER, fname_settings, ) # (2) create fname_settings file binorfloat = "$dumpcv" if output == "float": binorfloat = "$dumpcvc" fh = open(fname_settings,'w') content = "\n\n".join( [ "$load\n%s\n%s" % (fname_report,fname_aligned), "$addquery\n-1", "$run", "$dumpentries", "$cv_linear", "%s" % ( binorfloat ), # BINARY == $dumpcv, FLOAT = $dumpcvc "$exit\n\n", ] ) fh.write(content) fh.close() # (3) run the command ci,co,ce = osPopen3(command) ci.close() # output of EXECUTABLE_CEXPANDER_ALLVSALL is cast to STDOUT as well! cexpanderdata = co.read() co.close() error = ce.read() ce.close() # (4) parse fname_cexpander to CexpanderOutput object cxpdr = parse_cexpander(cexpanderdata,fname_fasta) # (5) cleanup files osSystem("rm -f %s %s.%s.*" % ( fname_fasta, fname_fasta,uniquetag ) ) # (6) return the output object return cxpdr