0001 function newModel=permuteModel(model, indexes, type)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 newModel=model;
0018 type=char(type);
0019
0020 switch type
0021 case 'rxns'
0022 if isfield(newModel,'rxns')
0023 newModel.rxns=newModel.rxns(indexes);
0024 end
0025 if isfield(newModel,'lb')
0026 newModel.lb=newModel.lb(indexes);
0027 end
0028 if isfield(newModel,'ub')
0029 newModel.ub=newModel.ub(indexes);
0030 end
0031 if isfield(newModel,'rev')
0032 newModel.rev=newModel.rev(indexes);
0033 end
0034 if isfield(newModel,'c')
0035 newModel.c=newModel.c(indexes);
0036 end
0037 if isfield(newModel,'S')
0038 newModel.S=newModel.S(:,indexes);
0039 end
0040 if isfield(newModel,'rxnNames')
0041 newModel.rxnNames=newModel.rxnNames(indexes);
0042 end
0043 if isfield(newModel,'rxnGeneMat')
0044 newModel.rxnGeneMat=newModel.rxnGeneMat(indexes,:);
0045 end
0046 if isfield(newModel,'grRules')
0047 newModel.grRules=newModel.grRules(indexes);
0048 end
0049 if isfield(newModel,'subSystems')
0050 newModel.subSystems=newModel.subSystems(indexes);
0051 end
0052 if isfield(newModel,'eccodes')
0053 newModel.eccodes=newModel.eccodes(indexes);
0054 end
0055 if isfield(newModel,'equations')
0056 newModel.equations=newModel.equations(indexes);
0057 end
0058 if isfield(newModel,'rxnMiriams')
0059 newModel.rxnMiriams=newModel.rxnMiriams(indexes);
0060 end
0061 if isfield(newModel,'rxnComps')
0062 newModel.rxnComps=newModel.rxnComps(indexes);
0063 end
0064 if isfield(newModel,'rxnFrom')
0065 newModel.rxnFrom=newModel.rxnFrom(indexes);
0066 end
0067 if isfield(newModel,'rxnScores')
0068 newModel.rxnScores=newModel.rxnScores(indexes);
0069 end
0070 if isfield(newModel,'rxnNotes')
0071 newModel.rxnNotes=newModel.rxnNotes(indexes);
0072 end
0073 if isfield(newModel,'rxnReferences')
0074 newModel.rxnReferences=newModel.rxnReferences(indexes);
0075 end
0076 if isfield(newModel,'rxnConfidenceScores')
0077 newModel.rxnConfidenceScores=newModel.rxnConfidenceScores(indexes);
0078 end
0079 if isfield(newModel,'rxnDeltaG')
0080 newModel.rxnDeltaG=newModel.rxnDeltaG(indexes);
0081 end
0082 case 'mets'
0083 if isfield(newModel,'mets')
0084 newModel.mets=newModel.mets(indexes);
0085 end
0086 if isfield(newModel,'metNames')
0087 newModel.metNames=newModel.metNames(indexes);
0088 end
0089 if isfield(newModel,'b')
0090 newModel.b=newModel.b(indexes,:);
0091 end
0092 if isfield(newModel,'metComps')
0093 newModel.metComps=newModel.metComps(indexes);
0094 end
0095 if isfield(newModel,'S')
0096 newModel.S=newModel.S(indexes,:);
0097 end
0098 if isfield(newModel,'unconstrained')
0099 newModel.unconstrained=newModel.unconstrained(indexes);
0100 end
0101 if isfield(newModel,'metMiriams')
0102 newModel.metMiriams=newModel.metMiriams(indexes,:);
0103 end
0104 if isfield(newModel,'inchis')
0105 newModel.inchis=newModel.inchis(indexes);
0106 end
0107 if isfield(newModel,'metSmiles')
0108 newModel.metSmiles=newModel.metSmiles(indexes);
0109 end
0110 if isfield(newModel,'metFormulas')
0111 newModel.metFormulas=newModel.metFormulas(indexes);
0112 end
0113 if isfield(newModel,'metFrom')
0114 newModel.metFrom=newModel.metFrom(indexes);
0115 end
0116 if isfield(newModel,'metCharges')
0117 newModel.metCharges=newModel.metCharges(indexes);
0118 end
0119 if isfield(newModel,'metDeltaG')
0120 newModel.metDeltaG=newModel.metDeltaG(indexes);
0121 end
0122 case 'genes'
0123 if isfield(newModel,'genes')
0124 newModel.genes=newModel.genes(indexes);
0125 end
0126 if isfield(newModel,'geneComps')
0127 newModel.geneComps=newModel.geneComps(indexes);
0128 end
0129 if isfield(newModel,'geneMiriams')
0130 newModel.geneMiriams=newModel.geneMiriams(indexes);
0131 end
0132 if isfield(newModel,'geneShortNames')
0133 newModel.geneShortNames=newModel.geneShortNames(indexes);
0134 end
0135 if isfield(newModel,'proteins')
0136 newModel.proteins=newModel.proteins(indexes);
0137 end
0138 if isfield(newModel,'rxnGeneMat')
0139 newModel.rxnGeneMat=newModel.rxnGeneMat(:,indexes);
0140 end
0141 case 'comps'
0142 if isfield(newModel,'comps')
0143 newModel.comps=newModel.comps(indexes);
0144 end
0145 if isfield(newModel,'compNames')
0146 newModel.compNames=newModel.compNames(indexes);
0147 end
0148 if isfield(newModel,'compOutside')
0149 newModel.compOutside=newModel.compOutside(indexes);
0150 end
0151 if isfield(newModel,'compMiriams')
0152 newModel.compMiriams=newModel.compMiriams(indexes);
0153 end
0154 [~,J]=sort(indexes);
0155 if isfield(newModel,'metComps')
0156 [toreplace, bywhat] = ismember(newModel.metComps,1:length(J));
0157 newModel.metComps(toreplace) = J(bywhat(toreplace));
0158 end
0159 if isfield(model,'rxnComps')
0160 [toreplace, bywhat] = ismember(model.rxnComps,1:length(J));
0161 model.rxnComps(toreplace) = J(bywhat(toreplace));
0162 end
0163 if isfield(model,'geneComps')
0164 [toreplace, bywhat] = ismember(model.geneComps,1:length(J));
0165 model.geneComps(toreplace) = J(bywhat(toreplace));
0166 end
0167 end
0168 end