Home > FR3DSource > xGetDiffSpec.m

xGetDiffSpec

PURPOSE ^

xGetDiffSpec parses the text for nucleotide differences

SYNOPSIS ^

function [mindiff,maxdiff,sign] = xGetDiffSpec(str)

DESCRIPTION ^

 xGetDiffSpec parses the text for nucleotide differences

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % xGetDiffSpec parses the text for nucleotide differences
0002 
0003 function [mindiff,maxdiff,sign] = xGetDiffSpec(str)
0004 
0005 mindiff = 1;                                % defaults
0006 maxdiff = Inf;
0007 
0008 sign    = 0;                                % default sign of difference
0009 
0010 if length(str) > 0,
0011 
0012   str    = regexprep(str,';| ',',');        % replace delims by commas
0013   while strfind(str,',,'),
0014     str = regexprep(str,',,',',');          % remove double commas
0015   end
0016   str    = regexprep(str,'>=','g');         % replace
0017   str    = regexprep(str,'<=','l');         % replace
0018   str    = regexprep(str,'==','=');         % replace
0019   str    = regexprep(str,'<,','<');         % replace
0020   str    = regexprep(str,'>,','>');         % replace
0021   str    = regexprep(str,'l,','l');         % replace
0022   str    = regexprep(str,'g,','g');         % replace
0023   str    = regexprep(str,'=,','=');         % replace
0024   str    = regexprep(str,'d','');           % replace d by nothing
0025   str    = regexprep(str,'D','');           % replace D by nothing
0026 
0027   lt = strfind(str,'>');
0028   for i=length(lt):-1:1,
0029    if lt(i)+1 <= length(str),
0030     if any(str(lt(i)+1) == 'gl=<>'),
0031       str = [str(1:lt(i)) ',' str(lt(i)+1:length(str))];    
0032     end
0033    end
0034   end
0035 
0036   lt = strfind(str,'<');
0037   for i=length(lt):-1:1,
0038    if lt(i)+1 <= length(str),
0039     if any(str(lt(i)+1) == 'gl=<>'),
0040       str = [str(1:lt(i)) ',' str(lt(i)+1:length(str))];    
0041     end
0042    end
0043   end
0044 
0045   commas = strfind(str,',');                % find locations of commas
0046   lim    = [0 commas length(str)+1];        % locations of tokens
0047   
0048   for i=1:length(lim)-1                     % loop through tokens
0049     Token = str(lim(i)+1:lim(i+1)-1);       % extract next token
0050     if length(Token) > 1,                   % first character is a symbol
0051       n = str2num(Token(2:length(Token)));    % extract number
0052       if ~isempty(n),
0053         switch Token(1)
0054           case '<', maxdiff = min(maxdiff,n-1); % reduce maxdiff
0055           case 'l', maxdiff = min(maxdiff,n);   % reduce maxdiff
0056           case '>', mindiff = max(mindiff,n+1); % increase mindiff
0057           case 'g', mindiff = max(mindiff,n);   % increase mindiff
0058           case '=', mindiff = n;
0059                     maxdiff = n;
0060         end
0061       end
0062     elseif length(Token) > 0,
0063       switch Token(1)
0064         case '<', sign = -1;
0065         case '>', sign =  1;
0066       end
0067     end
0068 
0069   end
0070 end
0071

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