0001 function exportToTabDelimited(model,path,sortIds)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 if nargin<2
0022 path='./';
0023 end
0024 if nargin<3
0025 sortIds=false;
0026 end
0027 if sortIds==true
0028 model=sortIdentifiers(model);
0029 end
0030
0031
0032 if ~isfolder(path)
0033 mkdir(path);
0034 end
0035
0036
0037 if isfile(fullfile(path,'excelRxns.txt'))
0038 delete(fullfile(path,'excelRxns.txt'));
0039 end
0040 if isfile(fullfile(path,'excelMets.txt'))
0041 delete(fullfile(path,'excelMets.txt'));
0042 end
0043 if isfile(fullfile(path,'excelGenes.txt'))
0044 delete(fullfile(path,'excelGenes.txt'));
0045 end
0046 if isfile(fullfile(path,'excelModel.txt'))
0047 delete(fullfile(path,'excelModel.txt'));
0048 end
0049 if isfile(fullfile(path,'excelComps.txt'))
0050 delete(fullfile(path,'excelComps.txt'));
0051 end
0052
0053
0054 model.equations=constructEquations(model,model.rxns,true);
0055
0056
0057 rxnFile=fopen(fullfile(path,'excelRxns.txt'),'wt');
0058
0059
0060 fprintf(rxnFile,'#\tID\tNAME\tEQUATION\tEC-NUMBER\tGENE ASSOCIATION\tLOWER BOUND\tUPPER BOUND\tOBJECTIVE\tCOMPARTMENT\tMIRIAM\tSUBSYSTEM\tREPLACEMENT ID\tNOTE\tREFERENCE\tCONFIDENCE SCORE\n');
0061
0062
0063 for i=1:numel(model.rxns)
0064 fprintf(rxnFile,['\t' model.rxns{i} '\t' model.rxnNames{i} '\t' model.equations{i} '\t']);
0065
0066 if isfield(model,'eccodes')
0067 fprintf(rxnFile,[model.eccodes{i} '\t']);
0068 else
0069 fprintf(rxnFile,'\t');
0070 end
0071
0072 if isfield(model,'grRules')
0073 fprintf(rxnFile,[model.grRules{i} '\t']);
0074 else
0075 fprintf(rxnFile,'\t');
0076 end
0077
0078
0079 fprintf(rxnFile,[num2str(model.lb(i)) '\t' num2str(model.ub(i)) '\t']);
0080
0081 if model.c(i)~=0
0082 fprintf(rxnFile,[num2str(model.c(i)) '\t' ]);
0083 else
0084 fprintf(rxnFile,'\t');
0085 end
0086
0087 if isfield(model,'rxnComps')
0088 fprintf(rxnFile,[model.comps{model.rxnComps(i)} '\t']);
0089 else
0090 fprintf(rxnFile,'\t');
0091 end
0092
0093 if isfield(model,'rxnMiriams')
0094 if ~isempty(model.rxnMiriams{i})
0095 toPrint=[];
0096 for j=1:numel(model.rxnMiriams{i}.name)
0097 toPrint=[toPrint strtrim(model.rxnMiriams{i}.name{j}) '/' strtrim(model.rxnMiriams{i}.value{j}) ';'];
0098 end
0099 fprintf(rxnFile,[toPrint(1:end-1) '\t']);
0100 else
0101 fprintf(rxnFile,'\t');
0102 end
0103 else
0104 fprintf(rxnFile,'\t');
0105 end
0106
0107 if isfield(model,'subSystems')
0108 if ~isempty(model.subSystems{i})
0109 fprintf(rxnFile,[strjoin(model.subSystems{i,1},';') '\t']);
0110 else
0111 fprintf(rxnFile,'\t');
0112 end
0113 end
0114
0115
0116 fprintf(rxnFile,'\t');
0117
0118 if isfield(model,'rxnNotes')
0119 fprintf(rxnFile,[model.rxnNotes{i} '\t']);
0120 else
0121 fprintf(rxnFile,'\t');
0122 end
0123
0124 if isfield(model,'rxnReferences')
0125 fprintf(rxnFile,[model.rxnReferences{i} '\t']);
0126 else
0127 fprintf(rxnFile,'\t');
0128 end
0129
0130 if isfield(model,'rxnConfidenceScores')
0131 fprintf(rxnFile,[num2str(model.rxnConfidenceScores(i)) '\t' ]);
0132 else
0133 fprintf(rxnFile,'\t');
0134 end
0135
0136 fprintf(rxnFile,'\n');
0137 end
0138
0139 fclose(rxnFile);
0140
0141
0142 metFile=fopen(fullfile(path,'excelMets.txt'),'wt');
0143
0144
0145 fprintf(metFile,'#\tID\tNAME\tUNCONSTRAINED\tMIRIAM\tCOMPOSITION\tInChI\tCOMPARTMENT\tREPLACEMENT ID\tMETS FIELD\tCHARGE\n');
0146
0147
0148 for i=1:numel(model.mets)
0149 fprintf(metFile,['\t' model.metNames{i} '[' model.comps{model.metComps(i)} ']\t' model.metNames{i} '\t']);
0150
0151 if isfield(model,'unconstrained')
0152 if model.unconstrained(i)~=0
0153 fprintf(metFile,'TRUE\t');
0154 else
0155 fprintf(metFile,'\t');
0156 end
0157 else
0158 fprintf(metFile,'\t');
0159 end
0160
0161 if isfield(model,'metMiriams')
0162 if ~isempty(model.metMiriams{i})
0163 toPrint=[];
0164 for j=1:numel(model.metMiriams{i}.name)
0165 toPrint=[toPrint strtrim(model.metMiriams{i}.name{j}) '/' strtrim(model.metMiriams{i}.value{j}) ';'];
0166 end
0167 fprintf(rxnFile,[toPrint(1:end-1) '\t']);
0168 else
0169 fprintf(metFile,'\t');
0170 end
0171 else
0172 fprintf(metFile,'\t');
0173 end
0174
0175 if isfield(model,'metFormulas')
0176 fprintf(metFile,[model.metFormulas{i} '\t']);
0177 else
0178 fprintf(metFile,'\t');
0179 end
0180
0181 if isfield(model,'inchis')
0182 fprintf(metFile,[model.inchis{i} '\t']);
0183 else
0184 fprintf(metFile,'\t');
0185 end
0186
0187 fprintf(metFile,[model.comps{model.metComps(i)} '\t']);
0188
0189
0190
0191 fprintf(metFile,['m' int2str(i) '\t']);
0192
0193
0194
0195 fprintf(metFile,[model.mets{i} '\t']);
0196
0197 if isfield(model,'metCharges')
0198 fprintf(metFile,[num2str(model.metCharges(i)) '\t']);
0199 else
0200 fprintf(metFile,'\t');
0201 end
0202
0203 fprintf(metFile,'\n');
0204 end
0205
0206 fclose(metFile);
0207
0208 if isfield(model,'genes')
0209
0210 geneFile=fopen(fullfile(path,'excelGenes.txt'),'wt');
0211
0212
0213 fprintf(geneFile,'#\tNAME\tMIRIAM\tSHORT NAME\tCOMPARTMENT\n');
0214
0215
0216 for i=1:numel(model.genes)
0217 fprintf(geneFile,['\t' model.genes{i} '\t']);
0218
0219 if isfield(model,'geneMiriams')
0220 if ~isempty(model.geneMiriams{i})
0221 toPrint=[];
0222 for j=1:numel(model.geneMiriams{i}.name)
0223 toPrint=[toPrint strtrim(model.geneMiriams{i}.name{j}) '/' strtrim(model.geneMiriams{i}.value{j}) ';'];
0224 end
0225 fprintf(geneFile,[toPrint(1:end-1) '\t']);
0226 else
0227 fprintf(geneFile,'\t');
0228 end
0229 else
0230 fprintf(geneFile,'\t');
0231 end
0232
0233 if isfield(model,'geneShortNames')
0234 fprintf(geneFile,[model.geneShortNames{i} '\t']);
0235 else
0236 fprintf(geneFile,'\t');
0237 end
0238
0239 if isfield(model,'geneComps')
0240 fprintf(geneFile,[model.comps{model.geneComps(i)} '\t']);
0241 else
0242 fprintf(geneFile,'\t');
0243 end
0244
0245 fprintf(geneFile,'\n');
0246 end
0247 fclose(geneFile);
0248 end
0249
0250 if isfield(model,'id')
0251
0252 modelFile=fopen(fullfile(path,'excelModel.txt'),'wt');
0253
0254
0255 fprintf(geneFile,'#\tID\tNAME\tDEFAULT LOWER\tDEFAULT UPPER\tCONTACT GIVEN NAME\tCONTACT FAMILY NAME\tCONTACT EMAIL\tORGANIZATION\tTAXONOMY\tNOTES\n');
0256
0257
0258
0259 toPrint=['\t' model.id '\t' model.name '\t'];
0260 if isfield(model,'annotation')
0261 if isfield(model.annotation,'defaultLB')
0262 toPrint=[toPrint num2str(model.annotation.defaultLB) '\t'];
0263 else
0264 toPrint=[toPrint num2str(min(model.lb)) '\t'];
0265 end
0266 if isfield(model.annotation,'defaultUB')
0267 toPrint=[toPrint num2str(model.annotation.defaultUB) '\t'];
0268 else
0269 toPrint=[toPrint num2str(max(model.ub)) '\t'];
0270 end
0271 if isfield(model.annotation,'givenName')
0272 toPrint=[toPrint model.annotation.givenName '\t'];
0273 else
0274 toPrint=[toPrint '\t'];
0275 end
0276 if isfield(model.annotation,'familyName')
0277 toPrint=[toPrint model.annotation.familyName '\t'];
0278 else
0279 toPrint=[toPrint '\t'];
0280 end
0281 if isfield(model.annotation,'email')
0282 toPrint=[toPrint model.annotation.email '\t'];
0283 else
0284 toPrint=[toPrint '\t'];
0285 end
0286 if isfield(model.annotation,'organization')
0287 toPrint=[toPrint model.annotation.organization '\t'];
0288 else
0289 toPrint=[toPrint '\t'];
0290 end
0291 if isfield(model.annotation,'taxonomy')
0292 toPrint=[toPrint model.annotation.taxonomy '\t'];
0293 else
0294 toPrint=[toPrint '\t'];
0295 end
0296 if isfield(model.annotation,'note')
0297 toPrint=[toPrint model.annotation.note '\t'];
0298 else
0299 toPrint=[toPrint '\t'];
0300 end
0301 else
0302 toPrint=[toPrint num2str(min(model.lb)) '\t' num2str(max(model.ub)) '\t\t\t\t\t\t\n'];
0303 end
0304 fprintf(modelFile,toPrint);
0305 fclose(modelFile);
0306 end
0307
0308 if isfield(model,'comps')
0309
0310 compsFile=fopen(fullfile(path,'excelComps.txt'),'wt');
0311
0312
0313 fprintf(compsFile,'#\tABBREVIATION\tNAME\tINSIDE\tMIRIAM\n');
0314
0315 for i=1:numel(model.comps)
0316 toPrint=['\t' model.comps{i} '\t' model.compNames{i} '\t'];
0317 if isfield(model,'compOutside')
0318 toPrint=[toPrint model.compOutside{i} '\t'];
0319 else
0320 toPrint=[toPrint '\t'];
0321 end
0322 if isfield(model,'compMiriams')
0323 if ~isempty(model.compMiriams{i})
0324 for j=1:numel(model.compMiriams{i}.name)
0325 toPrint=[toPrint strtrim(model.compMiriams{i}.name{j}) '/' strtrim(model.compMiriams{i}.value{j}) ';'];
0326 end
0327 toPrint(end)=[];
0328 toPrint=[toPrint '\t'];
0329 else
0330 toPrint=[toPrint '\t'];
0331 end
0332 else
0333 toPrint=[toPrint '\t'];
0334 end
0335 toPrint=[toPrint '\n'];
0336 fprintf(compsFile,toPrint);
0337 end
0338 fclose(compsFile);
0339 end
0340 end