Home > matlab > model_embedding_SBML.m

model_embedding_SBML

PURPOSE ^

--------------------------------------------------------------------------

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 --------------------------------------------------------------------------
 Run model embedding 
 (example models are defined by SBML files (for models) and SBtab file (for position table)
 ---------------------------------------------------------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % --------------------------------------------------------------------------
0002 % Run model embedding
0003 % (example models are defined by SBML files (for models) and SBtab file (for position table)
0004 % ---------------------------------------------------------------------------
0005 
0006 clear
0007 
0008 % Input file names
0009 
0010 Resource_DIR              = [me_BASEDIR '/../resources/models/example_1_sbml/'];
0011 
0012 kinetic_model_infile_sbml = {[Resource_DIR '/example_1_sbml_kinetic_model.xml']};
0013 network_model_infile_sbml =  [Resource_DIR '/example_1_sbml_network.xml'];
0014 position_file             =  [Resource_DIR '/example_1_sbml_Position.tsv'];
0015 
0016 
0017 % MATLAB file names
0018 
0019 % You may change the following path to any suitable directory in your system
0020 DIR = '/tmp/model_embedding_tmp/'; 
0021 
0022 infile_matlab  = [DIR '/embedding_example_1_sbml'];
0023 outfile_matlab = [DIR '/embedding_example_1_sbml_result'];
0024 outfile_sbml   = [DIR '/embedding_example_1_sbml_flat.xml'];
0025 
0026 
0027 % Model options
0028 
0029 me_options                      = struct;
0030 me_options.id                   = [];
0031 me_options.Tmax                 = 5; 
0032 me_options.c_init               = [0 0 0 0 1]';
0033 me_options.fba_constraints_zv   = [0 0 1 1]';
0034 me_options.arrowsize            = 0.1;
0035 me_options.squaresize           = 0.1;
0036 me_options.text_offset          = [0.05,0.02];
0037 me_options.arrowvaluesmax       = 1.2;
0038 me_options.legendFontsize       = 12;
0039 me_options.position_file        = position_file;
0040 me_options.enforce_stationarity = 0;
0041 me_options.verbose              = 0;
0042 
0043 
0044 % Directives
0045 
0046 flag_prepare_model = 1;
0047 
0048 
0049 % ---------------------------------------------------------------------------
0050 % Prepare models in matlab format - Model variables :
0051 %
0052 %   kinetic_models - list of kinetic models to be embedded
0053 %                    steady state concentrations for kinetic models
0054 %                    must be given in fields 's_init'
0055 %   network        - network model into which they are embedded
0056 %   network_CoHid  - version with cofactors omitted (only for graphics)
0057 %   me_options     - directives for model embedding, for details see 'model_embedding'
0058 %   c_init         - initial state (augmented model), only used for dynamic simulations
0059 %   T_max          - duration of dynamic simulations
0060 
0061 
0062 if flag_prepare_model,
0063 
0064   network = network_sbml_import(network_model_infile_sbml);
0065   network.compartment_sizes = 1;
0066   
0067   if 0,
0068     %% This command allows you to rearrange the network layout
0069     %% The new layout will be saved to the Position file
0070     netgraph_edit_positions(network,position_file,0);
0071   end
0072   
0073   for it = 1:length(kinetic_model_infile_sbml), 
0074     kinetic_models{it} = network_sbml_import(kinetic_model_infile_sbml{it});
0075     kinetic_models{it}.compartment_sizes = 1;
0076   end
0077   
0078   fba_constraints    = fba_default_options(network);
0079   fba_constraints.zv = me_options.fba_constraints_zv;
0080   
0081   me_options.fba_constraints = fba_constraints;
0082   me_options                 = join_struct(model_embedding_default_options,me_options);
0083 
0084   network_CoHid  = network;
0085   
0086   save(infile_matlab,'kinetic_models','network','network_CoHid','me_options');
0087 
0088   display(sprintf('Wrote matlab input model file %s',infile_matlab));
0089 
0090 else 
0091 
0092   load(infile_matlab);
0093 
0094 end
0095 
0096 
0097 % ------------------------------------------------------------
0098 % Run model embedding
0099 
0100 
0101 [network_combined, res, network_aug, network_aug_CoHid,network_aug_CoSplit ] = model_embedding(kinetic_models, network, network_CoHid, me_options );
0102 
0103 if 0,
0104   %% Again, this command allows you to rearrange the network layout
0105   %% The new layout will be saved to the Position file
0106   netgraph_edit_positions(network_aug_CoSplit, me_options.position_file,0);
0107 end
0108 
0109 flux_stationary = flux_check_stationarity(network_combined,res.v_combined) 
0110 
0111 
0112 % ------------------------------------------------------------
0113 % Run simulations
0114 
0115 c_init  = me_options.c_init;
0116 Tmax    = me_options.Tmax  ;
0117 
0118 if isempty(c_init),
0119   c_init = res.c_combined; c_init(1) = 5 * c_init(1);
0120 end
0121 
0122 v_init = network_velocities(c_init,network_combined);
0123 
0124 % First embedded model
0125 [simulation.t, simulation.C] = network_integrate(network_combined, c_init, Tmax);
0126 
0127 % First embedded model, simulated in isolation
0128 [simulation_local.t, simulation_local.C] = network_integrate(network_combined.kinetics.kinetic_models{1}, c_init(res.mapping_metabolites{1}), Tmax);
0129 
0130 
0131 % ------------------------------------------------------------
0132 % Make "flat" kinetics field and run simulation (only as check)
0133 
0134 try
0135   network_flat = model_embedding_kinetics_combined2flat(network_combined);
0136   [simulation_flat.t, simulation_flat.C] = network_integrate(network_flat, c_init, Tmax);
0137 catch
0138   network_flat      = [];
0139   simulation_flat.t = [];
0140 end
0141 
0142 
0143 % ------------------------------------------------------------
0144 % save model
0145 
0146 if length(network_flat),
0147   network_sbml_export(network_flat,0,'Combined model',outfile_sbml);
0148 end
0149 
0150 save(outfile_matlab,'network_combined', 'res', 'network_aug', 'network_aug_CoHid', 'network_aug_CoSplit', 'c_init','v_init','simulation','simulation_local','network_flat','simulation_flat');
0151 
0152 
0153 % ------------------------------------------------------------
0154 % make graphics
0155 
0156 if 0,
0157   load(infile_matlab);
0158   load(outfile_matlab);
0159 end
0160 
0161 ca; 
0162 
0163 psfile_dir         = [];
0164 flag_save_graphics = length(psfile_dir);
0165 
0166 model_embedding_graphics;

Generated on Fri 12-Feb-2016 20:05:51 by m2html © 2003