Ignore:
Timestamp:
07/14/14 23:27:01 (10 years ago)
Author:
rkrimmel
Message:

Removed parameters from alignmentalgorihm factory constructor and changed interface by adding a new align() method, which now gets all the data via parameter

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  
    33import java.util.ArrayList; 
    44 
     5import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.SubstitutionMatrix; 
     6 
    57public interface AlignmentAlgorithm { 
    68 
     9        public abstract void align(int[] input1, int[] input2, SubstitutionMatrix submat,float threshold); 
     10         
    711        /** 
    812         * 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  
    11package de.ugoe.cs.autoquest.tasktrees.alignment.algorithms; 
     2 
     3import java.lang.reflect.Constructor; 
     4import java.lang.reflect.InvocationTargetException; 
    25 
    36import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.SubstitutionMatrix; 
     
    58public class AlignmentAlgorithmFactory { 
    69         
     10        public static void setDefaultAlgorithm(String algorithmname) { 
     11                //TODO: check for valid algorihm class names here 
     12                algorithmclass = algorithmname; 
     13        } 
    714         
    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                } 
    1030                //return new SmithWaterman(input1,input2,submat,threshold); 
    1131                //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; 
    1334        } 
    1435} 
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NeedlemanWunsch.java

    r1592 r1612  
    3939        private SubstitutionMatrix submat; 
    4040 
    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         } 
    6541 
    6642        /** 
     
    289265        } 
    290266 
     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 
    291294 
    292295 
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWaterman.java

    r1592 r1612  
    3838        private SubstitutionMatrix submat; 
    3939 
    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         } 
    6440 
    6541        /** 
     
    294270        } 
    295271 
     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 
    296299} 
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java

    r1596 r1612  
    4343        private SubstitutionMatrix submat; 
    4444 
    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         
    6847        } 
    6948 
     
    374353        } 
    375354 
     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 
    376382} 
Note: See TracChangeset for help on using the changeset viewer.