Home > FR3DSource > xGetEdgeNums.m

xGetEdgeNums

PURPOSE ^

xGetEdgeNums parses the entries in the GUI concerning base-base interactions

SYNOPSIS ^

function [ReqEdge,ExEdge,OKPairs,ExPairs,BP1,BP2,EBP1,EBP2,Flank,Range,Coplanar,ReqBB,ExBB] = xGetEdgeNums(str)

DESCRIPTION ^

 xGetEdgeNums parses the entries in the GUI concerning base-base interactions

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % xGetEdgeNums parses the entries in the GUI concerning base-base interactions
0002 
0003 function [ReqEdge,ExEdge,OKPairs,ExPairs,BP1,BP2,EBP1,EBP2,Flank,Range,Coplanar,ReqBB,ExBB] = xGetEdgeNums(str)
0004 
0005 ReqEdge = [];
0006 ExEdge  = [];
0007 OKPairs  = [];
0008 ExPairs  = [];
0009 BP1      = [];
0010 BP2      = [];
0011 EBP1     = [];
0012 EBP2     = [];
0013 Flank    = [];
0014 Range    = [];
0015 RRange   = [];
0016 Coplanar = 0;
0017 NearCoplanar = 0;
0018 ReqBB    = [];
0019 ExBB     = [];
0020 
0021 % ------------------------------ Define relevant strings and associated codes
0022 
0023 EdgeStr{1} = 'cWW';
0024 BPequiv{1} = [1 -1];
0025 
0026 EdgeStr{2} = 'tWW';
0027 BPequiv{2} = [2 -2];
0028 
0029 EdgeStr{3} = 'cWH';
0030 BPequiv{3} = [3];
0031 
0032 EdgeStr{4} = 'cHW';
0033 BPequiv{4} = [-3];
0034 
0035 EdgeStr{5} = 'tWH';
0036 BPequiv{5} = [4];
0037 
0038 EdgeStr{6} = 'tHW';
0039 BPequiv{6} = [-4];
0040 
0041 EdgeStr{7} = 'cWS';
0042 BPequiv{7} = [5];
0043 
0044 EdgeStr{8} = 'cSW';
0045 BPequiv{8} = [-5];
0046 
0047 EdgeStr{9} = 'tWS';
0048 BPequiv{9} = [6];
0049 
0050 EdgeStr{10} = 'tSW';
0051 BPequiv{10} = [-6];
0052 
0053 EdgeStr{11} = 'cHH';
0054 BPequiv{11} = [7 -7];
0055 
0056 EdgeStr{12} = 'tHH';
0057 BPequiv{12} = [8 -8];
0058 
0059 EdgeStr{13} = 'cHS';
0060 BPequiv{13} = [9];
0061 
0062 EdgeStr{14} = 'cSH';
0063 BPequiv{14} = [-9];
0064 
0065 EdgeStr{15} = 'tHS';
0066 BPequiv{15} = [10];
0067 
0068 EdgeStr{16} = 'tSH';
0069 BPequiv{16} = [-10];
0070 
0071 EdgeStr{17} = 'cSS';
0072 BPequiv{17} = [11 -11];
0073 
0074 EdgeStr{18} = 'cSs';
0075 BPequiv{18} = [11];
0076 
0077 EdgeStr{19} = 'csS';
0078 BPequiv{19} = [-11];
0079 
0080 EdgeStr{20} = 'tSS';
0081 BPequiv{20} = [12 -12];
0082 
0083 EdgeStr{21} = 'tSs';
0084 BPequiv{21} = [12];
0085 
0086 EdgeStr{22} = 'tsS';
0087 BPequiv{22} = [-12];
0088 
0089 EdgeStr{23} = 'sP';
0090 BPequiv{23} = [21 -21];
0091 
0092 EdgeStr{24} = 'sA';
0093 BPequiv{24} = [22 -22 23 -23];
0094 
0095 EdgeStr{25} = 's35';
0096 BPequiv{25} = [21];
0097 
0098 EdgeStr{26} = 's53';
0099 BPequiv{26} = [-21];
0100 
0101 EdgeStr{27} = 's33';
0102 BPequiv{27} = [22 -22];
0103 
0104 EdgeStr{28} = 's55';
0105 BPequiv{28} = [23 -23];
0106 
0107 EdgeStr{29} = 'NP';            % close enough to interact,
0108                                % but not classified or near a class
0109 BPequiv{29} = [30 -30];
0110 
0111 EdgeStr{30} = 'Pair';
0112 BPequiv{30} = [-12:-1 1:12];
0113 
0114 EdgeStr{31} = 'Stack';
0115 BPequiv{31} = [21:23 -23:-21];
0116 
0117 EdgeStr{32} = 'cis';
0118 BPequiv{32} = [1 3 5 7 9 11 -1 -3 -5 -7 -9 -11];
0119 
0120 EdgeStr{33} = 'trans';
0121 BPequiv{33} = [2 4 6 8 10 12 -2 -4 -6 -8 -10 -12];
0122 
0123 EdgeStr{34} = 'bif';
0124 BPequiv{34} = [13 -13];
0125 
0126 EdgeStr{35} = 'cWw';
0127 BPequiv{35} = [1];
0128 
0129 EdgeStr{36} = 'cwW';
0130 BPequiv{36} = [-1];
0131 
0132 EdgeStr{37} = 'cHh';
0133 BPequiv{37} = [7];
0134 
0135 EdgeStr{38} = 'chH';
0136 BPequiv{38} = [-7];
0137 
0138 EdgeStr{39} = 'tHh';
0139 BPequiv{39} = [8];
0140 
0141 EdgeStr{40} = 'thH';
0142 BPequiv{40} = [-8];
0143 
0144 %BPCat = [2 6 8 0 6 7 8 9 0 1 3 4 5 0 5 8 0];  % updated 8-7-2008
0145 %         1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
0146 
0147 % Convert external category names for BP interactions to internal codes
0148 
0149 BPStr{1}    = 'BPh';
0150 basephoscode{1}  = 1:17;
0151 
0152 BPStr{2}    = '1BPh';
0153 basephoscode{2}  = [10];
0154 
0155 BPStr{3}    = '2BPh';
0156 basephoscode{3}  = [1];
0157 
0158 BPStr{4}    = '3BPh';
0159 basephoscode{4}  = [11];
0160 
0161 BPStr{5}    = '4BPh';
0162 basephoscode{5}  = [12 19];
0163 
0164 BPStr{6}    = '5BPh';
0165 basephoscode{6}  = [13 15];
0166 
0167 BPStr{7}    = '6BPh';
0168 basephoscode{7}  = [2 5];
0169 
0170 BPStr{8}    = '7BPh';
0171 basephoscode{8}  = [3 6 18];
0172 
0173 BPStr{9}    = '8BPh';
0174 basephoscode{9}  = [7];
0175 
0176 BPStr{10}    = '9BPh';
0177 basephoscode{10}  = [8 16];
0178 
0179 BPStr{11}    = '0BPh';
0180 basephoscode{11}  = [4 9 14 17];
0181 
0182 BPStr{12}    = '4bBP';
0183 basephoscode{12}  = [19];
0184 
0185 BPStr{13}    = '8bBP';
0186 basephoscode{13}  = [18];
0187 
0188 BPStr{14}    = '4bBPh';
0189 basephoscode{14}  = [19];
0190 
0191 BPStr{15}    = '8bBPh';
0192 basephoscode{15}  = [18];
0193 
0194 BPStr{21}    = 'PhB';
0195 basephoscode{21}  = 1:17;
0196 
0197 BPStr{22}    = '1PhB';
0198 basephoscode{22}  = [10];
0199 
0200 BPStr{23}    = '2PhB';
0201 basephoscode{23}  = [1];
0202 
0203 BPStr{24}    = '3PhB';
0204 basephoscode{24}  = [11];
0205 
0206 BPStr{25}    = '4PhB';
0207 basephoscode{25}  = [12];
0208 
0209 BPStr{26}    = '5PhB';
0210 basephoscode{26}  = [13 15];
0211 
0212 BPStr{27}    = '6PhB';
0213 basephoscode{27}  = [2 5];
0214 
0215 BPStr{28}    = '7PhB';
0216 basephoscode{28}  = [3 6 18];
0217 
0218 BPStr{29}    = '8PhB';
0219 basephoscode{29}  = [7];
0220 
0221 BPStr{30}    = '9PhB';
0222 basephoscode{30}  = [8 16];
0223 
0224 BPStr{31}    = '0PhB';
0225 basephoscode{31}  = [4 9 14 17];
0226 
0227 BPStr{32}    = '4bPB';
0228 basephoscode{32}  = [19];
0229 
0230 BPStr{33}    = '8bPB';
0231 basephoscode{33}  = [18];
0232 
0233 BPStr{34}    = '4bPhB';
0234 basephoscode{34}  = [19];
0235 
0236 BPStr{35}    = '8bPhB';
0237 basephoscode{35}  = [18];
0238 
0239 BPequiv{100} = [];
0240 
0241 zBackboneCodes;
0242 BBStr = Codes;
0243 
0244 % 1-AA  2-CA  3-GA  4-UA  5-AC  6-CC  7-GC  8-UC
0245 % 9-AG 10-CG 11-GG 12-UG 13-AU 14-CU 15-GU 16-UU
0246 
0247 Pairs = {'AA' 'CA' 'GA' 'UA' 'AC' 'CC' 'GC' 'UC' 'AG' 'CG' 'GG' 'UG' 'AU' 'CU' 'GU' 'UU' ''};
0248 
0249 str    = strrep(str,'any','');      % no restriction
0250   
0251 str    = strrep(str,';',',');       % replace delims by commas
0252 str    = strrep(str,':',',');       % replace delims by commas
0253 str    = strrep(str,'|',',');       % replace delims by commas
0254 str    = strrep(str,' ',',');       % replace delims by commas
0255 
0256 while strfind(str,',,'),
0257   str = strrep(str,',,',',');
0258 end
0259 
0260 if str(end) == ',',
0261   str = str(1:(end-1));
0262 end
0263 
0264 if str(1) == ',',
0265   str = str(2:end);
0266 end
0267 
0268 commas = strfind(str,',');               % find locations of commas
0269 
0270 if isempty(str),
0271   lim = [];
0272 else
0273   lim = [0 commas length(str)+1];        % locations of edge specifications
0274 end
0275 
0276 for i=1:length(lim)-1                    % loop through tokens
0277   Token = str(lim(i)+1:lim(i+1)-1);     % extract next token
0278   if Token(1) == '~',                   % this token, opposite of usual sense
0279     Token = Token(2:length(Token));
0280     Reverse = 1;
0281   else
0282     Reverse = 0;
0283   end
0284 
0285   if ((Token(1) == 'n') | (Token(1) == 'N')) && (length(Token) > 1),  % near
0286     Token = Token(2:length(Token));
0287     Near = 1;
0288   else
0289     Near = 0;
0290   end
0291 
0292   EdgeNum  = str2num(Token);               % try converting to a number
0293   PairCode = [];                           % default; nothing
0294   newBP1   = [];
0295   newBP2   = [];
0296   CP       = 0;
0297   nCP      = 0;
0298 
0299   if isempty(EdgeNum)                      % Token IS a string
0300     edg  = find(strcmp(EdgeStr,Token));    % case sensitive
0301     edgi = find(strcmpi(EdgeStr,Token));   % case insensitive
0302     pair = find(strcmpi(Pairs,Token));     % case insensitive
0303     basephos = find(strcmpi(BPStr,Token)); % case insensitive
0304     bb   = find(strcmpi(BBStr,Token));
0305 
0306     EdgeCode = 99;                         % default; nothing
0307 
0308     if ~isempty(edg),
0309       EdgeCode = edg(1);
0310     elseif ~isempty(edgi),
0311       EdgeCode = edgi(1);
0312     elseif ~isempty(pair),
0313       PairCode = pair(1);
0314     elseif ~isempty(basephos),
0315       if basephos(1) < 20,
0316         newBP1 = basephoscode{basephos(1)};
0317       else
0318         newBP2 = basephoscode{basephos(1)};          
0319       end
0320     elseif ~isempty(bb),
0321       BBCode = bb(1);
0322     end
0323 
0324     newRange = [];
0325 
0326     if strcmpi(Token,'flank') || strcmpi(Token,'f'),
0327       Flank = 1 - Reverse;
0328     elseif strcmpi(Token,'coplanar') || strcmpi(Token,'cp'),
0329       CP = 1 - 2*Reverse;
0330     elseif strcmpi(Token,'local') || strcmpi(Token,'L'),
0331       newRange = [1 10];
0332       newRRange = [11 Inf];
0333     elseif strcmpi(Token,'ested') || strcmpi(Token,'n'),
0334       newRange = [0 0];
0335       newRRange = [1 Inf];
0336     elseif strcmpi(Token,'long-range') || strcmpi(Token,'LR') || strcmpi(Token,'D') || strcmpi(Token,'Distant'),
0337       newRange = [11 Inf];
0338       newRRange = [0 10];
0339     end
0340 
0341     if isempty(Range),
0342       if ~isempty(newRange),
0343         Range = newRange;
0344         RRange = newRRange;
0345       end
0346     elseif ~isempty(newRange),
0347       Range(1) = min(Range(1),newRange(1));     % expand range
0348       Range(2) = max(Range(2),newRange(2));
0349       RRange(1) = max(RRange(1),newRRange(1));  % narrow RRange
0350       RRange(2) = min(RRange(2),newRRange(2));
0351     end
0352 
0353     EdgeNum = BPequiv{EdgeCode};
0354 
0355     if Near > 0,
0356       NearEdgeNum = [];
0357       for j = 1:length(EdgeNum),
0358         e = EdgeNum(j);
0359         NearEdgeNum = [NearEdgeNum sign(e) * (100 + abs(e))];
0360       end
0361       EdgeNum = NearEdgeNum;
0362 
0363       newBP1 = newBP1 + 100;
0364       newBP2 = newBP2 + 100;
0365 
0366       if (CP ~= 0),
0367         nCP = CP;
0368         CP  = 0;
0369       end
0370     end
0371   end
0372 
0373   if Reverse == 0,
0374     ReqEdge = [ReqEdge EdgeNum];
0375     OKPairs = [OKPairs PairCode];
0376     BP1     = [BP1 newBP1];
0377     BP2     = [BP2 newBP2];
0378     ReqBB   = [ReqBB bb];
0379   else
0380     ExEdge  = [ExEdge EdgeNum];
0381     ExPairs = [ExPairs PairCode];
0382     EBP1    = [EBP1 newBP1];
0383     EBP2    = [EBP2 newBP2];
0384     Range   = RRange;
0385     ExBB    = [ExBB bb];
0386   end
0387 
0388   if (CP ~= 0),
0389     Coplanar = CP;
0390   end
0391   if (nCP ~= 0)
0392     NearCoplanar = nCP;
0393   end
0394 end
0395 
0396 if     (Coplanar == 0) && (NearCoplanar == 0),
0397   Coplanar = [];
0398 elseif (Coplanar == -1) && (NearCoplanar == 0),
0399   Coplanar = 0;
0400 elseif (Coplanar == 1) && (NearCoplanar == 0),
0401   Coplanar = 1;
0402 elseif (Coplanar == 1) && (NearCoplanar == -1),
0403   Coplanar = 1;
0404 elseif (Coplanar == 1) && (NearCoplanar == 1),
0405   Coplanar = 2;
0406 elseif (Coplanar == 0) && (NearCoplanar == 1),
0407   Coplanar = 3;
0408 elseif (Coplanar == -1) && (NearCoplanar == 1),
0409   Coplanar = 3;
0410 elseif (Coplanar == 0) && (NearCoplanar == -1),
0411   Coplanar = 4;
0412 elseif (Coplanar == -1) && (NearCoplanar == -1),
0413   Coplanar = 5;
0414 end

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