Changeset 1574


Ignore:
Timestamp:
06/23/14 08:38:03 (10 years ago)
Author:
rkrimmel
Message:

Improvements to smith waterman

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java

    r1572 r1574  
    6363 
    6464                buildMatrix(); 
     65                traceback(); 
    6566        } 
    6667 
     
    216217         
    217218         
    218         private int[] traceback(int i, int j) { 
    219                  
    220                          
    221                 return null; 
    222         } 
    223          
    224          
    225219        public void traceback() { 
    226220                MatrixEntry tmp = matrix[length1+1][0]; 
    227                  
    228                 int aligned1[] = new int[length1+length2]; 
    229                 int aligned2[] = new int[length1+length2]; 
     221                //TODO: Why do we need such long arrays, also, add a check if we reach the limit? 
     222                int aligned1[] = new int[2*length1+2*length2]; 
     223                int aligned2[] = new int[2*length1+2*length2]; 
     224                System.out.println("Aligned length: " + aligned1.length); 
    230225                int count = 0; 
    231226                do 
     
    239234                        tmp = tmp.getPrevious(); 
    240235                        count++; 
     236                        System.out.println(count); 
    241237                         
    242238                } while(tmp != null); 
     
    246242                int reversed2[] = new int[count]; 
    247243                 
    248                 for(int i = count; count > 0; count ++) { 
    249                          
     244                 
     245                for(int i = count-1; i > 0; i--) { 
     246                        reversed1[reversed1.length-i]= aligned1[i]; 
     247                        reversed2[reversed2.length-i]= aligned2[i]; 
    250248                } 
    251249                 
     
    328326        } 
    329327 
    330         /** 
    331          * Return a set of Matches identified in Dynamic programming matrix. A match 
    332          * is a pair of subsequences whose score is higher than the preset 
    333          * scoreThreshold 
    334          **/ 
    335         public List<Match> getMatches() { 
    336                 ArrayList<Match> matchList = new ArrayList(); 
    337                 int fA = 0, fB = 0; 
    338                 // skip the first row and column, find the next maxScore after 
    339                 // prevmaxScore 
    340                 for (int i = 1; i <= length1; i++) { 
    341                         for (int j = 1; j <= length2; j++) { 
    342                                 if (matrix[i][j].getScore() > scoreThreshold 
    343                                                 && matrix[i][j].getScore() > matrix[i - 1][j - 1].getScore() 
    344                                                 && matrix[i][j].getScore() > matrix[i - 1][j].getScore() 
    345                                                 && matrix[i][j].getScore() > matrix[i][j - 1].getScore()) { 
    346                                         if (i == length1 || j == length2 
    347                                                         || matrix[i][j].getScore() > matrix[i + 1][j + 1].getScore()) { 
    348                                                 // should be lesser than prev maxScore 
    349                                                 fA = i; 
    350                                                 fB = j; 
    351                                                 int[] f = traceback(fA, fB); // sets the x, y to 
    352                                                                                                                 // startAlignment 
    353                                                                                                                 // coordinates 
    354                                                 System.out.println(f[0] + " " + i + " " + f[1] + " " 
    355                                                                 + j + " " + matrix[i][j].getScore()); 
    356                                                 // TODO Add matches to matchList 
    357                                         } 
    358                                 } 
    359                         } 
    360                 } 
    361                 return matchList; 
    362         } 
    363          
    364328 
    365329        public List<NumberSequence> getAlignment() { 
Note: See TracChangeset for help on using the changeset viewer.