%% Tailed Primer Design % % The goal of this script is to take an input file containing untailed RPA % Basic primers and generate tailed primer sets to screen %% Import data and labels % Import CSV containing untailed RPA Basic primer sequences % CSV has 3 columns: Target, Forward Primer, Reverse Primer filename = 'nontailedsequences.csv'; % Read data in file into a table datatable = readtable(filename); % Convert table to cell array primerdesign = table2struct(datatable); %% Store properties of the original primers in structure field for i=1:length(primerdesign) primerdesign(i).forwardprimerprops = oligoprop(primerdesign(i).ForwardPrimer); primerdesign(i).reverseprimerprops = oligoprop(primerdesign(i).ReversePrimer); end %% Generate random 15bp sequence tails % Generate j random sequences, and attach in new column in cell numtails =200; i=1; j=1; for i = 1:length(primerdesign) %number of HPV types in imported table for j= 1:numtails %number of tail sequences to generate %create an array with the first 15 bp tail if j == 1 randtail = randseq(15); randtails = [randtail]; %For subsequent tails after the first one, add new tail to the array else randtail = randseq(15); randtails = [randtails; randtail]; end end %store this random tail array in the primerdesign structure primerdesign(i).tails = randtails; end %% Generate tailed forward and reverse primers % Reset counters i=i; j=i; % Cycle through the number of rows for i = 1:length(primerdesign) % Step through the number of tails for j= 1:numtails % Create tailed forward and reverse primers primerdesign(i).tailedforward(j,:) = strcat(primerdesign(i).tails(j,:), primerdesign(i).ForwardPrimer); primerdesign(i).tailedreverse(j,:) = strcat(primerdesign(i).tails(j,:), primerdesign(i).ReversePrimer); % Store a separate set of tailed primers that %have internal spacer between tail and primer for ease of ordering primerdesign(i).tailedforwardspaced(j,:) = strcat(primerdesign(i).tails(j,:), '/iSpC3/' ,primerdesign(i).ForwardPrimer); primerdesign(i).tailedreversespaced(j,:) = strcat(primerdesign(i).tails(j,:), '/iSpC3/', primerdesign(i).ReversePrimer); % Store the oligonucleotide properties of tailed forward/reverse primers primerdesign(i).tailprops(j,1)= oligoprop(primerdesign(i).tails(j,:)); primerdesign(i).tailedforwardprops(j,1) = oligoprop (primerdesign(i).tailedforward(j,:)); primerdesign(i).tailedreverseprops(j,1) = oligoprop(primerdesign(i).tailedreverse(j,:)); end end %% Filter Bad Tails and Bad Tailed Primers % Code based on Exploring Primer Design Help Page from MathWorks % https://www.mathworks.com/help/bioinfo/examples/exploring-primer-design.html i=1; j=1; for i = 1:length(primerdesign) % (i) Find tails with GC content greater than 45% primerdesign(i).badtailsgc = [primerdesign(i).tailprops.GC]' > 45 ; for j=1:numtails %(iiA): Find tailed primers with MORE dimers than the origianl % primers primerdesign(i).badfpdimers(j,1) = size(primerdesign(i).tailedforwardprops(j).Dimers,1) > size(primerdesign(i).forwardprimerprops.Dimers,1); primerdesign(i).badrpdimers(j,1) = size(primerdesign(i).tailedreverseprops(j).Dimers,1) > size(primerdesign(i).reverseprimerprops.Dimers,1); % (iiB): Find tailed primers with MORE hairpins than the original % primers primerdesign(i).badfphairpins(j,1) = size(primerdesign(i).tailedforwardprops(j).Hairpins,1) > size(primerdesign(i).forwardprimerprops.Hairpins,1); primerdesign(i).badrphairpins(j,1) = size(primerdesign(i).tailedreverseprops(j).Hairpins,1) > size(primerdesign(i).reverseprimerprops.Hairpins,1); end end %% Combine'bad' arrays to find good tailed forward or reverse primers i = 1; for i=1:length(primerdesign) %Storing all the bad primers into one array primerdesign(i).badtailedfpsall = [primerdesign(i).badtailsgc, primerdesign(i).badfpdimers, primerdesign(i).badfphairpins]; primerdesign(i).badtailedrpsall = [primerdesign(i).badtailsgc, primerdesign(i).badrpdimers, primerdesign(i).badrphairpins]; % At this point, '1' indicates a tailed primer that fails screening criteria % Switch '1's to be good primers and then scan through each row to see % if a tailed primer meets all the criteria and store the position of % tailed primers that pass screening primerdesign(i).goodfppos = find(all(~primerdesign(i).badtailedfpsall,2)); primerdesign(i).goodrppos = find(all(~primerdesign(i).badtailedrpsall,2)); %Pull out the tailed primers that pass primerdesign(i).goodtailedfps = primerdesign(i).tailedforward(primerdesign(i).goodfppos, :); primerdesign(i).goodtailedrps = primerdesign(i).tailedreverse(primerdesign(i).goodrppos, :); % Pull out the corresponding tailed primers with spacers primerdesign(i).goodtailedfpsspaced = primerdesign(i).tailedforwardspaced(primerdesign(i).goodfppos, :); primerdesign(i).goodtailedrpsspaced = primerdesign(i).tailedreversespaced(primerdesign(i).goodrppos, :); end %% Align tailed primers and checking for additional crossdimerization % Check for cross dimerization scr_mat = [-1,-1,-1,1;-1,-1,1,-1;-1,1,-1,-1;1,-1,-1,-1;]; i=1; j=1; k=1; for i=1:length(primerdesign) % Set the Cross-Dimerization Threshold as the Dimer threshold % between untailed forward/reverse primers primerdesign(i).dimerthreshold = swalign(primerdesign(i).ForwardPrimer, primerdesign(i).ReversePrimer, ... 'SCORINGMATRIX', scr_mat, 'GAPOPEN',5,'ALPHA','NT'); % Loop through the number of good tailed forward primers and storing their % dimerization with the reverse primer if size(primerdesign(i).goodtailedfps, 1) >0 for j = 1: size(primerdesign(i).goodtailedfps, 1) primerdesign(i).crossdimer_tfp(j) = swalign(primerdesign(i).ReversePrimer,... primerdesign(i).goodtailedfps(j,:), 'SCORINGMATRIX', scr_mat,'GAPOPEN',5,... 'ALPHA','NT'); end end % Loop through the number of good tailed reverse primers and storing their % dimerization score with the forward primer if size(primerdesign(i).goodtailedrps, 1) >0 for k=1:size(primerdesign(i).goodtailedrps, 1) primerdesign(i).crossdimer_trp(k) = swalign(primerdesign(i).ForwardPrimer,... primerdesign(i).goodtailedrps(k,:), 'SCORINGMATRIX', scr_mat, 'GAPOPEN',5,... 'ALPHA','NT'); end end % (iii) Find tailed primer combos that do not result in additional % cross-dimerization compared to the untailed primer pair primerdesign(i).finaltfps_pos = find(primerdesign(i).crossdimer_tfp <= primerdesign(i).dimerthreshold); primerdesign(i).finaltrps_pos = find(primerdesign(i).crossdimer_trp <= primerdesign(i).dimerthreshold); % These are the final sequences to input into IDT containing the C3 spacer primerdesign(i).finaltfpsspaced = primerdesign(i).goodtailedfpsspaced(primerdesign(i).finaltfps_pos,:); primerdesign(i).finaltrpsspaced = primerdesign(i).goodtailedrpsspaced(primerdesign(i).finaltrps_pos, :); end