import sys import os # Get the directory containing the current file current_dir = os.path.dirname(os.path.abspath(__file__)) # Append the 'sedmlEditor' directory to the system path sys.path.append(os.path.join(current_dir, '../sedmlEditor/')) from sedDict import create_dict_sedDocment, add_sedTask2dict from sedEditor import create_sedDocment,write_sedml, validate_sedml # Convert the model to CellML 2.0 if needed model_name='GLUT2_BG' path_='../Facilitated transporter/CellMLV2/' sedFilename = model_name+'_ss_io.sedml' full_path = os.path.join(current_dir, path_, sedFilename) model_path ='../' # ********** The following is to create a dictionary for the sedml file ********** dict_sedDocument=create_dict_sedDocment() # ********** TThe above can be commented out if the model is already in CellML 2.0 ********** for model_id in range(250): # ********** The following is to create a dictionary for the sedml file ********** sed_model_id = model_name+f'_{model_id}_io' # This is the model id in the sedml, could be different from the model file name # ********** The following is to add the task information to the dictionary ********** # Note: the following is an example, you can modify it to add more tasks # Note: the valid sedml id should start with a letter, and only contain letters, numbers, and underscores # This is the model file name, assuming in the same folder with the sedml file model_source = model_path + model_name + '.cellml' # This is to modify the model parameters if needed if model_id == 0: changes={'g_i':{'component':'params_BG','name':'g_i','newValue':'1e-4'}, 'g_o':{'component':'params_BG','name':'g_o','newValue':'1e-4'}} else: changes={'g_i':{'component':'params_BG','name':'g_i','newValue':f'{model_id/10}'}, 'g_o':{'component':'params_BG','name':'g_o','newValue':'1e-4'} } # the format is {'id':{'component':str,'name':str,'newValue':str}} # Example: changes={'V_m':{'component':'main','name':'V_m','newValue':'-0.055'} # This is the output of the simulation, and the key is part of the output id # The value is a dictionary with the following keys: 'component', 'name', 'scale' # component is the component name in the CellML model where the output variable is defined # name is the variable name of the outputs # scale is the scaling factor for the output variable outputs={'t':{'component':'GLUT2_BG','name':'t','scale':1}, 'v_r1':{'component':'GLUT2_BG','name':'v_r1','scale':-1}, 'q_init_Ai':{'component':'GLUT2_BG','name':'q_init_Ai','scale':1/0.09}, } # You can add more outputs if needed # The following is the simulation setting # This is to set the maximum step size for the simulation dict_algorithmParameter={'kisaoID':'KISAO:0000467', 'name':'max_step','value':'100'} # You can set more algorithm parameters if needed. You can refer to get_KISAO_parameters() in src/simulator.py file to get the parameters for the specific algorithm # Add the algorithm parameters to listOfAlgorithmParameters # You can choose one of the simulation algorithms specified by KISAO_ALGORITHMS in src/simulator.py file dict_algorithm={'kisaoID':'KISAO:0000088','name':'LSODA','listOfAlgorithmParameters':[dict_algorithmParameter]} # This is the simulation setting # You can choose one of the following simulation types: 'UniformTimeCourse', 'OneStep' simSetting={'type':'UniformTimeCourse','algorithm':dict_algorithm,'initialTime':0,'outputStartTime':250,'outputEndTime':250,'numberOfSteps':0} # simSetting={'type':'OneStep','algorithm':dict_algorithm,'step':0.1} # The following is to add the task information to the dictionary add_sedTask2dict(dict_sedDocument, sed_model_id, model_source,changes,simSetting,outputs) # You can repeat the above steps to add more tasks with DIFFERENT model names. # ********** The following is to create the sedml file, no need to modify ********** try: doc=create_sedDocment(dict_sedDocument) except ValueError as err: print(err) write_sedml(doc,full_path) print(validate_sedml(full_path))