Home > BiKEGG > MapAdjuster.m

MapAdjuster

PURPOSE ^

MapAdjuster(GUI)

SYNOPSIS ^

function varargout = MapAdjuster(varargin)

DESCRIPTION ^

 MapAdjuster(GUI)
 Post-processing the created customized metabolic maps by NetDraw

 O. Jamialahmadi
 TMU, Chem. Eng. Dept., Biotech. Group 
 June 2016

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = MapAdjuster(varargin)
0002 % MapAdjuster(GUI)
0003 % Post-processing the created customized metabolic maps by NetDraw
0004 %
0005 % O. Jamialahmadi
0006 % TMU, Chem. Eng. Dept., Biotech. Group
0007 % June 2016
0008 
0009 % Begin initialization code - DO NOT EDIT
0010 gui_Singleton = 1;
0011 gui_State = struct('gui_Name',       mfilename, ...
0012                    'gui_Singleton',  gui_Singleton, ...
0013                    'gui_OpeningFcn', @MapAdjuster_OpeningFcn, ...
0014                    'gui_OutputFcn',  @MapAdjuster_OutputFcn, ...
0015                    'gui_LayoutFcn',  [] , ...
0016                    'gui_Callback',   []);
0017 if nargin && ischar(varargin{1})
0018     gui_State.gui_Callback = str2func(varargin{1});
0019 end
0020 
0021 if nargout
0022     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0023 else
0024     gui_mainfcn(gui_State, varargin{:});
0025 end
0026 % End initialization code - DO NOT EDIT
0027 
0028 
0029 % --- Executes just before MapAdjuster is made visible.
0030 function MapAdjuster_OpeningFcn(hObject, eventdata, handles, varargin)
0031 % This function has no output args, see OutputFcn.
0032 % hObject    handle to figure
0033 % eventdata  reserved - to be defined in a future version of MATLAB
0034 % handles    structure with handles and user data (see GUIDATA)
0035 % varargin   command line arguments to MapAdjuster (see VARARGIN)
0036 
0037 % Choose default command line output for MapAdjuster
0038 handles.output = hObject;
0039 
0040 % Update handles structure
0041 guidata(hObject, handles);
0042 
0043 % UIWAIT makes MapAdjuster wait for user response (see UIRESUME)
0044 % uiwait(handles.figure1);
0045 
0046 
0047 % --- Outputs from this function are returned to the command line.
0048 function varargout = MapAdjuster_OutputFcn(hObject, eventdata, handles) 
0049 % varargout  cell array for returning output args (see VARARGOUT);
0050 % hObject    handle to figure
0051 % eventdata  reserved - to be defined in a future version of MATLAB
0052 % handles    structure with handles and user data (see GUIDATA)
0053 
0054 % Get default command line output from handles structure
0055 varargout{1} = handles.output;
0056 
0057 
0058 % --- Executes on button press in DonePush.
0059 function DonePush_Callback(hObject, eventdata, handles)
0060 PostData = getappdata(0,'PostData');
0061 % Title processing ////////////////////////////////////////////////////////
0062 Title = get(handles.TitleEdit,'String');
0063 FHndl = getappdata(0,'ParentFig');
0064 AxHndl = getappdata(0,'ParentAx');
0065 % TitleHndl = getappdata(hObject,'TitleHndl');
0066 % set(TitleHndl,'Visible','off');
0067 text('position',[50,50],'String',Title,'Unit','data','FontSize',22,...
0068     'Parent',AxHndl);
0069 % setappdata(hObject,'TitleHndl',TitleHndl);
0070 set(FHndl,'name',Title,'numbertitle','off')
0071 % Show Rates///////////////////////////////////////////////////////////////
0072 ShowRate = get(handles.ShowRatesCheck,'Value');
0073 if ShowRate
0074     FlxStrHndls = getappdata(hObject,'FlxStrHndls');
0075     set(FlxStrHndls,'Visible','off');
0076     AxHndl = getappdata(0,'ParentAx');
0077     flx = PostData.flx(:,PostData.k);
0078     ArX = PostData.ArX;
0079     ArY = PostData.ArY;
0080     for i1=1:numel(ArX)
0081         FlxStrHndls(i1) = text('position',[mean(ArX{i1}),mean(ArY{i1})],...
0082          'String',num2str(abs(flx(i1)),'%.2f'),'FontSize',7,'Parent',AxHndl);
0083     end
0084     setappdata(hObject,'FlxStrHndls',FlxStrHndls);
0085 else
0086     FlxStrHndls = getappdata(hObject,'FlxStrHndls');
0087     set(FlxStrHndls,'Visible','off');
0088 end
0089 % Show compounds //////////////////////////////////////////////////////////
0090 CpdPanelTags = {'KeggCpdIdRadio','KeggCpdNRadio','BiGGCpdRadio','RmvCpdRadio'};
0091 hCpdpanel = get(handles.CpdPanel,'SelectedObject');
0092 Cpdpanel = find(strcmp(CpdPanelTags,get(hCpdpanel,'Tag')));
0093 AxHndl = getappdata(0,'ParentAx');
0094 KEGGCpdH = getappdata(hObject,'KEGGCpdH');
0095 KEGGCpdNH = getappdata(hObject,'KEGGCpdNH');
0096 BiGGCpdH = getappdata(hObject,'BiGGCpdH');
0097 if any(ishandle(KEGGCpdH))
0098     set(KEGGCpdH,'Visible','off');
0099 end
0100 if any(ishandle(KEGGCpdNH))
0101     set(KEGGCpdNH,'Visible','off');
0102 end
0103 if any(ishandle(BiGGCpdH))
0104     set(BiGGCpdH,'Visible','off');
0105 end
0106 switch Cpdpanel
0107     case 1
0108         cpdnames = PostData.cpdnames;
0109         x_cpd = PostData.x_cpd;
0110         y_cpd = PostData.y_cpd;
0111         cpdxy = PostData.cpdxy;
0112         for i1=1:numel(cpdnames)
0113              KEGGCpdH(i1) = text('position',[x_cpd(i1)+cpdxy(1,4)/2,y_cpd(i1)-cpdxy(1,4)/2],...
0114                  'String',cpdnames{i1},'FontSize',7,'Parent',AxHndl);
0115         end
0116         setappdata(hObject,'KEGGCpdH',KEGGCpdH);
0117     case 2
0118         cpdnames = PostData.cpdnames;
0119         x_cpd = PostData.x_cpd;
0120         y_cpd = PostData.y_cpd;
0121         cpdxy = PostData.cpdxy;
0122         Fileid = fopen('KEGGcpd.txt','r');
0123         TempCpds = textscan(Fileid,'%s %s %[^\n]');
0124         fclose(Fileid);
0125         CpdIds = TempCpds{1}; CpdIds = strrep(CpdIds,'cpd:','');
0126         CpdNms = TempCpds{2}; CpdNms = strrep(CpdNms,';','');
0127         clear TempCpds
0128         [~,N1] = ismember(cpdnames,CpdIds);
0129          KEGGCpdNms = CpdNms(N1);
0130         for i1=1:numel(KEGGCpdNms)
0131              KEGGCpdNH(i1) = text('position',[x_cpd(i1)+cpdxy(1,4)/2,y_cpd(i1)-cpdxy(1,4)/2],...
0132                  'String',KEGGCpdNms{i1},'FontSize',5.5,'Parent',AxHndl);
0133         end
0134         setappdata(hObject,'KEGGCpdNH',KEGGCpdNH);
0135     case 3
0136         BiGGModel = getappdata(0,'BiGGModel');
0137         if isempty(BiGGModel)
0138             [pname,fname1]=uigetfile({'*.*'},'Select the model file (SBML)');
0139             Testname=pname(strfind(pname,'.')+1:end);
0140             if ~strcmp(Testname,'xml')
0141                 msgbox('Only xml file format!','Error','error');
0142                 return
0143             else
0144                 Idf = fopen([fname1,pname]);
0145                 D = textscan(Idf,'%s');
0146                 fclose(Idf);
0147                 CbModel = readCbModel([fname1,pname]);
0148                 [Metkegg,Metbigg] = KEGG2BiGGMets(D,CbModel);
0149                 BiGGModel.Metkegg = Metkegg;
0150                 BiGGModel.CbModel = CbModel;
0151                 BiGGModel.Metbigg = Metbigg;
0152                 setappdata(0,'BiGGModel',BiGGModel);
0153             end
0154         end
0155         Metbigg = BiGGModel.Metbigg;
0156         Metkegg = BiGGModel.Metkegg;
0157         cpdnames = PostData.cpdnames;
0158         x_cpd = PostData.x_cpd;
0159         y_cpd = PostData.y_cpd;
0160         cpdxy = PostData.cpdxy;
0161         for m1 = 1:numel(cpdnames)
0162             if any(ismember(cpdnames{m1},Metkegg))
0163                 whrc = find(ismember(Metkegg,cpdnames{m1}));
0164                 cpdnames(m1) = Metbigg(whrc(1));
0165             end
0166         end
0167         
0168         for i1=1:numel(cpdnames)
0169              BiGGCpdH(i1) = text('position',[x_cpd(i1)+cpdxy(1,4)/2,y_cpd(i1)-cpdxy(1,4)/2],...
0170                  'Interpreter','none','String',cpdnames{i1},'FontSize',5.5,'Parent',AxHndl);
0171         end
0172         setappdata(hObject,'BiGGCpdH',BiGGCpdH);
0173 end
0174 % Show rxns ///////////////////////////////////////////////////////////////
0175 RxnPanelTags = {'KeggRxnIdRadio','BiGGRxnRadio','RmvRxnRadio'};
0176 hrxnpanel = get(handles.RxnPanel,'SelectedObject');
0177 rxnpanel = find(strcmp(RxnPanelTags,get(hrxnpanel,'Tag')));
0178 AxHndl = getappdata(0,'ParentAx');
0179 KEGGRxnHndls = getappdata(hObject,'KEGGRxnHndls');
0180 BiGGRxnHndls = getappdata(hObject,'BiGGRxnHndls');
0181 if any(ishandle(KEGGRxnHndls))
0182     set(KEGGRxnHndls,'Visible','off');
0183 end
0184 if any(ishandle(BiGGRxnHndls))
0185     set(BiGGRxnHndls,'Visible','off');
0186 end
0187 
0188 switch rxnpanel % Show rxn IDs ////////////////////////////////////////////
0189     case 1 % KEGG ID ------------------------------------------------------
0190         [OverlayMe,Allx4Arrow,Ally4Arrow] = RxnAdjuster(PostData,[],'kegg');
0191         for i1=1:numel(Allx4Arrow)
0192             if std(Allx4Arrow{i1})<1e-1
0193                 KEGGRxnHndls(i1) = text('position',...
0194                     [mean(Allx4Arrow{i1})-10,mean(Ally4Arrow{i1})+15],...
0195                  'String',OverlayMe{i1},'FontSize',6.5,'rotation',90,'Parent',AxHndl);
0196             else
0197                 KEGGRxnHndls(i1) = text('position',...
0198                     [mean(Allx4Arrow{i1})-15,mean(Ally4Arrow{i1})-10],...
0199                  'String',OverlayMe{i1},'FontSize',6.5,'Parent',AxHndl);
0200             end
0201         end 
0202         setappdata(hObject,'KEGGRxnHndls',KEGGRxnHndls)
0203     case 2 % BiGG ID ------------------------------------------------------
0204         Mdl = getappdata(0,'Mdl');
0205         if isempty(Mdl)
0206             [pname,~]=uigetfile({'*.*'},'Select the model file (SBML)');
0207             Testname=pname(strfind(pname,'.')+1:end);
0208             if ~strcmp(Testname,'xml')
0209                 msgbox('Only xml file format!','Error','error');
0210                 return
0211             end
0212             Chk = which([pname(1:strfind(pname,'.')-1),'KEGG.mat']);
0213             if isempty(Chk)
0214                 msgbox({[pname(1:strfind(pname,'.')-1),'KEGG.mat',' cannot be found!'];...
0215                     'Make sure the file is present in BiGG2KEGG folder'},'Error','error');
0216                 return
0217             end
0218             Mdl = load(which([pname(1:strfind(pname,'.')-1),'KEGG.mat']));
0219             setappdata(0,'Mdl',Mdl);
0220         end
0221         [OverlayMe,Allx4Arrow,Ally4Arrow] = RxnAdjuster(PostData,Mdl,'bigg');
0222         % Rmv empty ones
0223         Chkempty = find(cellfun('isempty',regexp(OverlayMe,'\w','match')));
0224         OverlayMe(Chkempty) = {''};
0225         
0226         for i1=1:numel(Allx4Arrow)
0227             if std(Allx4Arrow{i1})<1e-1
0228                 BiGGRxnHndls(i1) = text('position',...
0229                     [mean(Allx4Arrow{i1})-10,mean(Ally4Arrow{i1})+15],...
0230                  'String',OverlayMe{i1},'FontSize',6,'rotation',90,...
0231                  'Interpreter','none','Parent',AxHndl);
0232             else
0233                 BiGGRxnHndls(i1) = text('position',...
0234                     [mean(Allx4Arrow{i1})-15,mean(Ally4Arrow{i1})-10],...
0235                  'String',OverlayMe{i1},'FontSize',6,'Parent',AxHndl,...
0236                  'Interpreter','none');
0237             end
0238         end 
0239         setappdata(hObject,'BiGGRxnHndls',BiGGRxnHndls)
0240 end
0241 
0242 function TitleEdit_Callback(hObject, eventdata, handles)
0243 
0244 
0245 
0246 % --- Executes during object creation, after setting all properties.
0247 function TitleEdit_CreateFcn(hObject, eventdata, handles)
0248 % hObject    handle to TitleEdit (see GCBO)
0249 % eventdata  reserved - to be defined in a future version of MATLAB
0250 % handles    empty - handles not created until after all CreateFcns called
0251 
0252 % Hint: edit controls usually have a white background on Windows.
0253 %       See ISPC and COMPUTER.
0254 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0255     set(hObject,'BackgroundColor','white');
0256 end
0257 
0258 
0259 % --- Executes on button press in TitlePush.
0260 function TitlePush_Callback(hObject, eventdata, handles)
0261 
0262 
0263 
0264 function LineWEdit_Callback(hObject, eventdata, handles)
0265 % hObject    handle to LineWEdit (see GCBO)
0266 % eventdata  reserved - to be defined in a future version of MATLAB
0267 % handles    structure with handles and user data (see GUIDATA)
0268 
0269 % Hints: get(hObject,'String') returns contents of LineWEdit as text
0270 %        str2double(get(hObject,'String')) returns contents of LineWEdit as a double
0271 
0272 
0273 % --- Executes during object creation, after setting all properties.
0274 function LineWEdit_CreateFcn(hObject, eventdata, handles)
0275 % hObject    handle to LineWEdit (see GCBO)
0276 % eventdata  reserved - to be defined in a future version of MATLAB
0277 % handles    empty - handles not created until after all CreateFcns called
0278 
0279 % Hint: edit controls usually have a white background on Windows.
0280 %       See ISPC and COMPUTER.
0281 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0282     set(hObject,'BackgroundColor','white');
0283 end
0284 
0285 
0286 % --- Executes on button press in ShowRatesCheck.
0287 function ShowRatesCheck_Callback(hObject, eventdata, handles)
0288 % hObject    handle to ShowRatesCheck (see GCBO)
0289 % eventdata  reserved - to be defined in a future version of MATLAB
0290 % handles    structure with handles and user data (see GUIDATA)
0291 
0292 % Hint: get(hObject,'Value') returns toggle state of ShowRatesCheck
0293 
0294 
0295 % --- Executes on button press in OverlapCheck.
0296 function OverlapCheck_Callback(hObject, eventdata, handles)
0297 % hObject    handle to OverlapCheck (see GCBO)
0298 % eventdata  reserved - to be defined in a future version of MATLAB
0299 % handles    structure with handles and user data (see GUIDATA)
0300 
0301 % Hint: get(hObject,'Value') returns toggle state of OverlapCheck
0302 
0303 
0304 % --- Executes on button press in ColormapCheck.
0305 function ColormapCheck_Callback(hObject, eventdata, handles)
0306 % hObject    handle to ColormapCheck (see GCBO)
0307 % eventdata  reserved - to be defined in a future version of MATLAB
0308 % handles    structure with handles and user data (see GUIDATA)
0309 
0310 % Hint: get(hObject,'Value') returns toggle state of ColormapCheck
0311 
0312 
0313 % --- Executes on button press in RedrawPush.
0314 function RedrawPush_Callback(hObject, eventdata, handles)
0315 OverlapC = get(handles.OverlapCheck,'Value');
0316 ColormapC = get(handles.ColormapCheck,'Value');
0317 LineStr = str2double(get(handles.LineWEdit,'String'));
0318 BackCol = getappdata(handles.Backgroundpush,'BackCol');
0319 CpdCol = getappdata(handles.Cpdpush,'CpdCol');
0320 inactiveCol = getappdata(handles.inactivespush,'inactiveCol');
0321 NetPoster(LineStr,OverlapC,ColormapC,BackCol,CpdCol,inactiveCol)
0322 
0323 
0324 % --- Executes on button press in Backgroundpush.
0325 function Backgroundpush_Callback(hObject, eventdata, handles)
0326 BackCol=uisetcolor;
0327 setappdata(hObject,'BackCol',BackCol);
0328 
0329 
0330 % --- Executes on button press in Cpdpush.
0331 function Cpdpush_Callback(hObject, eventdata, handles)
0332 CpdCol=uisetcolor;
0333 setappdata(hObject,'CpdCol',CpdCol);
0334 
0335 
0336 % --- Executes on button press in inactivespush.
0337 function inactivespush_Callback(hObject, eventdata, handles)
0338 inactiveCol=uisetcolor;
0339 setappdata(hObject,'inactiveCol',inactiveCol);
0340 
0341 
0342 % --- Executes on button press in ClosePush.
0343 function ClosePush_Callback(hObject, eventdata, handles)
0344 % hObject    handle to ClosePush (see GCBO)
0345 % eventdata  reserved - to be defined in a future version of MATLAB
0346 % handles    structure with handles and user data (see GUIDATA)
0347 close(gcf)

Generated on Sat 16-Jul-2016 20:21:30 by m2html © 2005