Code covered by the BSD License  

Highlights from
Primer Design GUI

image thumbnail

Primer Design GUI

by

 

16 Jun 2011 (Updated )

A GUI for designing primers

PrimerDesignGUI(varargin)
function varargout = PrimerDesignGUI(varargin)
% PRIMERDESIGNGUI M-file for PrimerDesignGUI.fig
%      PRIMERDESIGNGUI, by itself, creates a new PRIMERDESIGNGUI or raises the existing
%      singleton*.
%
%      H = PRIMERDESIGNGUI returns the handle to a new PRIMERDESIGNGUI or the handle to
%      the existing singleton*.
%
%      PRIMERDESIGNGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in PRIMERDESIGNGUI.M with the given input arguments.
%
%      PRIMERDESIGNGUI('Property','Value',...) creates a new PRIMERDESIGNGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before PrimerDesignGUI_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to PrimerDesignGUI_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 PrimerDesignGUI

% Last Modified by GUIDE v2.5 19-Jun-2007 09:22:43
% Copyright 2007 - 2011 MathWorks, Inc.

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @PrimerDesignGUI_OpeningFcn, ...
    'gui_OutputFcn',  @PrimerDesignGUI_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 PrimerDesignGUI is made visible.
function PrimerDesignGUI_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 PrimerDesignGUI (see VARARGIN)

% Choose default command line output for PrimerDesignGUI
handles.output = hObject;
parentColor = [0.6941 0.8078 0.8118];

hPanel = handles.uipanel1;
[handles.LengthSlider,pnl,handles.LengthBox] = sliderPanel(hPanel,...
    {'pos',[0.05 0.825 0.9 0.11],'bordertype','none','backgroundcolor',parentColor},...
    {'min',10,'max',50,'value',20,'sliderstep',[1 5]/40},...
    {},{'backgroundcolor',parentColor},'%0.0f');
[handles.MinTmSlider,pnl,handles.MinTmBox] = sliderPanel(hPanel,...
    {'pos',[0.05 0.57 0.4 0.11],'bordertype','none','backgroundcolor',parentColor},...
    {'min',30,'max',60,'value',50,'sliderstep',[1 5]/30},...
    {},{'backgroundcolor',parentColor},'%0.0f');
[handles.MaxTmSlider,pnl,handles.MaxTmBox] = sliderPanel(hPanel,...
    {'pos',[0.5 0.57 0.4 0.11],'bordertype','none','backgroundcolor',parentColor},...
    {'min',40,'max',70,'value',60,'sliderstep',[1 5]/30},...
    {},{'backgroundcolor',parentColor},'%0.0f');
[handles.MinGCSlider,pnl,handles.MinGCBox] = sliderPanel(hPanel,...
    {'pos',[0.05 0.33 0.4 0.11],'bordertype','none','backgroundcolor',parentColor},...
    {'min',0,'max',100,'value',45,'sliderstep',[1 10]/100},...
    {},{'backgroundcolor',parentColor},'%0.0f');
[handles.MaxGCSlider,pnl,handles.MaxGCBox] = sliderPanel(hPanel,...
    {'pos',[0.5 0.33 0.4 0.11],'bordertype','none','backgroundcolor',parentColor},...
    {'min',0,'max',100,'value',55,'sliderstep',[1 10]/100},...
    {},{'backgroundcolor',parentColor},'%0.0f');
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes PrimerDesignGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = PrimerDesignGUI_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 on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox1


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

% Hint: get(hObject,'Value') returns toggle state of checkbox2


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

% Hint: get(hObject,'Value') returns toggle state of checkbox3


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

% Hint: get(hObject,'Value') returns toggle state of checkbox4


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

% Hint: get(hObject,'Value') returns toggle state of checkbox5


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

% Hint: get(hObject,'Value') returns toggle state of checkbox6


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

% Hint: get(hObject,'Value') returns toggle state of checkbox7


function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (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 edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)




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


% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[fn,pn,findex] = uigetfile({'*.mat';'*.txt';'*.csv';'*.xls';'*.fa';'*.*'},'Retrieve Sequence Data File');
if ~fn
    return
end
switch findex
    case 1
        load([pn fn]);
        sequence = humanHEXA.Sequence;
        setappdata(handles.figure1,'sequence',sequence);
        set(handles.pushbutton4,'enable','on');
    case 2
    case 3
    case 4
    case 5
        s = loadFile(f);
    case 6
end

set(handles.text9,'string',...
    'Select restriction options and levels, and press "EXECUTE."');

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
allboxes = findobj('tag','Chkbox');
if any(cell2mat(get(allboxes,'value')))
    set(allboxes,'value',0);
else
    set(allboxes,'value',1);
end
    
    
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see
% GUIDATA)

cla(handles.axes1);
cla(handles.axes2);
cla(handles.axes3);
set(handles.axes1,'visible','off');
set(handles.axes2,'visible','off');
set(handles.axes3,'visible','off');
delete(findall(handles.figure1,'tag','Primer_annotation'));
delete(findall(handles.figure1,'tag','PDColorbar'));
set(handles.pushbutton5,'enable','off');

if get(handles.Chkbox(5),'value')
    GCRange = [str2num(get(handles.MinGCBox,'String')),str2num(get(handles.MaxGCBox,'String'))];
else
    GCRange = [];
end

if get(handles.Chkbox(6),'value')
    TmRange = [str2num(get(handles.MinTmBox,'String')),str2num(get(handles.MaxTmBox,'String'))];
else
    TmRange = [];
end
TargetLength = str2num(get(handles.LengthBox,'String'));
noSelfDimerization = get(handles.Chkbox(3),'value');
noHairpinFormation = get(handles.Chkbox(4),'value');
requireGCClamp = get(handles.Chkbox(1),'value');
noNucleotideRepeats = get(handles.Chkbox(2),'value');
set(handles.text9,'string','Calculating...Please wait.');
sequence = getappdata(handles.figure1,'sequence');
PrimerList = PrimerDesignFcn(sequence,...
    TargetLength,...
    GCRange,...
    TmRange,...
    noSelfDimerization,...
    noHairpinFormation,...
    requireGCClamp,...
    noNucleotideRepeats,...
    handles);
setappdata(handles.figure1,'PrimerList',PrimerList);


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

% Hint: get(hObject,'Value') returns toggle state of Chkbox


% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
prompt = {'Enter Genbank Accession Number (as a quoted string):'};
dlg_title = 'Access Genbank';
num_lines = 1;
def = {'NM_000520'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
answer = getncbidata(answer{1});
sequence = answer.Sequence;
setappdata(handles.figure1,'sequence',sequence);
set(handles.pushbutton4,'enable','on');
set(handles.text9,'string',...
    'Select restriction options and levels, and press "Execute."');

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


% --------------------------------------------------------------------
function Untitled_8_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(hObject,'checked','on');
set(handles.ExecutionMode,'checked','off');



% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
PrimerList = getappdata(handles.figure1,'PrimerList');
w = evalin('base','who');
match = 0;
ii = 1;
while ~match
    if ismember(['PrimerList' num2str(ii)],w)
        ii = ii+1;
    else
        match = 1;
    end
end
assignin('base',['PrimerList' num2str(ii)],PrimerList);
fprintf('Results written to %s in the Base Workspace.\n',['PrimerList' num2str(ii)]);
set(handles.text9,'string',...
    sprintf('Done.\n\nPrimer list saved to workspace variable %s',['PrimerList' num2str(ii)]));

% --- Use loadFile to read in the sequence data from a file.
function s = loadFile(f)
fileSrc = fullfile(matlabroot,'toolbox','bioinfo','bioinfo','private','seqread.m');
fileDest = fullfile(pwd,'private');
if ~exist(fileDest,'dir')
    mkdir(pwd,'private')
end
copyfile(fileSrc,fileDest);
[s, ft] = seqread(f);
if isfield(s,'Sequence')
    s = getfield(s,'Sequence');
end

Contact us