0001 function reducedModel=removeMets(model,metsToRemove,isNames,removeUnusedRxns,removeUnusedGenes,removeUnusedComps)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 if ~islogical(metsToRemove) && ~isnumeric(metsToRemove)
0026 metsToRemove=convertCharArray(metsToRemove);
0027 end
0028
0029 if nargin<3
0030 isNames=false;
0031 end
0032
0033 if nargin<4
0034 removeUnusedRxns=false;
0035 end
0036
0037 if nargin<5
0038 removeUnusedGenes=false;
0039 end
0040
0041 if nargin<6
0042 removeUnusedComps=false;
0043 end
0044
0045
0046 if isNames==true && ~iscell(metsToRemove)
0047 error('Must supply a cell array of strings if isNames=true');
0048 end
0049
0050 reducedModel=model;
0051
0052 if isNames==false
0053 indexesToDelete=getIndexes(model,metsToRemove,'mets');
0054 else
0055 indexesToDelete=[];
0056 for i=1:numel(metsToRemove)
0057 indexesToDelete=[indexesToDelete;find(strcmp(metsToRemove(i),model.metNames))];
0058 end
0059 end
0060
0061
0062 if ~isempty(indexesToDelete)
0063 reducedModel.mets(indexesToDelete)=[];
0064 reducedModel.S(indexesToDelete,:)=[];
0065 if isfield(reducedModel,'b')
0066 reducedModel.b(indexesToDelete,:)=[];
0067 end
0068 if isfield(reducedModel,'metNames')
0069 reducedModel.metNames(indexesToDelete)=[];
0070 end
0071 if isfield(reducedModel,'metComps')
0072 reducedModel.metComps(indexesToDelete)=[];
0073 end
0074 if isfield(reducedModel,'inchis')
0075 reducedModel.inchis(indexesToDelete)=[];
0076 end
0077 if isfield(reducedModel,'metSmiles')
0078 reducedModel.metSmiles(indexesToDelete)=[];
0079 end
0080 if isfield(reducedModel,'metFormulas')
0081 reducedModel.metFormulas(indexesToDelete)=[];
0082 end
0083 if isfield(reducedModel,'metMiriams')
0084 reducedModel.metMiriams(indexesToDelete)=[];
0085 end
0086 if isfield(reducedModel,'unconstrained')
0087 reducedModel.unconstrained(indexesToDelete)=[];
0088 end
0089 if isfield(reducedModel,'metFrom')
0090 reducedModel.metFrom(indexesToDelete)=[];
0091 end
0092 if isfield(reducedModel,'metCharges')
0093 reducedModel.metCharges(indexesToDelete)=[];
0094 end
0095 if isfield(reducedModel,'metDeltaG')
0096 reducedModel.metDeltaG(indexesToDelete)=[];
0097 end
0098 if isfield(reducedModel,'metNotes')
0099 reducedModel.metNotes(indexesToDelete)=[];
0100 end
0101 end
0102
0103
0104 if removeUnusedRxns==true
0105
0106 [~, a]=find(reducedModel.S);
0107 rxnsToRemove=1:numel(reducedModel.rxns);
0108 rxnsToRemove(a)=[];
0109 reducedModel=removeReactions(reducedModel,rxnsToRemove,false,removeUnusedGenes);
0110 end
0111
0112
0113 if removeUnusedComps==true
0114 oldComps=reducedModel.comps;
0115 I=ismember(1:numel(oldComps),reducedModel.metComps);
0116 if ~all(I)
0117 reducedModel.comps(~I)=[];
0118 reducedModel.compNames(~I)=[];
0119 if isfield(reducedModel,'compOutside')
0120 reducedModel.compOutside(~I)=[];
0121 end
0122 if isfield(reducedModel,'compMiriams')
0123 reducedModel.compMiriams(~I)=[];
0124 end
0125 [~, J]=ismember(oldComps(reducedModel.metComps),reducedModel.comps);
0126 reducedModel.metComps=J;
0127 end
0128 end
0129 end