diff --git a/.gitattributes b/.gitattributes index 012b630f..3e0ca4ab 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,6 +5,7 @@ # Mark as binary to prevent EOL changes. Also no need to track mafft.bat binary mafft/ binary +mafft binary # Files/folders that should not be included when downloading repo as ZIP .gitattributes export-ignore .gitignore export-ignore diff --git a/INIT/runINIT.m b/INIT/runINIT.m index 5221b858..9da20c4a 100644 --- a/INIT/runINIT.m +++ b/INIT/runINIT.m @@ -283,7 +283,7 @@ prob.b=zeros(size(prob.a,1), 1); prob.ub=[prob.bux; prob.buc]; prob.osense=1; -prob.csense=char(1,zeros(size(prob.a,1))); +prob.csense=char(zeros(1,size(prob.a,1))); prob.csense(:)='E'; %We still don't know which of the presentMets that can be produced. Go diff --git a/core/addRxns.m b/core/addRxns.m index 05172dfa..4dd9a94c 100755 --- a/core/addRxns.m +++ b/core/addRxns.m @@ -60,7 +60,7 @@ % interpreted % 1 - The metabolites are matched to model.mets. New % metabolites (if allowed) are added to -% "compartment" +% "compartment" (default) % 2 - The metabolites are matched to model.metNames and % all metabolites are assigned to "compartment". Any % new metabolites that are added will be assigned @@ -101,6 +101,16 @@ % Usage: newModel=addRxns(model,rxnsToAdd,eqnType,compartment,... % allowNewMets,allowNewGenes) +if nargin<3 + eqnType=1; +elseif ~isnumeric(eqnType) + EM='eqnType must be numeric'; + dispEM(EM); +elseif ~ismember(eqnType,[1 2 3]) + EM='eqnType must be 1, 2, or 3'; + dispEM(EM); +end + if nargin<4 compartment=[]; else @@ -139,17 +149,6 @@ return; end -%Check the input -if isfield(rxnsToAdd,'stoichCoeffs') - eqnType=1; -elseif ~isnumeric(eqnType) - EM='eqnType must be numeric'; - dispEM(EM); -elseif ~ismember(eqnType,[1 2 3]) - EM='eqnType must be 1, 2, or 3'; - dispEM(EM); -end - if eqnType==2 || (eqnType==1 && allowNewMets==true) compartment=char(compartment); if ~ismember(compartment,model.comps) @@ -518,18 +517,18 @@ if eqnType==1 [I, J]=ismember(mets,model.mets); if ~all(I) - if allowNewMets==true | isstr(allowNewMets) + if allowNewMets==true || ischar(allowNewMets) %Add the new mets metsToAdd.mets=mets(~I); metsToAdd.metNames=metsToAdd.mets; metsToAdd.compartments=compartment; - if isstr(allowNewMets) + if ischar(allowNewMets) newModel=addMets(newModel,metsToAdd,true,allowNewMets); else newModel=addMets(newModel,metsToAdd,true); end else - EM='One or more equations contain metabolites that are not in model.mets. Set allowNewMets to true to allow this function to add metabolites or use addMets to add them before calling this function'; + EM='One or more equations contain metabolites that are not in model.mets. Set allowNewMets to true to allow this function to add metabolites or use addMets to add them before calling this function. Are you sure that eqnType=1?'; dispEM(EM); end end @@ -553,11 +552,11 @@ [I, J]=ismember(t1,t2); if ~all(I) - if allowNewMets==true | isstr(allowNewMets) + if allowNewMets==true || ischar(allowNewMets) %Add the new mets metsToAdd.metNames=mets(~I); metsToAdd.compartments=compartment; - if isstr(allowNewMets) + if ischar(allowNewMets) newModel=addMets(newModel,metsToAdd,true,allowNewMets); else newModel=addMets(newModel,metsToAdd,true); @@ -603,11 +602,11 @@ [I, J]=ismember(t1,t2); if ~all(I) - if allowNewMets==true | isstr(allowNewMets) + if allowNewMets==true || ischar(allowNewMets) %Add the new mets metsToAdd.metNames=metNames(~I); metsToAdd.compartments=compartments(~I); - if isstr(allowNewMets) + if ischar(allowNewMets) newModel=addMets(newModel,metsToAdd,true,allowNewMets); else newModel=addMets(newModel,metsToAdd,true); diff --git a/core/changeRxns.m b/core/changeRxns.m index e4b068cc..aee91e85 100755 --- a/core/changeRxns.m +++ b/core/changeRxns.m @@ -13,7 +13,7 @@ % interpreted % 1 - The metabolites are matched to model.mets. New % metabolites (if allowed) are added to -% "compartment" +% "compartment" (default) % 2 - The metabolites are matched to model.metNames and % all metabolites are assigned to "compartment". Any % new metabolites that are added will be assigned @@ -53,7 +53,7 @@ % % Usage: model=changeRxns(model,rxns,equations,eqnType,compartment,allowNewMets) -if nargin<4 & isfield(equations,'stoichCoeffs') +if nargin<4 eqnType=1; end @@ -65,7 +65,6 @@ end rxns=convertCharArray(rxns); -equations=convertCharArray(equations); compartment=char(compartment); %Find the indexes of the reactions and throw an error if they aren't all @@ -86,7 +85,7 @@ rxnsToChange.mets=equations.mets; rxnsToChange.stoichCoeffs=equations.stoichCoeffs; else - rxnsToChange.equations=equations; + rxnsToChange.equations=convertCharArray(equations); end if isfield(model,'rxnNames') rxnsToChange.rxnNames=model.rxnNames(J); diff --git a/core/getGenesFromGrRules.m b/core/getGenesFromGrRules.m index 176ec081..7f84fa5f 100644 --- a/core/getGenesFromGrRules.m +++ b/core/getGenesFromGrRules.m @@ -1,9 +1,9 @@ -function [genes,rxnGeneMat] = getGenesFromGrRules(grRules) +function [genes,rxnGeneMat] = getGenesFromGrRules(grRules, originalGenes) %getGenesFromGrRules Extract gene list and rxnGeneMat from grRules array. % % USAGE: % -% [genes,rxnGeneMat] = getGenesFromGrRules(grRules); +% [genes,rxnGeneMat] = getGenesFromGrRules(grRules, originalGenes); % % INPUTS: % @@ -12,6 +12,7 @@ % NOTE: Boolean operators can be text ("and", "or") or % symbolic ("&", "|"), but there must be a space % between operators and gene names/IDs. +% originalGenes The original gene list from the model as reference % % OUTPUTS: % @@ -24,6 +25,11 @@ % +% handle input arguments +if nargin < 2 + originalGenes = []; +end + % check if the grRules use written or symbolic boolean operators if any(contains(grRules,{'&','|'})) % fix some potential missing spaces between parentheses and &/| @@ -50,10 +56,16 @@ nonEmpty = ~cellfun(@isempty,rxnGenes); genes = unique([rxnGenes{nonEmpty}]'); +if ~isempty(originalGenes) + if ~isequal(sort(originalGenes), sort(genes)) + error('The grRules and original gene list are inconsistent!'); + else + genes = originalGenes; + end +end + % construct new rxnGeneMat (if requested) if nargout > 1 rxnGeneCell = cellfun(@(rg) ismember(genes,rg),rxnGenes,'UniformOutput',false); rxnGeneMat = sparse(double(horzcat(rxnGeneCell{:})')); -end - - +end \ No newline at end of file diff --git a/doc/INIT/runINIT.html b/doc/INIT/runINIT.html index 63312a58..2b85ff7c 100644 --- a/doc/INIT/runINIT.html +++ b/doc/INIT/runINIT.html @@ -388,7 +388,7 @@