0001 function options = setMapOptions(options, map, varargin)
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
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 nNodes = size(map.molName,1);
0079 nEdges = size(map.connectionName,1);
0080
0081 if ~isstr(varargin{1}) && isstr(varargin{2})
0082 model = varargin{1};
0083 for i = 2:2:size(varargin,2)
0084 switch lower(varargin{i})
0085 case 'nodecolor'
0086 conc = cell2mat(varargin(i+1));
0087 if size(conc,1)==1
0088 conc = repmat(conc,nNodes,1);
0089 elseif all(size(conc) == [nNodes 3])
0090
0091 options.nodeColor = conc;
0092 continue;
0093 end
0094 if(size(conc,2)==1)
0095 color = getColorFromColorScale(conc);
0096 elseif(size(conc,2)== 3)
0097 color = conc;
0098 else
0099 warning('Invalid size for nodeColor entry');
0100 continue;
0101 end
0102
0103 if isfield(model,'metNames')
0104 mapMol = 'molName';
0105 modelMol = 'metNames';
0106 else
0107 mapMol = 'molAbbreviation';
0108 modelMol = 'mets';
0109 end
0110
0111 options.nodeColor = ones(nNodes,3)*191;
0112
0113 [known index] = ismember(map.(mapMol),model.(modelMol));
0114 index = index(index~=0);
0115 options.nodeColor(known,:) = color(index,:);
0116
0117 clear('conc','mapMol','modelMol','color','known','index');
0118 case 'edgecolor'
0119 flux = cell2mat(varargin(i+1));
0120 if size(flux,1)==1
0121 flux = repmat(flux,nEdges,1);
0122 elseif all(size(flux) == [nEdges 3])
0123
0124 options.edgeColor = flux;
0125 continue
0126 elseif size(flux) ~= length(model.rxns)
0127 warning('Invalid size for edgeColor entry');
0128 continue;
0129 end
0130
0131 if(size(flux,2)==1)
0132 color = getColorFromColorScale(flux);
0133 elseif(size(flux,2)== 3)
0134 color = flux;
0135 else
0136 warning('Invalid size for edgeColor entry');
0137 continue;
0138 end
0139
0140 options.edgeColor = ones(nEdges,3)*191;
0141
0142 [known index] = ismember(map.connectionAbb,model.rxns);
0143 index = index(index~=0);
0144 options.edgeColor(known,:) = color(index,:);
0145
0146 clear('flux','color','known','index');
0147 case 'edgearrowcolor'
0148 arrowColor = cell2mat(varargin(i+1));
0149 if size(arrowColor,1)==1
0150 arrowColor = repmat(arrowColor,nEdges,1);
0151 end
0152 if size(arrowColor,2)~=3
0153 warning('Invalid size for arrowColor entry');
0154 continue
0155 end
0156 options.edgeArrowColor = arrowColor;
0157
0158 clear('arrowColor');
0159 case 'nodeweight'
0160 nodeWeight = cell2mat(varargin(i+1));
0161 if size(nodeWeight,1)==1
0162 nodeWeight = repmat(nodeWeight,nNodes,1);
0163 options.nodeWeight = nodeWeight;
0164 elseif size(nodeWeight,1)==length(model.mets)
0165
0166 if isfield(model,'metNames')
0167 mapMol = 'molName';
0168 modelMol = 'metNames';
0169 else
0170 mapMol = 'molAbbreviation';
0171 modelMol = 'mets';
0172 end
0173
0174 if max(nodeWeight)~=0, nodeWeight = round(24*nodeWeight/max(nodeWeight))+1; end
0175
0176 options.nodeWeight = ones(nNodes,1)*25;
0177
0178 [known index] = ismember(map.(mapMol),model.(modelMol));
0179 index = index(index~=0);
0180 options.nodeWeight(known) = nodeWeight(index);
0181 elseif size(nodeWeight,1)==nNodes
0182
0183 options.nodeWeight=nodeWeight;
0184 else
0185 warning('Invalid size for nodeWeight entry');
0186 end
0187 if ~isfield(options,'nodeWeightSecondary')
0188 options.nodeWeightSecondary = options.nodeWeight*15/25;
0189 end
0190
0191 clear('nodeWeight','mapMol','modelMol','known','index');
0192 case 'nodeweightsecondary'
0193 nodeWeight = cell2mat(varargin(i+1));
0194 if size(nodeWeight,1)==1
0195 nodeWeight = repmat(nodeWeight,nNodes,1);
0196 options.nodeWeightSecondary = nodeWeight;
0197 elseif size(nodeWeight,1)==length(model.mets)
0198
0199 if isfield(model,'metNames')
0200 mapMol = 'molName';
0201 modelMol = 'metNames';
0202 else
0203 mapMol = 'molAbbreviation';
0204 modelMol = 'mets';
0205 end
0206
0207 if max(nodeWeight)~=0, nodeWeight = round(24*nodeWeight/max(nodeWeight))+1; end
0208
0209 options.nodeWeightSecondary = ones(nNodes,1)*25;
0210
0211 [known index] = ismember(map.(mapMol),model.(modelMol));
0212 index = index(index~=0);
0213 options.nodeWeightSecondary(known) = nodeWeight(index);
0214 elseif size(nodeWeight,1)==nNodes
0215
0216 options.nodeWeightSecondary=nodeWeight;
0217 else
0218 warning('Invalid size for nodeWeight entry');
0219 end
0220
0221 clear('nodeWeight','mapMol','modelMol','known','index');
0222 case 'edgeweight'
0223 edgeWeight = cell2mat(varargin(i+1));
0224 if size(edgeWeight,1) == 1
0225
0226 options.edgeWeight = repmat(edgeWeight,nEdges,1);
0227 elseif size(edgeWeight,1) == length(model.rxns)
0228
0229
0230 if max(edgeWeight)~=0, edgeWeight = round(4*edgeWeight/max(edgeWeight))+1; end
0231
0232 options.edgeWeight = ones(nEdges,1)*4;
0233
0234 [known index] = ismember(map.connectionAbb,model.rxns);
0235 index = index(index~=0);
0236 options.edgeWeight(known) = edgeWeight(index);
0237 elseif size(edgeWeight,1) == nEdges
0238
0239 options.edgeWeight = edgeWeight;
0240 else
0241 warning('invalid size for nodeWeight entry');
0242 end
0243
0244 clear('edgeWeight','known','index');
0245 case 'textsize'
0246 textSize = cell2mat(varargin(i+1));
0247 nNodes = size(map.molName,1);
0248 if length(textSize)==1
0249 textSize = ones(nNodes,1)*textSize;
0250 end
0251 for j = 1:nNodes
0252 str = map.molName(j);
0253 index = find(strcmp(model.metNames(:),str));
0254 if isempty(index)
0255 options.textSize(j,1) = 8;
0256 elseif length(index) == 1
0257 options.textSize(j,1) = textSize(index);
0258 else
0259 options.textSize(j,1) = textSize(index(1));
0260 end
0261 end
0262 case 'textcolor'
0263 tColor = cell2mat(varargin(i+1));
0264 nNodes = size(map.molName,1);
0265 if size(tColor,1)==1
0266 tColor = repmat(tColor,nNodes,1);
0267 end
0268 for j = 1:nNodes
0269 str = map.molName(j);
0270 index = find(strcmp(model.metNames(:),str));
0271 if isempty(index)
0272 options.textColor(j,:) = [0 0 0];
0273 elseif length(index) == 1
0274 options.textColor(j,:)= tColor(index,:);
0275 else
0276 options.textColor(j,:)= tColor(index(1),:);
0277 end
0278 end
0279 case 'othertextcolor'
0280 otColor = cell2mat(varargin(i+1));
0281 nNodes = size(map.molName,1);
0282 if size(ltColor,1)==1
0283 otColor = repmat(otColor,nNodes,1);
0284 end
0285 options.otherTextColor = otColor;
0286 case 'lb', options.lb = varargin{i+1};
0287 case 'ub', options.ub = varargin{i+1};
0288 case 'scaletype', options.scaleType = varargin{i+1};
0289 case 'colorscale', options.colorScale = varargin{i+1};
0290 case 'zerofluxwidth', options.zeroFluxWidth = varargin{i+1};
0291 case 'zerofluxcolor', options.zeroFluxColor = varargin{i+1};
0292 case 'zeroconccolor', options.zeroConcColor = varargin{i+1};
0293 case 'filename', options.fileName = varargin{i+1};
0294 case 'rxndirflag', options.rxnDir = varargin{i+1};
0295 case 'rxndirmultiplier', options.rxnDirMultiplier = varargin{i+1};
0296 case 'bidircolor', options.fluxVarColor.biDirColor = varargin{i+1};
0297 case 'unidirirrcolor', options.fluxVarColor.uniDirIrrColor = varargin{i+1};
0298 case 'unidirfwdcolor', options.fluxVarColor.uniDirFwdColor = varargin{i+1};
0299 case 'unidirrevcolor', options.fluxVarColor.uniDirRevColor = varargin{i+1};
0300 otherwise
0301 if isstr(varargin{i})
0302 warning('Unknown Property: "%s"',varargin{i});
0303 end
0304 end
0305 end
0306
0307
0308 else
0309 for i = 1:2:size(varargin,2)
0310 switch lower(varargin{i})
0311 case 'nodeweight', options.nodeWeight = cell2mat(varargin(i+1));
0312 case 'nodecolor', options.nodeColor = cell2mat(varargin(i+1));
0313 case 'edgeweight', options.edgeWeight = cell2mat(varargin(i+1));
0314 case 'edgecolor', options.edgeColor = cell2mat(varargin(i+1));
0315 case 'edgearrowcolor', options.edgeArrowColor = cell2mat(varargin(i+1));
0316 case 'textsize', options.textSize = cell2mat(varargin(i+1));
0317 case 'textcolor', options.textColor = cell2mat(varargin(i+1));
0318 case 'othertextsize', options.otherTextSize = cell2mat(varargin(i+1));
0319 case 'othertextcolor', options.otherTextColor = cell2mat(varargin(i+1));
0320 case 'lb', options.lb = varargin{i+1};
0321 case 'ub', options.ub = varargin{i+1};
0322 case 'scaletype', options.scaleType = varargin{i+1};
0323 case 'colorscale', options.colorScale = varargin{i+1};
0324 case 'zerofluxwidth', options.zeroFluxWidth = varargin{i+1};
0325 case 'zerofluxcolor', options.zeroFluxColor = varargin{i+1};
0326 case 'zeroconccolor', options.zeroConcColor = varargin{i+1};
0327 case 'filename', options.fileName = varargin{i+1};
0328 case 'rxndirflag', options.rxnDirFlag = varargin{i+1};
0329 case 'rxndirmultiplier', options.rxnDirMultipler = varargin{i+1};
0330 case 'bidircolor', options.fluxVarColor.biDirColor = varargin{i+1};
0331 case 'unidirirrcolor', options.fluxVarColor.uniDirIrrColor = varargin{i+1};
0332 case 'unidirfwdcolor', options.fluxVarColor.uniDirFwdColor = varargin{i+1};
0333 case 'unidirrevcolor', options.fluxVarColor.uniDirRevColor = varargin{i+1};
0334 otherwise
0335 if isstr(varargin{i})
0336 warning('Unknown Property: "%s"',varargin{i});
0337 end
0338 end
0339 end
0340 end