Changeset 1575


Ignore:
Timestamp:
06/25/14 16:12:05 (10 years ago)
Author:
rkrimmel
Message:

Fixed wrong initialization of the first column in dynamic programming matrix.

File:
1 edited

Legend:

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

    r1574 r1575  
    55import java.util.LinkedList; 
    66import java.util.List; 
     7import java.util.logging.Level; 
    78 
    89import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.SubstitutionMatrix; 
     10import de.ugoe.cs.util.console.Console; 
    911 
    1012public class SmithWatermanRepeated { 
     
    9597                for (int j = 1; j < length2; j++) { 
    9698                        matrix[0][j].setScore(0); 
    97                         matrix[0][j].setPrevious(matrix[0][j-1]); 
    98                          
     99                        //We don't need to go back to [0][0] if we reached matrix[0][x], so just end here 
     100                        //matrix[0][j].setPrevious(matrix[0][j-1]); 
     101                        matrix[0][j].setPrevious(null);  
    99102                } 
    100103                 
     
    219222        public void traceback() { 
    220223                MatrixEntry tmp = matrix[length1+1][0]; 
    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); 
     224                int aligned1[] = new int[length1+length2+2]; 
     225                int aligned2[] = new int[length1+length2+2]; 
    225226                int count = 0; 
    226227                do 
     
    234235                        tmp = tmp.getPrevious(); 
    235236                        count++; 
    236                         System.out.println(count); 
     237                if (length1+length2+2 == count) {        
     238                        Console.traceln(Level.WARNING, "Traceback longer than both sequences summed up!"); 
     239                        break; 
     240                } 
    237241                         
    238242                } while(tmp != null); 
    239  
    240                 //reverse order 
     243                count--; 
     244                //reverse order of the alignment 
    241245                int reversed1[] = new int[count]; 
    242246                int reversed2[] = new int[count]; 
Note: See TracChangeset for help on using the changeset viewer.