generateRules

PURPOSE ^

If a model does not have a model.rules field but has a model.grRules

SYNOPSIS ^

function [model2] = generateRules(model)

DESCRIPTION ^

 If a model does not have a model.rules field but has a model.grRules
 field, can be regenerated using this script

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [model2] = generateRules(model)
0002 % If a model does not have a model.rules field but has a model.grRules
0003 % field, can be regenerated using this script
0004 
0005 % Input:
0006 %       model               with model.grRules***
0007 % Output:
0008 %       model2              same model but with model.rules added
0009 
0010 % Aarash Bordar 11/17/2010
0011 
0012 grRules = model.grRules;
0013 genes = model.genes;
0014 
0015 [m,n] = size(model.S);
0016 
0017 rules(1:n,1) = {''};
0018 
0019 for i = 1:n
0020     if length(grRules{i}) > 0
0021         tmp = grRules{i};
0022         
0023         tmp = splitString(tmp,' ');
0024         tmp = strrep(tmp,' ','');
0025         
0026         tmp2 = [];
0027         for j = 1:length(tmp)
0028             if strcmp(tmp{j},'or')
0029                 tmp2 = [tmp2,'| '];
0030             elseif strcmp(tmp{j},'and')
0031                 tmp2 = [tmp2,'& '];
0032             elseif strcmp(tmp{j}(1),'(') & strcmp(tmp{j}(end),')')
0033                 tmp{j} = strrep(tmp{j},'(','');
0034                 tmp{j} = strrep(tmp{j},')','');
0035                 loc = strmatch(tmp{j},genes,'exact');
0036                 tmp2 = [tmp2,'(x(',num2str(loc),')) '];
0037             elseif strcmp(tmp{j}(1),'(')
0038                 tmp{j} = strrep(tmp{j},'(','');
0039                 tmp{j} = strrep(tmp{j},')','');
0040                 loc = strmatch(tmp{j},genes,'exact');
0041                 tmp2 = [tmp2,'(x(',num2str(loc),') ']; 
0042             elseif strcmp(tmp{j}(end),')')
0043                 tmp{j} = strrep(tmp{j},'(','');
0044                 tmp{j} = strrep(tmp{j},')','');
0045                 loc = strmatch(tmp{j},genes,'exact');
0046                 tmp2 = [tmp2,'x(',num2str(loc),')) ']; 
0047             else
0048                 loc = strmatch(tmp{j},genes,'exact');
0049                 tmp2 = [tmp2,'x(',num2str(loc),') '];
0050             end
0051         end
0052         
0053         tmp2 = tmp2(1:end-1);
0054         rules{i} = tmp2;
0055    
0056     end
0057 end
0058 
0059 
0060 model2 = model;
0061 model2.rules = rules;

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003