Home > FR3DSource > xGetNuclSpec.m

xGetNuclSpec

PURPOSE ^

xGetNuclSpec parses the text for nucleotide mask, angle weight, location weight

SYNOPSIS ^

function [OK,LW,AW] = xGetNuclSpec(str)

DESCRIPTION ^

 xGetNuclSpec parses the text for nucleotide mask, angle weight, location weight

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % xGetNuclSpec parses the text for nucleotide mask, angle weight, location weight
0002 
0003 function [OK,LW,AW] = xGetNuclSpec(str)
0004 
0005 OK    = [];
0006 AW    = [];
0007 LW    = [];
0008 
0009 if length(str) > 0,
0010 
0011   str    = upper(regexprep(str,';| ',',')); % replace delims by commas
0012   while strfind(str,',,'),
0013     str = regexprep(str,',,',',');
0014   end
0015   str    = regexprep(str,'LW,','LW');       % replace delims by commas
0016   str    = regexprep(str,'AW,','AW');       % replace delims by commas
0017   str    = regexprep(str,'LW','l');         % replace LW by l
0018   str    = regexprep(str,'AW','a');         % replace AW by a
0019   commas = strfind(str,',');                % find locations of commas
0020   lim    = [0 commas length(str)+1];        % locations of tokens
0021   
0022   for i=1:length(lim)-1                     % loop through tokens
0023         
0024     Token = str(lim(i)+1:lim(i+1)-1);       % extract next token
0025     if Token(1) == '~',                     % opposite of usual sense
0026       Reverse = 1;
0027       Token   = Token(2:length(Token));
0028     else
0029       Reverse = 0;
0030     end
0031   
0032     if Token(1) == 'l',                     % location weight
0033       LW = str2num(Token(2:length(Token))); % extract number
0034     elseif Token(1) == 'a',                 % angle weight
0035       AW = str2num(Token(2:length(Token))); % extract number
0036     else                                    % nucleotide being specified
0037       Nucl = zeros(1,4);                    % start with 0
0038       for i=1:length(Token),                % go through letters here
0039         switch Token(i)
0040           case 'A', Nucl = Nucl + [1 0 0 0];
0041           case 'C', Nucl = Nucl + [0 1 0 0];
0042           case 'G', Nucl = Nucl + [0 0 1 0];
0043           case 'U', Nucl = Nucl + [0 0 0 1];
0044           case 'M', Nucl = Nucl + [1 1 0 0];
0045           case 'R', Nucl = Nucl + [1 0 1 0];
0046           case 'W', Nucl = Nucl + [1 0 0 1];
0047           case 'S', Nucl = Nucl + [0 1 1 0];
0048           case 'Y', Nucl = Nucl + [0 1 0 1];
0049           case 'K', Nucl = Nucl + [0 0 1 1];
0050           case 'V', Nucl = Nucl + [1 1 1 0];
0051           case 'H', Nucl = Nucl + [1 1 0 1];
0052           case 'D', Nucl = Nucl + [1 0 1 1];
0053           case 'B', Nucl = Nucl + [0 1 1 1];
0054           case 'N', Nucl = Nucl + [1 1 1 1];
0055         end
0056       end
0057       Nucl = min([1 1 1 1],Nucl);           
0058       if max(Nucl) > 0,                         % something specified
0059         if isempty(OK),                         % no mask yet
0060           if Reverse == 0,                      %
0061             OK = Nucl;
0062           else
0063             OK = 1 - Nucl; 
0064           end
0065         else
0066           if Reverse == 0,
0067             OK = max(OK, Nucl);
0068           else
0069             OK = min(OK, 1-Nucl);
0070           end
0071         end
0072       end
0073 
0074     end
0075   end
0076 end
0077 
0078 if isempty(OK),
0079   OK = [1 1 1 1];
0080 end
0081 
0082 if isempty(LW),
0083   LW = 1;
0084 end
0085 
0086 if isempty(AW),
0087   AW = 1;
0088 end

Generated on Fri 03-Apr-2009 09:52:35 by m2html © 2003