HP_newrepairing: An auxiliary function that modifies a sequence configuration to avoid self-intersections It is called recursively INPUTS sizeChain: Size of the subchain inspected Pos: Configuration of the sequence being repaired pos: position in the sequence being inspected moves: set of allowed moves in random order s: Sequence of residues repaire vector: original sequence OUTPUTS solutionFound: whether the solution was repaired s: Sequence of residues repaired (without self-intersections) Pos: Final configuration of the sequence Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
0001 function[solutionFound,s,Pos] = HP_newrepairing(sizeChain,Pos,pos,moves,s,vector) 0002 % HP_newrepairing: An auxiliary function that modifies a sequence configuration to avoid self-intersections 0003 % It is called recursively 0004 % INPUTS 0005 % sizeChain: Size of the subchain inspected 0006 % Pos: Configuration of the sequence being repaired 0007 % pos: position in the sequence being inspected 0008 % moves: set of allowed moves in random order 0009 % s: Sequence of residues repaire 0010 % vector: original sequence 0011 % OUTPUTS 0012 % solutionFound: whether the solution was repaired 0013 % s: Sequence of residues repaired (without self-intersections) 0014 % Pos: Final configuration of the sequence 0015 % 0016 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es) 0017 0018 global HPInitConf; 0019 0020 0021 if (NewFeasible(s,pos-1,Pos)==1 ) 0022 if (size(s,2) == sizeChain) 0023 solutionFound = 1; 0024 else 0025 solutionFound = 0; 0026 i = 1; 0027 while (solutionFound==0 & i<=4) 0028 if(i==1 || moves(pos,i) ~= vector(pos)) 0029 new_s = [s,moves(pos,i)]; 0030 [Pos] = PutMoveAtPos(Pos,pos,moves(pos,i)); 0031 [solutionFound,new_s,Pos] = HP_newrepairing(sizeChain,Pos,pos+1,moves,new_s,vector); 0032 end 0033 i = i + 1; 0034 if (solutionFound==1) 0035 s = new_s; 0036 end 0037 end 0038 end 0039 else 0040 solutionFound = 0; 0041 end 0042 0043 0044 % Last version 10/09/2005. Roberto Santana (rsantana@si.ehu.es)