Changeset 1587


Ignore:
Timestamp:
07/04/14 00:38:41 (10 years ago)
Author:
rkrimmel
Message:

Adding needleman wunsch

Location:
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees
Files:
1 added
7 edited

Legend:

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

    r1586 r1587  
    1212        public abstract ArrayList<NumberSequence> getAlignment(); 
    1313 
     14        public abstract void printDPMatrix(); 
     15 
     16        public abstract void printAlignment(); 
     17 
    1418} 
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithmFactory.java

    r1586 r1587  
    88        public static AlignmentAlgorithm create(int[] input1, int[] input2, SubstitutionMatrix submat,float threshold) { 
    99                 
    10                 return new SmithWaterman(input1,input2,submat,threshold); 
     10                //return new NeedlemanWunsch(input1,input2,submat,threshold); 
     11                return new NeedlemanWunsch(input1,input2,submat,threshold); 
     12                //return new SmithWatermanRepeated(input1,input2,submat,threshold); 
    1113        } 
    1214} 
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWaterman.java

    r1586 r1587  
    3232 
    3333        private ArrayList<NumberSequence> alignment; 
    34  
    35         private float scoreThreshold; 
    3634 
    3735        /** 
     
    5149                // + submat.getClass() + " Substitution Matrix: " + 
    5250                // submat.getClass().getCanonicalName()); 
    53                 this.scoreThreshold = threshold; 
    5451 
    5552                matrix = new MatrixEntry[length1 + 1][length2 + 1]; 
     
    9390 
    9491                // the first column 
    95                 for (int j = 1; j < length2+1; j++) { 
     92                for (int j = 1; j < length2; j++) { 
    9693                        matrix[0][j].setScore(0); 
    9794                        matrix[0][j].setPrevious(matrix[0][j - 1]); 
     
    10198                // the first row 
    10299 
    103                 for (int j = 1; j < length1+1; j++) { 
     100                for (int j = 1; j < length1; j++) { 
    104101                        matrix[j][0].setScore(0); 
    105102                        matrix[j][0].setPrevious(matrix[j - 1][0]); 
     
    262259                        System.out.format("%5d", input1[i - 1]); 
    263260                System.out.println(); 
    264                 for (int j = 0; j < length2; j++) { 
     261                for (int j = 0; j <= length2; j++) { 
    265262                        if (j > 0) 
    266263                                System.out.format("%5d ", input2[j - 1]); 
     
    268265                                System.out.print("      "); 
    269266                        } 
    270                         for (int i = 0; i < length1; i++) { 
     267                        for (int i = 0; i <= length1; i++) { 
    271268                                        System.out.format("%4.1f ", matrix[i][j].getScore()); 
    272269                        } 
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java

    r1586 r1587  
    102102                 
    103103                 
    104                 for (int i = 1; i <= length1 + 1; i++) { 
     104                for (int i = 1; i < length1 + 2; i++) { 
    105105                 
    106106                        // Formula for first row: 
     
    220220        public void traceback() { 
    221221                MatrixEntry tmp = matrix[length1+1][0]; 
    222                 int aligned1[] = new int[length1+length2+2]; 
    223                 int aligned2[] = new int[length1+length2+2]; 
     222                int aligned1[] = new int[length1+1+length2+2]; 
     223                int aligned2[] = new int[length1+1+length2+2]; 
    224224                int count = 0; 
    225225                do 
     
    227227                        if(count != 0) 
    228228                        { 
    229                                 if (length1+length2+2 == count) {        
     229                                if (length1+1+length2+2 == count) {      
    230230                                        Console.traceln(Level.WARNING, "Traceback longer than both sequences summed up!"); 
    231231                                        break; 
     
    312312                        System.out.format("%5d", input1[i - 1]); 
    313313                System.out.println(); 
    314                 for (int j = 0; j < length2; j++) { 
     314                for (int j = 0; j <= length2; j++) { 
    315315                        if (j > 0) 
    316316                                System.out.format("%5d ",input2[j - 1]); 
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/ObjectDistanceSubstitionMatrix.java

    r1585 r1587  
    2929                idmapping = new HashMap<Integer, Integer>(); 
    3030                matrix = new TriangleMatrix(uniqueTasks.size()+1); 
    31                 gapPenalty = -3; 
     31                gapPenalty = -2; 
    3232                 
    3333        } 
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/UPGMAAligningTree.java

    r1586 r1587  
    137137        private void finish() 
    138138        { 
     139                this.getRoot().setSequences(alignSequences(this.getRoot())); 
    139140                distance = null;                 
    140141        } 
     
    215216                        int seqCount1 = node1.getSequences().size(); 
    216217                        int seqCount2 = node2.getSequences().size(); 
     218                         
     219                        for(int i = 0; i < seqCount1; i++) { 
     220                                for(int j = 0; j < seqCount2; j++) { 
     221                                        node1.getSequence(i).printSequence(); 
     222                                        node2.getSequence(j).printSequence(); 
     223                                } 
     224                        } 
     225                         
    217226                        Console.traceln(Level.INFO,"Merging node " + node1.getIdentifier() + " with " + node2.getIdentifier()); 
    218227                        //Console.println("SeqCount1: " + seqCount1 + " seqCount2 " + seqCount2); 
     
    220229                        if(seqCount1 == 1 && seqCount2 == 1) { 
    221230                                alignment = (alignments.get(node1.getNumber(), node2.getNumber())).getAlignment(); 
     231                                 
    222232                        } 
    223233                        //Align a sequence to a group 
     
    236246                                } 
    237247                                //if(maxScore > 0) 
     248                                 
    238249                                alignment.add(tempStorage.get(maxIndex, 1).getAlignment().get(1)); 
    239250                        } 
     
    252263                                } 
    253264                                //if(maxScore > 0) 
     265                                 
    254266                                alignment.add(tempStorage.get(1,maxIndex).getAlignment().get(1)); 
    255267                        } 
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java

    r1586 r1587  
    208208                        } 
    209209                } 
    210                 //System.out.println(sequenceDistances.toString()); 
     210                //alignments.get(20, 47).printDPMatrix(); 
     211                //alignments.get(20, 47).printAlignment(); 
     212                 
     213                System.out.println(alignments.getDistanceMatrix().toString()); 
    211214                UPGMAAligningTree guidetree = new UPGMAAligningTree(numberseqs, alignments,submat); 
    212  
    213                 for (Iterator<NumberSequence> it =  guidetree.getRoot().getChild(0).getSequences().iterator(); it.hasNext();) { 
     215                //System.out.println("Number of sequences in root node: " + guidetree.getRoot().getSequences().size()); 
     216                for (Iterator<NumberSequence> it =  guidetree.getRoot().getSequences().iterator(); it.hasNext();) { 
    214217                        NumberSequence tmp  = it.next(); 
    215218                        tmp.printSequence(); 
    216219                } 
     220                 
    217221         
    218222                /* 
Note: See TracChangeset for help on using the changeset viewer.