Changeset 1592 for branches/ralph/src
- Timestamp:
- 07/09/14 22:49:39 (10 years ago)
- Location:
- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithm.java
r1587 r1592 16 16 public abstract void printAlignment(); 17 17 18 public abstract ArrayList<ArrayList<NumberSequence>> getMatches(); 19 18 20 } -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NeedlemanWunsch.java
r1588 r1592 283 283 } 284 284 285 @Override 286 public ArrayList<ArrayList<NumberSequence>> getMatches() { 287 // TODO Auto-generated method stub 288 return null; 289 } 290 285 291 286 292 -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequence.java
r1580 r1592 49 49 } 50 50 51 public int size() { 52 return sequence.length; 53 } 51 54 } -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWaterman.java
r1587 r1592 288 288 } 289 289 290 @Override 291 public ArrayList<ArrayList<NumberSequence>> getMatches() { 292 // TODO Auto-generated method stub 293 return null; 294 } 295 290 296 } -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java
r1589 r1592 93 93 matrix[0][0].setScore(0); 94 94 matrix[0][0].setPrevious(null); // starting point 95 matrix[0][0].setXvalue(Constants.UNMATCHED_SYMBOL); 96 matrix[0][0].setYvalue(Constants.UNMATCHED_SYMBOL); 95 97 96 98 // the first column … … 132 134 tempMax -= scoreThreshold; 133 135 matrix[i][0].setScore(Math.max(firstRowLeftScore, tempMax)); 134 if(tempMax == matrix[i][0].getScore()){136 if(tempMax == matrix[i][0].getScore()){ 135 137 matrix[i][0].setPrevious(matrix[i-1][maxRowIndex]); 136 138 } … … 222 224 LinkedList<Integer> aligned1 = new LinkedList<Integer>(); 223 225 LinkedList<Integer> aligned2 = new LinkedList<Integer>(); 224 do{226 while (tmp.getPrevious() != null) { 225 227 226 228 aligned1.add(new Integer(tmp.getXvalue())); … … 228 230 229 231 tmp = tmp.getPrevious(); 230 231 } while (tmp != null); 232 } 232 233 233 234 // reverse order of the alignment … … 296 297 count++; 297 298 298 } while(tmp != null);299 } while(tmp.getPrevious() != null); 299 300 System.out.println(aligned1); 300 301 System.out.println(aligned2); 301 302 } 302 303 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 } 304 347 305 348 /** -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/PairwiseAlignmentGenerator.java
r1589 r1592 2 2 3 3 import java.util.ArrayList; 4 import java.util.Iterator; 4 5 5 6 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.AlignmentAlgorithm; … … 38 39 if(score > 0) { 39 40 System.out.println(); 40 alignments.get(i, j).printAlignment(); 41 //alignments.get(i, j).printAlignment(); 42 ArrayList<ArrayList<NumberSequence>> matches = alignments.get(i, j).getMatches(); 43 for(Iterator<ArrayList<NumberSequence>> it = matches.iterator();it.hasNext();) { 44 ArrayList<NumberSequence> tmp = it.next(); 45 tmp.get(0).printSequence(); 46 tmp.get(1).printSequence(); 47 } 41 48 System.out.println(); 42 49 }
Note: See TracChangeset
for help on using the changeset viewer.