No BSD License  

Highlights from
dbSNP tool

image thumbnail

dbSNP tool

by

 

02 Oct 2006 (Updated )

GUI for the retrieval of single nucleotide polymorphism data from dbSNP

dbSNP(varargin)
function varargout = dbSNP(varargin)
% DBSNP M-file for dbSNP.fig
%      DBSNP, by itself, creates a new DBSNP or raises the existing
%      singleton*.
%
%      H = DBSNP returns the handle to a new DBSNP or the handle to
%      the existing singleton*.
%
%      DBSNP('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DBSNP.M with the given input arguments.
%
%      DBSNP('Property','Value',...) creates a new DBSNP or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before dbSNP_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to dbSNP_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help dbSNP

% Last Modified by GUIDE v2.5 02-Oct-2006 14:52:20

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @dbSNP_OpeningFcn, ...
    'gui_OutputFcn',  @dbSNP_OutputFcn, ...
    'gui_LayoutFcn',  [] , ...
    'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before dbSNP is made visible.
function dbSNP_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to dbSNP (see VARARGIN)

% Choose default command line output for dbSNP
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes dbSNP wait for user response (see UIRESUME)
% uiwait(handles.dbsnpGUI);

movegui(handles.dbsnpGUI,'center');
%place the entrez logo in the GUI using an axes
image(imread('logo.jpg'));axis off;


set(gcf, 'CurrentAxes', handles.imholder2);
image(imread('snp.jpg'));axis off;

%set the button images
set(handles.searchButton,       'cdata', searchButton);
set(handles.structureOutBut,    'cdata', structureOutBut);
set(handles.fileOutputBut,      'cdata', fileOutputBut);

% --- Outputs from this function are returned to the command line.
function varargout = dbSNP_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes during object creation, after setting all properties.
function searchTerm_CreateFcn(hObject, eventdata, handles)
% hObject    handle to searchTerm (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in searchButton.
function searchButton_Callback(hObject, eventdata, handles)
% hObject    handle to searchButton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global numResults
%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-
set(handles.structureOutBut, 'Enable', 'off');
set(handles.fileOutputBut, 'Enable', 'off');
set(handles.text1,  'visible','off');
set(handles.text9,  'visible','off');
set(handles.text10, 'visible','off');
set(handles.text12, 'visible','off');
set(handles.text13, 'visible','off');
set(handles.text17, 'visible','off');
set(handles.text15, 'visible','off');
set(handles.text11, 'visible','off');
set(handles.text16, 'visible','off');
set(handles.text14, 'visible','off');
set(handles.text18, 'visible','off');
%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-
%change axes focus
set(gcf, 'CurrentAxes', handles.imholder2);
image(imread('snp.jpg'));axis off;

%resetlistbox
set(handles.resListbox, 'String', {});

%create url to query dbSNP
urlFetch = strcat('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=snp&retype=flt&retmax=',...
    num2str(numResults),'&term=',get(handles.searchTerm,'String'));

%return the fasta results in xml format
fetchResults = char(strread(urlread(urlFetch),'%s','delimiter','\n','whitespace',''));
fetchResults = cellstr(fetchResults);
fetchResults = strtrim(fetchResults);

%select the ids from the xml 
numLines = strmatch('<Id>',fetchResults);
[mat, idx] = regexp(fetchResults(numLines,:),'\d','match','start');

for i = 1:length(mat)
    mat{i} =char(mat{i})';
end

if isempty(mat)
    msgbox('No dbSNP entries retrieved');
else
    set(handles.resListbox, 'String', mat);
end

function sequence_Callback(hObject, eventdata, handles)
% hObject    handle to sequence (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of sequence as text
%        str2double(get(hObject,'String')) returns contents of sequence as a double


% --- Executes during object creation, after setting all properties.
function sequence_CreateFcn(hObject, eventdata, handles)
% hObject    handle to sequence (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in resListbox.
function resListbox_Callback(hObject, eventdata, handles)
% hObject    handle to resListbox (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns resListbox contents as cell array
%        contents{get(hObject,'Value')} returns selected item from resListbox

dbsnpId = get(hObject,'Value');
id = get(hObject,'string');

try
urlSearch = strcat('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=snp&id=',...
    num2str(id{dbsnpId}),'&retmode=text&rettype=fasta');
catch
    msgbox('No dbSNP entries retrieved');
    return
end

idResultFasta = urlread(urlSearch);
set(handles.resListbox, 'UserData', idResultFasta);
idResult = cellstr(char(strread(idResultFasta,'%s','delimiter','|')));
cla;

%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-
%display thee text in snpinfopanel
set(handles.text1,  'String', idResult{1},  'visible','on');
set(handles.text9,  'String', idResult{2},  'visible','on');
set(handles.text10,  'String', idResult{3}, 'visible','on');
set(handles.text12,  'String', idResult{4}, 'visible','on');
set(handles.text13,  'String', idResult{5}, 'visible','on');
set(handles.text17,  'String', idResult{6}, 'visible','on');
set(handles.text15,  'String', idResult{7}, 'visible','on');
set(handles.text11,  'String', idResult{8}, 'visible','on');
set(handles.text16,  'String', idResult{9}, 'visible','on');
set(handles.text14,  'String', idResult{10}, 'visible','on');
set(handles.text18, 'String', idResult{11}, 'visible','on');
%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%

dbsnpTool=sprintf('%s \n','dbSNP accession for the snp:','ss# refers to submitted snp accession.',...
    'rs# refers to the accession of refSNP cluster of one or more submitted snp.');
set(handles.text12,'ToolTipString',dbsnpTool);
numLines = strmatch('build',idResult);
sequence1 = idResult(numLines+1:end);
set(handles.sequence, 'String', lower(sequence1));

set(handles.structureOutBut, 'Enable', 'on');
set(handles.fileOutputBut, 'Enable', 'on');

% --- Executes during object creation, after setting all properties.
function resListbox_CreateFcn(hObject, eventdata, handles)
% hObject    handle to resListbox (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%
%place images on buttons
%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%

function fileLoad_pic = searchButton
fileLoad_pic= iconize(imread(strcat('search.jpg')));
fileLoad_pic(fileLoad_pic==255) = 10*255;


function structureOutButPic = structureOutBut
structureOutButPic= iconize(imread(strcat('matlab_1.jpg')));
structureOutButPic(structureOutButPic==255) = 1*255;


function fileOutputButPic = fileOutputBut
fileOutputButPic= iconize(imread(strcat('file.jpg')));
fileOutputButPic(fileOutputButPic==255) = 1*255;

function out = iconize(a)
% Find the size of the acquired image and determine how much data will need
% to be lost in order to form a 18x18 icon
[r,c,d] = size(a);
r_skip = ceil(r/200);
c_skip = ceil(c/200);

% Create the 18x18 icon (RGB data)
out = a(1:r_skip:end,1:c_skip:end,:);



function selectNum_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to selectNum (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

set(handles.selectNum,'SelectionChangeFcn',@selcbk);


%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%
% radio button callback
%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%
function selcbk(source,eventdata)
global numResults
numResults =  get(eventdata.NewValue,'String');


% --- Executes on button press in structureOutBut.
function structureOutBut_Callback(hObject, eventdata, handles)
% hObject    handle to structureOutBut (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%
% output selected result to fasta
%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%
idResultFasta = get(handles.resListbox, 'UserData');
dbsnpId = get(handles.resListbox,'Value');
ids = get(handles.resListbox,'string');
assignin('base',strcat('rs',num2str(ids{dbsnpId})), fastaread(idResultFasta));
set(handles.structureOutBut, 'Enable', 'off');
% --- Executes on button press in fileOutputBut.

function fileOutputBut_Callback(hObject, eventdata, handles)
% hObject    handle to fileOutputBut (see GCBO)
% eventdata  reserved - to be defined in a future version of
% handles    structure with handles and user data (see GUIDATA)

%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%
% output result to fasta file
%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%
idResultFasta = get(handles.resListbox, 'UserData');
dbsnpId = get(handles.resListbox,'Value');
ids = get(handles.resListbox,'string');
fastawrite(strcat(num2str(ids{dbsnpId}),'.fa'),fastaread(idResultFasta));
set(handles.fileOutputBut, 'Enable', 'off');


Contact us