0001 function Weight4TransRxns(Idfier)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 Fileid = fopen('cpd2rxn.txt','r');
0017 cpd2rxn = textscan(Fileid,'%s %s');
0018 rxnData = strrep(cpd2rxn{2},'rn:','');
0019 cpds = strrep(cpd2rxn{1},'cpd:','');
0020 fclose(Fileid);
0021
0022 Fileid = fopen('cpd2weight.txt','r');
0023 cpd2weight = textscan(Fileid,'%s %f');
0024 cpd4weight = strrep(cpd2weight{1},'cpd:','');
0025 Weight = cpd2weight{2};
0026 fclose(Fileid);
0027 CurLen = 1; W4CurCpds = ({}); CanRxn = ({});
0028 Pth1 = which ('Bigg2Kegg.m');
0029 tind = find(Pth1=='\',1,'last');
0030 Pth = Pth1(1:tind-1);
0031
0032 if (Idfier == 2)
0033 fprintf('Generating W4TranRxns2.txt for rxn: ')
0034 Pth1 = [Pth,'\','W4TranRxns2.txt'];
0035 Fid = fopen(Pth1,'w');
0036 elseif (Idfier == 4)
0037 fprintf('Generating W4TranRxns4.txt for rxn: ')
0038 Pth1 = [Pth,'\','W4TranRxns4.txt'];
0039 Fid = fopen(Pth1,'w');
0040 elseif (Idfier == 6)
0041 fprintf('Generating W4TranRxns6.txt for rxn: ')
0042 Pth1 = [Pth,'\','W4TranRxns6.txt'];
0043 Fid = fopen(Pth1,'w');
0044 end
0045 for count = 1:numel(rxnData)
0046 if count>1
0047 for j=0:log10(count-1)
0048 fprintf('\b');
0049 end
0050 end
0051 fprintf('%d', count);
0052 TNum = sum(ismember(rxnData,rxnData{count}));
0053 if TNum == Idfier
0054 CurCpds = cpds(ismember(rxnData,rxnData{count}));
0055 W4CurCpdsT = Weight(ismember(cpd4weight,CurCpds));
0056 if numel(W4CurCpdsT) == Idfier && ~any(ismember(CanRxn,rxnData{count})) ...
0057 && (2.*numel(unique(W4CurCpdsT)) == Idfier)
0058 W4CurCpds{CurLen} = W4CurCpdsT;
0059 CanRxn{CurLen} = rxnData{count};
0060 CurLen = CurLen + 1;
0061 end
0062 end
0063 end
0064
0065 if (Idfier == 2)
0066 for ct = 1:numel(W4CurCpds)
0067 fprintf(Fid,'%s\t%f\t%f\n',CanRxn{ct},W4CurCpds{ct});
0068 end
0069 elseif (Idfier == 4)
0070 for ct = 1:numel(W4CurCpds)
0071 fprintf(Fid,'%s\t%f\t%f\t%f\t%f\n',CanRxn{ct},W4CurCpds{ct});
0072 end
0073 elseif (Idfier == 6)
0074 for ct = 1:numel(W4CurCpds)
0075 fprintf(Fid,'%s\t%f\t%f\t%f\t%f\t%f\t%f\n',CanRxn{ct},W4CurCpds{ct});
0076 end
0077 end
0078 fclose(Fid);