- Timestamp:
- 07/14/14 23:27:01 (10 years ago)
- Location:
- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithm.java
r1592 r1612 3 3 import java.util.ArrayList; 4 4 5 import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.SubstitutionMatrix; 6 5 7 public interface AlignmentAlgorithm { 6 8 9 public abstract void align(int[] input1, int[] input2, SubstitutionMatrix submat,float threshold); 10 7 11 /** 8 12 * Get the alignment score between the two input strings. -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithmFactory.java
r1589 r1612 1 1 package de.ugoe.cs.autoquest.tasktrees.alignment.algorithms; 2 3 import java.lang.reflect.Constructor; 4 import java.lang.reflect.InvocationTargetException; 2 5 3 6 import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.SubstitutionMatrix; … … 5 8 public class AlignmentAlgorithmFactory { 6 9 10 public static void setDefaultAlgorithm(String algorithmname) { 11 //TODO: check for valid algorihm class names here 12 algorithmclass = algorithmname; 13 } 7 14 8 public static AlignmentAlgorithm create(int[] input1, int[] input2, SubstitutionMatrix submat,float threshold) { 9 15 private static String algorithmclass = "de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.SmithWatermanRepeated"; 16 17 18 19 public static AlignmentAlgorithm create() { 20 Class<?> newclass; 21 Object object = null; 22 try { 23 newclass = Class.forName(algorithmclass); 24 object = newclass.newInstance(); 25 26 } catch (ClassNotFoundException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException e) { 27 // TODO Auto-generated catch block 28 e.printStackTrace(); 29 } 10 30 //return new SmithWaterman(input1,input2,submat,threshold); 11 31 //return new NeedlemanWunsch(input1,input2,submat,threshold); 12 return new SmithWatermanRepeated(input1,input2,submat,threshold); 32 //return new SmithWatermanRepeated(input1,input2,submat,threshold); 33 return (AlignmentAlgorithm) object; 13 34 } 14 35 } -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NeedlemanWunsch.java
r1592 r1612 39 39 private SubstitutionMatrix submat; 40 40 41 public NeedlemanWunsch(int[] input1, int[] input2, SubstitutionMatrix submat,42 float threshold) {43 this.input1 = input1;44 this.input2 = input2;45 length1 = input1.length;46 length2 = input2.length;47 this.submat = submat;48 49 // System.out.println("Starting SmithWaterman algorithm with a "50 // + submat.getClass() + " Substitution Matrix: " +51 // submat.getClass().getCanonicalName());52 53 matrix = new MatrixEntry[length1 + 1][length2 + 1];54 alignment = new ArrayList<NumberSequence>();55 56 for (int i = 0; i < length1+1; i++) {57 for (int j = 0; j < length2+1; j++) {58 matrix[i][j] = new MatrixEntry();59 }60 }61 62 buildMatrix();63 traceback();64 }65 41 66 42 /** … … 289 265 } 290 266 267 @Override 268 public void align(int[] input1, int[] input2, SubstitutionMatrix submat, 269 float threshold) { 270 this.input1 = input1; 271 this.input2 = input2; 272 length1 = input1.length; 273 length2 = input2.length; 274 this.submat = submat; 275 276 // System.out.println("Starting SmithWaterman algorithm with a " 277 // + submat.getClass() + " Substitution Matrix: " + 278 // submat.getClass().getCanonicalName()); 279 280 matrix = new MatrixEntry[length1 + 1][length2 + 1]; 281 alignment = new ArrayList<NumberSequence>(); 282 283 for (int i = 0; i < length1+1; i++) { 284 for (int j = 0; j < length2+1; j++) { 285 matrix[i][j] = new MatrixEntry(); 286 } 287 } 288 289 buildMatrix(); 290 traceback(); 291 292 } 293 291 294 292 295 -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWaterman.java
r1592 r1612 38 38 private SubstitutionMatrix submat; 39 39 40 public SmithWaterman(int[] input1, int[] input2, SubstitutionMatrix submat,41 float threshold) {42 this.input1 = input1;43 this.input2 = input2;44 length1 = input1.length;45 length2 = input2.length;46 this.submat = submat;47 48 // System.out.println("Starting SmithWaterman algorithm with a "49 // + submat.getClass() + " Substitution Matrix: " +50 // submat.getClass().getCanonicalName());51 52 matrix = new MatrixEntry[length1 + 1][length2 + 1];53 alignment = new ArrayList<NumberSequence>();54 55 for (int i = 0; i < length1+1; i++) {56 for (int j = 0; j < length2+1; j++) {57 matrix[i][j] = new MatrixEntry();58 }59 }60 61 buildMatrix();62 traceback();63 }64 40 65 41 /** … … 294 270 } 295 271 272 @Override 273 public void align(int[] input1, int[] input2, SubstitutionMatrix submat, 274 float threshold) { 275 this.input1 = input1; 276 this.input2 = input2; 277 length1 = input1.length; 278 length2 = input2.length; 279 this.submat = submat; 280 281 // System.out.println("Starting SmithWaterman algorithm with a " 282 // + submat.getClass() + " Substitution Matrix: " + 283 // submat.getClass().getCanonicalName()); 284 285 matrix = new MatrixEntry[length1 + 1][length2 + 1]; 286 alignment = new ArrayList<NumberSequence>(); 287 288 for (int i = 0; i < length1+1; i++) { 289 for (int j = 0; j < length2+1; j++) { 290 matrix[i][j] = new MatrixEntry(); 291 } 292 } 293 294 buildMatrix(); 295 traceback(); 296 297 } 298 296 299 } -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java
r1596 r1612 43 43 private SubstitutionMatrix submat; 44 44 45 public SmithWatermanRepeated(int[] input1, int[] input2, SubstitutionMatrix submat,float threshold) { 46 this.input1 = input1; 47 this.input2 = input2; 48 length1 = input1.length; 49 length2 = input2.length; 50 this.submat = submat; 51 52 //System.out.println("Starting SmithWaterman algorithm with a " 53 // + submat.getClass() + " Substitution Matrix: " + submat.getClass().getCanonicalName()); 54 this.scoreThreshold = threshold; 55 56 matrix = new MatrixEntry[length1+2][length2+1]; 57 alignment = new ArrayList<NumberSequence>(); 58 59 for (int i = 0; i <= length1+1; i++) { 60 for(int j = 0; j< length2; j++) { 61 matrix[i][j] = new MatrixEntry(); 62 } 63 } 64 65 66 buildMatrix(); 67 traceback(); 45 public SmithWatermanRepeated() { 46 68 47 } 69 48 … … 374 353 } 375 354 355 @Override 356 public void align(int[] input1, int[] input2, SubstitutionMatrix submat, 357 float threshold) { 358 this.input1 = input1; 359 this.input2 = input2; 360 length1 = input1.length; 361 length2 = input2.length; 362 this.submat = submat; 363 364 //System.out.println("Starting SmithWaterman algorithm with a " 365 // + submat.getClass() + " Substitution Matrix: " + submat.getClass().getCanonicalName()); 366 this.scoreThreshold = threshold; 367 368 matrix = new MatrixEntry[length1+2][length2+1]; 369 alignment = new ArrayList<NumberSequence>(); 370 371 for (int i = 0; i <= length1+1; i++) { 372 for(int j = 0; j< length2; j++) { 373 matrix[i][j] = new MatrixEntry(); 374 } 375 } 376 377 378 buildMatrix(); 379 traceback(); 380 } 381 376 382 }
Note: See TracChangeset
for help on using the changeset viewer.