0001 function f = calculateFfactor(model, protData, enzymes, modelAdapter)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 if nargin < 4 || isempty(modelAdapter)
0021 modelAdapter = ModelAdapterManager.getDefault();
0022 if isempty(modelAdapter)
0023 error('Either send in a modelAdapter or set the default model adapter in the ModelAdapterManager.')
0024 end
0025 end
0026 params = modelAdapter.getParameters();
0027
0028 if nargin < 3 || isempty(enzymes)
0029 enzymes = model.ec.enzymes;
0030 end
0031
0032
0033 if nargin < 2 || isempty(protData)
0034 if exist(fullfile(params.path,'data','paxDB.tsv'),'file')
0035 protData = fullfile(params.path,'data','paxDB.tsv');
0036 else
0037 printOrange('WARNING: No proteomics data is provided or can be found. Default f value of 0.5 is returned.\n');
0038 f = 0.5;
0039 end
0040 end
0041
0042
0043 uniprotDB = loadDatabases('uniprot', modelAdapter);
0044 uniprotDB = uniprotDB.uniprot;
0045
0046 if ischar(protData) && endsWith(protData,'paxDB.tsv')
0047 fID = fopen(fullfile(protData),'r');
0048 fileContent = textscan(fID,'%s','delimiter','\n');
0049 headerLines = find(startsWith(fileContent{1},'#'),1,'last');
0050 fclose(fID);
0051
0052
0053 fID = fopen(fullfile(protData),'r');
0054 fileContent = textscan(fID,'%s %s %f','delimiter','\t','HeaderLines',headerLines);
0055 genes = fileContent{2};
0056
0057 genes = regexprep(genes,'^\d+\.','');
0058 level = fileContent{3};
0059 fclose(fID);
0060 [a,b] = ismember(genes,uniprotDB.genes);
0061 uniprot = uniprotDB.ID(b(a));
0062 level(~a) = [];
0063 clear protData
0064 protData.uniprotIDs = uniprot;
0065 protData.level = level;
0066
0067 [~,idx] = ismember(protData.uniprotIDs,uniprotDB.ID);
0068 protData.MW = uniprotDB.MW(idx);
0069 protData.abundances = protData.level .* protData.MW;
0070 end
0071
0072 avgAbundances = mean(protData.abundances,2);
0073 totalProt = sum(avgAbundances,'omitnan');
0074
0075
0076 enzymesInModel = ismember(protData.uniprotIDs,enzymes);
0077 totalEnz = sum(avgAbundances(enzymesInModel),'omitnan');
0078
0079 f = totalEnz/totalProt;
0080 end