Home > BiKEGG > Precons.m

Precons

PURPOSE ^

Precons(GUI)

SYNOPSIS ^

function varargout = Precons(varargin)

DESCRIPTION ^

 Precons(GUI)
 A GUI for PreconsMethod

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = Precons(varargin)
0002 % Precons(GUI)
0003 % A GUI for PreconsMethod
0004 %
0005 % O. Jamialahmadi
0006 % TMU, Chem. Eng. Dept., Biotech. Group
0007 % Match 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', @Precons_OpeningFcn, ...
0014                    'gui_OutputFcn',  @Precons_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 Precons is made visible.
0030 function Precons_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 Precons (see VARARGIN)
0036 Fileid = fopen('orgs.txt','r');
0037 orgcell = textscan(Fileid,'%s %s %[^\n]');
0038 fclose(Fileid);
0039 Tcode = orgcell{1}; Scode = orgcell{2};
0040 for ct = 1:numel(Tcode)
0041     tscode{ct} = [Scode{ct},'  ',Tcode{ct}];
0042 end
0043 set(handles.OrganPopup,'String',tscode)
0044 
0045 % Choose default command line output for Precons
0046 handles.output = hObject;
0047 
0048 % Update handles structure
0049 guidata(hObject, handles);
0050 
0051 % UIWAIT makes Precons wait for user response (see UIRESUME)
0052 % uiwait(handles.figure1);
0053 
0054 
0055 % --- Outputs from this function are returned to the command line.
0056 function varargout = Precons_OutputFcn(hObject, eventdata, handles) 
0057 % varargout  cell array for returning output args (see VARARGOUT);
0058 % hObject    handle to figure
0059 % eventdata  reserved - to be defined in a future version of MATLAB
0060 % handles    structure with handles and user data (see GUIDATA)
0061 
0062 % Get default command line output from handles structure
0063 varargout{1} = handles.output;
0064 
0065 
0066 % --- Executes on selection change in OrganPopup.
0067 function OrganPopup_Callback(hObject, eventdata, handles)
0068 % hObject    handle to OrganPopup (see GCBO)
0069 % eventdata  reserved - to be defined in a future version of MATLAB
0070 % handles    structure with handles and user data (see GUIDATA)
0071 Fileid = fopen('orgs.txt','r');
0072 orgcell = textscan(Fileid,'%s %s %[^\n]');
0073 fclose(Fileid);
0074 Ncode = orgcell{3}; Scode = orgcell{2};
0075 Cursel = get(hObject,'Value');
0076 if ~isempty(Cursel)
0077     set(handles.Orgtext,'String',Ncode{Cursel})
0078     set(handles.OrganEdit,'String',Scode{Cursel})
0079 end
0080 
0081 stat = get(handles.Biographcheck,'Value');
0082 if stat
0083     Org = get(handles.OrganEdit,'String');
0084     if ~strcmp(Org,'Organism code')
0085         Txt1 = 'Downloding pathway data...';
0086         fprintf(Txt1)
0087         [getpathways,stat] = urlread(['http://rest.kegg.jp/list/pathway/',Org]);
0088         if ~stat
0089             msgbox('There is a problem with the internet connection!');
0090             for i =1:numel(Txt1)
0091                 fprintf('\b')
0092             end
0093             return
0094         end
0095         for i =1:numel(Txt1)
0096             fprintf('\b')
0097         end
0098         pths = textscan(getpathways,'%s %[^\n]');
0099         pathnames = pths{1}; pathnames = strrep(pathnames,'path:','');
0100         pathdescription = pths{2};
0101         set(handles.Pathwaylistbox,'String',strcat(pathnames,'_',pathdescription))
0102     end
0103 end
0104 
0105 % --- Executes during object creation, after setting all properties.
0106 function OrganPopup_CreateFcn(hObject, eventdata, handles)
0107 % hObject    handle to OrganPopup (see GCBO)
0108 % eventdata  reserved - to be defined in a future version of MATLAB
0109 % handles    empty - handles not created until after all CreateFcns called
0110 
0111 % Hint: popupmenu controls usually have a white background on Windows.
0112 %       See ISPC and COMPUTER.
0113 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0114     set(hObject,'BackgroundColor','white');
0115 end
0116 
0117 
0118 
0119 function OrganEdit_Callback(hObject, eventdata, handles)
0120 % hObject    handle to OrganEdit (see GCBO)
0121 % eventdata  reserved - to be defined in a future version of MATLAB
0122 % handles    structure with handles and user data (see GUIDATA)
0123 Fileid = fopen('orgs.txt','r');
0124 orgcell = textscan(Fileid,'%s %s %[^\n]');
0125 fclose(Fileid);
0126 Tcode = orgcell{1}; Scode = orgcell{2}; Ncode = orgcell{3};
0127 OrgEditSelect = get(hObject,'String');
0128 WhereOrgPop1 = find(ismember(Tcode,OrgEditSelect));
0129 WhereOrgPop2 = find(ismember(Scode,OrgEditSelect));
0130 if ~isempty(WhereOrgPop1)
0131     set(handles.OrganPopup,'Value',WhereOrgPop1)
0132     set(handles.Orgtext,'String',Ncode{WhereOrgPop1})
0133 elseif ~isempty(WhereOrgPop2)
0134     set(handles.OrganPopup,'Value',WhereOrgPop2)
0135     set(handles.Orgtext,'String',Ncode{WhereOrgPop2})
0136 else
0137     set(handles.Orgtext,'String','Wrong organism code')
0138 end
0139 stat = get(handles.Biographcheck,'Value');
0140 if stat
0141     Org = get(handles.OrganEdit,'String');
0142     if ~strcmp(Org,'Organism code')
0143         Txt1 = 'Downloding pathway data...';
0144         fprintf(Txt1)
0145         [getpathways,stat] = urlread(['http://rest.kegg.jp/list/pathway/',Org]);
0146         if ~stat
0147             msgbox('There is a problem with the internet connection!');
0148             for i =1:numel(Txt1)
0149                 fprintf('\b')
0150             end
0151             return
0152         end
0153         for i =1:numel(Txt1)
0154             fprintf('\b')
0155         end
0156         pths = textscan(getpathways,'%s %[^\n]');
0157         pathnames = pths{1}; pathnames = strrep(pathnames,'path:','');
0158         pathdescription = pths{2};
0159         set(handles.Pathwaylistbox,'String',strcat(pathnames,'_',pathdescription))
0160     end
0161 end
0162 
0163 % --- Executes during object creation, after setting all properties.
0164 function OrganEdit_CreateFcn(hObject, eventdata, handles)
0165 % hObject    handle to OrganEdit (see GCBO)
0166 % eventdata  reserved - to be defined in a future version of MATLAB
0167 % handles    empty - handles not created until after all CreateFcns called
0168 
0169 % Hint: edit controls usually have a white background on Windows.
0170 %       See ISPC and COMPUTER.
0171 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0172     set(hObject,'BackgroundColor','white');
0173 end
0174 
0175 
0176 % --- Executes on button press in DonePush.
0177 function DonePush_Callback(hObject, eventdata, handles)
0178 % hObject    handle to DonePush (see GCBO)
0179 % eventdata  reserved - to be defined in a future version of MATLAB
0180 % handles    structure with handles and user data (see GUIDATA)
0181 PreconsMethod(handles)
0182 
0183 
0184 % --- Executes on selection change in Pathwaylistbox.
0185 function Pathwaylistbox_Callback(hObject, eventdata, handles)
0186 % hObject    handle to Pathwaylistbox (see GCBO)
0187 % eventdata  reserved - to be defined in a future version of MATLAB
0188 % handles    structure with handles and user data (see GUIDATA)
0189 
0190 % Hints: contents = cellstr(get(hObject,'String')) returns Pathwaylistbox contents as cell array
0191 %        contents{get(hObject,'Value')} returns selected item from Pathwaylistbox
0192 
0193 
0194 % --- Executes during object creation, after setting all properties.
0195 function Pathwaylistbox_CreateFcn(hObject, eventdata, handles)
0196 % hObject    handle to Pathwaylistbox (see GCBO)
0197 % eventdata  reserved - to be defined in a future version of MATLAB
0198 % handles    empty - handles not created until after all CreateFcns called
0199 
0200 % Hint: listbox controls usually have a white background on Windows.
0201 %       See ISPC and COMPUTER.
0202 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0203     set(hObject,'BackgroundColor','white');
0204 end
0205 
0206 
0207 % --- Executes on button press in Biographcheck.
0208 function Biographcheck_Callback(hObject, eventdata, handles)
0209 % hObject    handle to Biographcheck (see GCBO)
0210 % eventdata  reserved - to be defined in a future version of MATLAB
0211 % handles    structure with handles and user data (see GUIDATA)
0212 
0213 % Hint: get(hObject,'Value') returns toggle state of Biographcheck
0214 stat = get(hObject,'Value');
0215 if stat
0216     set(handles.Pathwaylistbox,'Enable','on')
0217     set(handles.G2Bradiobutton,'Enable','on')
0218     set(handles.G2Kradiobutton,'Enable','on')
0219     set(handles.G2K2Bradiobutton,'Enable','on')
0220     Org = get(handles.OrganEdit,'String');
0221     if ~strcmp(Org,'Organism code')
0222         Txt1 = 'Downloding pathway data...';
0223         fprintf(Txt1)
0224         [getpathways,stat] = urlread(['http://rest.kegg.jp/list/pathway/',Org]);
0225         if ~stat
0226             msgbox('There is a problem with the internet connection!');
0227             for i =1:numel(Txt1)
0228                 fprintf('\b')
0229             end
0230             return
0231         end
0232         for i =1:numel(Txt1)
0233             fprintf('\b')
0234         end
0235         pths = textscan(getpathways,'%s %[^\n]');
0236         pathnames = pths{1}; pathnames = strrep(pathnames,'path:','');
0237         pathdescription = pths{2};
0238         set(handles.Pathwaylistbox,'String',strcat(pathnames,'_',pathdescription))
0239     end
0240 else
0241     set(handles.Pathwaylistbox,'Enable','off')
0242     set(handles.G2Bradiobutton,'Enable','off')
0243     set(handles.G2Kradiobutton,'Enable','off')
0244     set(handles.G2K2Bradiobutton,'Enable','off')
0245 end

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