Ignore:
Timestamp:
07/09/14 22:49:39 (10 years ago)
Author:
rkrimmel
Message:

Trying new approach

File:
1 edited

Legend:

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

    r1589 r1592  
    9393                matrix[0][0].setScore(0); 
    9494                matrix[0][0].setPrevious(null); // starting point 
     95                matrix[0][0].setXvalue(Constants.UNMATCHED_SYMBOL); 
     96                matrix[0][0].setYvalue(Constants.UNMATCHED_SYMBOL); 
    9597 
    9698                // the first column 
     
    132134                        tempMax -= scoreThreshold; 
    133135                        matrix[i][0].setScore(Math.max(firstRowLeftScore, tempMax)); 
    134                         if(tempMax ==matrix[i][0].getScore()){ 
     136                        if(tempMax == matrix[i][0].getScore()){ 
    135137                                matrix[i][0].setPrevious(matrix[i-1][maxRowIndex]); 
    136138                        } 
     
    222224                LinkedList<Integer> aligned1 = new LinkedList<Integer>(); 
    223225                LinkedList<Integer> aligned2 = new LinkedList<Integer>(); 
    224                 do { 
     226                while (tmp.getPrevious() != null) { 
    225227                         
    226228                        aligned1.add(new Integer(tmp.getXvalue())); 
     
    228230 
    229231                        tmp = tmp.getPrevious(); 
    230  
    231                 } while (tmp != null); 
     232                }  
    232233                 
    233234                // reverse order of the alignment 
     
    296297                        count++; 
    297298                         
    298                 } while(tmp != null); 
     299                } while(tmp.getPrevious() != null); 
    299300                System.out.println(aligned1); 
    300301                System.out.println(aligned2); 
    301302        } 
    302303         
    303  
     304        public ArrayList<ArrayList<NumberSequence>> getMatches() { 
     305                ArrayList<ArrayList<NumberSequence>> result = new ArrayList<ArrayList<NumberSequence>>(); 
     306                 
     307                //both alignment sequences should be equally long 
     308                int i = 0; 
     309                int[] seq1 = alignment.get(0).getSequence(); 
     310                int[] seq2 = alignment.get(1).getSequence(); 
     311                int start = 0; 
     312                while (i < seq1.length){ 
     313                        if(seq2[i] != Constants.UNMATCHED_SYMBOL) { 
     314                                start = i; 
     315                                int count = 0; 
     316                                while(i < seq2.length && seq2[i] != Constants.UNMATCHED_SYMBOL) { 
     317                                        i++; 
     318                                        count++; 
     319                                } 
     320                                //I am really missing memcpy here  
     321                                int[] tmp1 = new int[count]; 
     322                                int[] tmp2 = new int[count]; 
     323                                for (int j = 0; j<count;j++) { 
     324                                        tmp1[j] = seq1[start+j]; 
     325                                        tmp2[j] = seq2[start+j]; 
     326                                } 
     327                                NumberSequence tmpns1 = new NumberSequence(count); 
     328                                NumberSequence tmpns2 = new NumberSequence(count); 
     329                                tmpns1.setSequence(tmp1); 
     330                                tmpns2.setSequence(tmp2); 
     331                                ArrayList<NumberSequence> tmpal = new ArrayList<NumberSequence>(); 
     332                                tmpal.add(tmpns1); 
     333                                tmpal.add(tmpns2); 
     334                                result.add(tmpal); 
     335                        } 
     336                        i++; 
     337                } 
     338                 
     339                 
     340                 
     341                 
     342                 
     343                 
     344                return result; 
     345                 
     346        } 
    304347         
    305348        /** 
Note: See TracChangeset for help on using the changeset viewer.