Changeset 1584
- Timestamp:
- 06/27/14 15:25:25 (11 years ago)
- Location:
- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/BinaryAlignmentStorage.java
r1582 r1584 1 1 package de.ugoe.cs.autoquest.tasktrees.alignment.matrix; 2 3 4 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.SmithWatermanRepeated; 2 5 3 6 public class BinaryAlignmentStorage { 4 7 8 private SmithWatermanRepeated[][] alignments; 9 UPGMAMatrix sequenceDistances; 10 11 public BinaryAlignmentStorage(int size) { 12 alignments = new SmithWatermanRepeated[size][size]; 13 sequenceDistances = new UPGMAMatrix(size); 14 sequenceDistances.initialize(Double.POSITIVE_INFINITY); 15 } 16 17 public void set(int i,int j,SmithWatermanRepeated sw) { 18 alignments[i][j] = sw; 19 } 20 21 public SmithWatermanRepeated get(int i,int j) { 22 return alignments[i][j]; 23 } 24 25 public void setDistance(int i,int j,double distance) { 26 sequenceDistances.set(i, j, distance); 27 } 28 29 public double getDistance(int i,int j) { 30 return sequenceDistances.get(i,j); 31 } 32 33 public UPGMAMatrix getDistanceMatrix() { 34 return sequenceDistances; 35 } 5 36 } 37 -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/UPGMAAligningTree.java
r1579 r1584 17 17 18 18 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.NumberSequence; 19 import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.BinaryAlignmentStorage; 19 20 import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.UPGMAMatrix; 20 21 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc.Identifier; … … 41 42 * @param m distance matrix 42 43 */ 43 public UPGMAAligningTree(ArrayList<NumberSequence> numberseqs, UPGMAMatrix m)44 { 45 if ( m.size() < 2)44 public UPGMAAligningTree(ArrayList<NumberSequence> numberseqs, BinaryAlignmentStorage alignments) 45 { 46 if (alignments.getDistanceMatrix().size() < 2) 46 47 { 47 48 new IllegalArgumentException("LESS THAN 2 TAXA IN DISTANCE MATRIX"); … … 49 50 50 51 this.numberseqs = numberseqs; 51 init(m); 52 this.alignments = alignments; 53 init(alignments.getDistanceMatrix()); 52 54 53 55 while (true) … … 73 75 // 74 76 private ArrayList<NumberSequence> numberseqs; 77 private BinaryAlignmentStorage alignments; 75 78 private int numClusters; 76 79 private int besti, abi; -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java
r1583 r1584 26 26 import java.util.logging.Level; 27 27 28 29 28 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.NumberSequence; 30 29 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.SmithWatermanRepeated; 30 import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.BinaryAlignmentStorage; 31 31 import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.ObjectDistanceSubstitionMatrix; 32 32 import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.UPGMAMatrix; … … 158 158 submat.generate(); 159 159 160 UPGMAMatrix sequenceDistances = new UPGMAMatrix(numberseqs.size()); 161 sequenceDistances.initialize(Double.POSITIVE_INFINITY); 162 163 //Save the alignments so we do not need to recalculate those when aligning them again in feng doolittle algorithm 164 SmithWatermanRepeated[][] alignments = new SmithWatermanRepeated[numberseqs.size()][numberseqs.size()]; 160 161 BinaryAlignmentStorage alignments = new BinaryAlignmentStorage(numberseqs.size()); 162 165 163 166 164 for (int i = 0; i < numberseqs.size(); i++) { … … 172 170 int smithWatermanThreshold = 10; 173 171 174 alignments [i][j] =new SmithWatermanRepeated(172 alignments.set(i, j,new SmithWatermanRepeated( 175 173 ns1.getSequence(), ns2.getSequence(), submat, 176 smithWatermanThreshold) ;174 smithWatermanThreshold)); 177 175 SmithWatermanRepeated sameSequence1 = new SmithWatermanRepeated( 178 176 ns1.getSequence(), ns1.getSequence(), submat, … … 185 183 186 184 // Score of the aligmnment 187 double score = alignments [i][j].getAlignmentScore();185 double score = alignments.get(i,j).getAlignmentScore(); 188 186 // Scores of the sequence being aligned to itself (maximum score) 189 187 double sSelf1 = sameSequence1.getAlignmentScore(); … … 201 199 202 200 if(!Double.isInfinite(distance) && !Double.isNaN(distance)) { 203 if(distance < sequenceDistances.get(i, j)) {204 sequenceDistances.set(i,j,distance );201 if(distance < alignments.getDistance(i, j)) { 202 alignments.setDistance(i,j,distance ); 205 203 } 206 204 } … … 209 207 } 210 208 //System.out.println(sequenceDistances.toString()); 211 UPGMAAligningTree guidetree = new UPGMAAligningTree(numberseqs, sequenceDistances);209 UPGMAAligningTree guidetree = new UPGMAAligningTree(numberseqs, alignments); 212 210 213 211
Note: See TracChangeset
for help on using the changeset viewer.