0001 function compStruct=compareRxnsGenesMetsComps(models,printResults)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 if nargin<2
0029 printResults=true;
0030 end
0031
0032 if numel(models)<=1
0033 EM='Cannot compare only one model. Use printModelStats if you want a summary of a model';
0034 dispEM(EM);
0035 end
0036
0037 compStruct.modelIDs={};
0038 for i=1:numel(models)
0039 compStruct.modelIDs=[compStruct.modelIDs;models{i}.id];
0040 models{i}.equ=constructEquations(models{i},models{i}.rxns,true,true,true);
0041 models{i}.uEqu=constructEquations(models{i},models{i}.rxns,false,true,true);
0042 end
0043
0044 field='rxns';
0045 compStruct.rxns.comparison=getToCheck(models,field);
0046 compStruct.rxns.nElements=checkStuff(getElements(models,field),compStruct.rxns.comparison);
0047 if printResults==true
0048 fprintf('*** Comparison of reaction IDs:\n');
0049 printList(models,compStruct.rxns.comparison,compStruct.rxns.nElements);
0050 fprintf('\n\n');
0051 end
0052
0053 field='mets';
0054 compStruct.mets.comparison=getToCheck(models,field);
0055 compStruct.mets.nElements=checkStuff(getElements(models,field),compStruct.mets.comparison);
0056 if printResults==true
0057 fprintf('*** Comparison of metabolite IDs:\n');
0058 printList(models,compStruct.mets.comparison,compStruct.mets.nElements);
0059 fprintf('\n\n');
0060 end
0061
0062 field='genes';
0063 compStruct.genes.comparison=getToCheck(models,field);
0064 compStruct.genes.nElements=checkStuff(getElements(models,field),compStruct.genes.comparison);
0065 if printResults==true
0066 fprintf('*** Comparison of gene IDs:\n');
0067 printList(models,compStruct.genes.comparison,compStruct.genes.nElements);
0068 fprintf('\n\n');
0069 end
0070
0071 field='eccodes';
0072 compStruct.eccodes.comparison=getToCheck(models,field);
0073 compStruct.eccodes.nElements=checkStuff(getElements(models,field),compStruct.eccodes.comparison);
0074 if printResults==true
0075 fprintf('*** Comparison of ec-numbers:\n');
0076 printList(models,compStruct.eccodes.comparison,compStruct.eccodes.nElements);
0077 fprintf('\n\n');
0078 end
0079
0080 field='metNames';
0081 compStruct.metNames.comparison=getToCheck(models,field);
0082 compStruct.metNames.nElements=checkStuff(getElements(models,field),compStruct.metNames.comparison);
0083 if printResults==true
0084 fprintf('*** Comparison of metabolite names:\n');
0085 printList(models,compStruct.metNames.comparison,compStruct.metNames.nElements);
0086 fprintf('\n\n');
0087 end
0088
0089 field='equ';
0090 compStruct.equ.comparison=getToCheck(models,field);
0091 compStruct.equ.nElements=checkStuff(getElements(models,field),compStruct.equ.comparison);
0092 if printResults==true
0093 fprintf('*** Comparison of equations with compartment:\n');
0094 printList(models,compStruct.equ.comparison,compStruct.equ.nElements);
0095 fprintf('\n\n');
0096 end
0097
0098 field='uEqu';
0099 compStruct.uEqu.comparison=getToCheck(models,field);
0100 compStruct.uEqu.nElements=checkStuff(getElements(models,field),compStruct.uEqu.comparison);
0101 if printResults==true
0102 fprintf('*** Comparison of equations without compartment:\n');
0103 printList(models,compStruct.uEqu.comparison,compStruct.uEqu.nElements);
0104 fprintf('\n\n');
0105 end
0106 end
0107
0108 function A=getElements(models,field)
0109 A={};
0110 for i=1:numel(models)
0111 if isfield(models{i},field)
0112 A=[A;{models{i}.(field)}];
0113 end
0114 end
0115 end
0116
0117 function toCheck=getToCheck(models,field)
0118
0119
0120 toCheckA=[];
0121 I=find(cellfun(@checkField,models));
0122 nI=numel(I);
0123 for i=nI:-1:1
0124 combs=combnk(1:nI,i);
0125 toAdd=false(size(combs,1),nI);
0126 for j=1:size(combs,1)
0127 toAdd(j,combs(j,:))=true;
0128 end
0129 toCheckA=[toCheckA;toAdd];
0130 end
0131
0132
0133 toCheck=false(size(toCheckA,1),numel(models));
0134 toCheck(:,I)=toCheckA;
0135
0136
0137 function I=checkField(A)
0138 I=isfield(A,field);
0139 end
0140 end
0141
0142 function printList(models,toCheck,nElements)
0143
0144 firstLen=[];
0145 for i=1:size(toCheck,1)
0146 label=[];
0147 I=find(toCheck(i,:));
0148 for j=1:numel(I)
0149 label=[label models{I(j)}.id '/'];
0150 end
0151 if i==1
0152 firstLen=numel(label);
0153 end
0154 nSpaces=firstLen-numel(label);
0155 fprintf([label(1:end-1) ' ' repmat(sprintf(' '),1,nSpaces) num2str(nElements(i)) '\n']);
0156 end
0157 end
0158
0159 function nElements=checkStuff(A,toCheck)
0160
0161
0162
0163 nElements=zeros(size(toCheck,1),1);
0164 alreadyChecked=[];
0165 for i=1:size(toCheck,1)
0166 I=find(toCheck(i,:));
0167 inCommon=setdiff(A{I(1)},alreadyChecked);
0168 for j=2:numel(I)
0169 inCommon=intersect(inCommon,A{I(j)});
0170 end
0171 alreadyChecked=union(alreadyChecked,inCommon);
0172 nElements(i)=numel(inCommon);
0173 end
0174 end