X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAlignSeq.java;h=6bf812c56187cfb2c8fffc22b3a5238a72d76df2;hb=567c2595554096f10feab130153f97286f3f7d80;hp=ceca6d6fcd207c2a468c1ccc6385ff3445eb08b8;hpb=69b6e688c0a87bffc1fc7ae970fa0f8cd2976007;p=jalview.git diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index ceca6d6..6bf812c 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -20,8 +20,10 @@ */ package jalview.analysis; +import jalview.analysis.scoremodels.PIDModel; import jalview.analysis.scoremodels.ScoreMatrix; import jalview.analysis.scoremodels.ScoreModels; +import jalview.analysis.scoremodels.SimilarityParams; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Mapping; @@ -110,16 +112,14 @@ public class AlignSeq int gapExtend = 20; - float[][] lookup; - - int gapIndex = 23; - StringBuffer output = new StringBuffer(); String type; // AlignSeq.PEP or AlignSeq.DNA private ScoreMatrix scoreModel; + private static final int GAP_INDEX = -1; + /** * Creates a new AlignSeq object. * @@ -320,10 +320,6 @@ public class AlignSeq return; } - seq1 = new int[s1str.length()]; - - seq2 = new int[s2str.length()]; - score = new float[s1str.length()][s2str.length()]; E = new float[s1str.length()][s2str.length()]; @@ -349,8 +345,6 @@ public class AlignSeq type = moleculeType; scoreModel = ScoreModels.getInstance().getDefaultModel( PEP.equals(type)); - lookup = scoreModel.getMatrix(); - gapIndex = scoreModel.getMatrixIndex(' '); } /** @@ -415,13 +409,13 @@ public class AlignSeq else if (trace == 1) { j--; - aseq1[count] = gapIndex; + aseq1[count] = GAP_INDEX; sb1.replace(sb1.length() - 1, sb1.length(), "-"); } else if (trace == -1) { i--; - aseq2[count] = gapIndex; + aseq2[count] = GAP_INDEX; sb2.replace(sb2.length() - 1, sb2.length(), "-"); } @@ -431,13 +425,13 @@ public class AlignSeq seq1start = i + 1; seq2start = j + 1; - if (aseq1[count] != gapIndex) + if (aseq1[count] != GAP_INDEX) { aseq1[count] = seq1[i]; sb1.append(s1str.charAt(i)); } - if (aseq2[count] != gapIndex) + if (aseq2[count] != GAP_INDEX) { aseq2[count] = seq2[j]; sb2.append(s2str.charAt(j)); @@ -594,7 +588,10 @@ public class AlignSeq public int findTrace(int i, int j) { int t = 0; - float max = score[i - 1][j - 1] + (lookup[seq1[i]][seq2[j]] * 10); + // float pairwiseScore = lookup[seq1[i]][seq2[j]]; + float pairwiseScore = scoreModel.getPairwiseScore(s1str.charAt(i), + s2str.charAt(j)); + float max = score[i - 1][j - 1] + (pairwiseScore * 10); if (F[i][j] > max) { @@ -638,7 +635,8 @@ public class AlignSeq int m = seq2.length; // top left hand element - score[0][0] = lookup[seq1[0]][seq2[0]] * 10; + score[0][0] = scoreModel.getPairwiseScore(s1str.charAt(0), + s2str.charAt(0)) * 10; E[0][0] = -gapExtend; F[0][0] = 0; @@ -649,7 +647,9 @@ public class AlignSeq E[0][j] = max(score[0][j - 1] - gapOpen, E[0][j - 1] - gapExtend); F[0][j] = -gapExtend; - score[0][j] = max(lookup[seq1[0]][seq2[j]] * 10, -gapOpen, -gapExtend); + float pairwiseScore = scoreModel.getPairwiseScore(s1str.charAt(0), + s2str.charAt(j)); + score[0][j] = max(pairwiseScore * 10, -gapOpen, -gapExtend); traceback[0][j] = 1; } @@ -660,7 +660,9 @@ public class AlignSeq E[i][0] = -gapOpen; F[i][0] = max(score[i - 1][0] - gapOpen, F[i - 1][0] - gapExtend); - score[i][0] = max(lookup[seq1[i]][seq2[0]] * 10, E[i][0], F[i][0]); + float pairwiseScore = scoreModel.getPairwiseScore(s1str.charAt(i), + s2str.charAt(0)); + score[i][0] = max(pairwiseScore * 10, E[i][0], F[i][0]); traceback[i][0] = -1; } @@ -672,8 +674,10 @@ public class AlignSeq E[i][j] = max(score[i][j - 1] - gapOpen, E[i][j - 1] - gapExtend); F[i][j] = max(score[i - 1][j] - gapOpen, F[i - 1][j] - gapExtend); + float pairwiseScore = scoreModel.getPairwiseScore(s1str.charAt(i), + s2str.charAt(j)); score[i][j] = max(score[i - 1][j - 1] - + (lookup[seq1[i]][seq2[j]] * 10), E[i][j], F[i][j]); + + (pairwiseScore * 10), E[i][j], F[i][j]); traceback[i][j] = findTrace(i, j); } } @@ -795,7 +799,7 @@ public class AlignSeq public static void displayMatrix(Graphics g, int[][] mat, int n, int m, int psize) { - // TODO method dosen't seem to be referenced anywhere delete?? + // TODO method doesn't seem to be referenced anywhere delete?? int max = -1000; int min = 1000; @@ -969,8 +973,8 @@ public class AlignSeq bestm = msq; } } - System.out.println("Best Score for " + (matches.size() + 1) + " :" - + bestscore); + // System.out.println("Best Score for " + (matches.size() + 1) + " :" + // + bestscore); matches.add(bestm); aligns.add(bestaseq); al.deleteSequence(bestm); @@ -1059,6 +1063,8 @@ public class AlignSeq // long start = System.currentTimeMillis(); + SimilarityParams pidParams = new SimilarityParams(true, true, true, + true); float pid; String seqi, seqj; for (int i = 0; i < height; i++) @@ -1099,7 +1105,7 @@ public class AlignSeq seqj = ug; } } - pid = Comparison.PID(seqi, seqj); + pid = (float) PIDModel.computePID(seqi, seqj, pidParams); // use real sequence length rather than string length if (lngth[j] < lngth[i])