From: MorellThomas Date: Sun, 1 Oct 2023 15:29:13 +0000 (+0200) Subject: Fix Reset Button for PaSiMap and issue with indelfreeAstr in AlignSeq X-Git-Tag: Release_2_11_4_0~31^2~33 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3a8bdc94ec8366d687d7693a7e71948878c05fa5;p=jalview.git Fix Reset Button for PaSiMap and issue with indelfreeAstr in AlignSeq --- diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index 7165096..fa90f74 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -517,7 +517,6 @@ public class AlignSeq seq1end = i + 1; seq2end = j + 1; - aseq1 = new int[seq1.length + seq2.length]; aseq2 = new int[seq1.length + seq2.length]; @@ -545,7 +544,6 @@ public class AlignSeq j--; } - while (i > 0 && j > 0) { aseq1[count] = seq1[i]; @@ -579,17 +577,10 @@ public class AlignSeq seq1start = i + 1; seq2start = j + 1; - if (aseq1[count] != GAP_INDEX) - { - aseq1[count] = seq1[i]; - sb1.append(s1str.charAt(i)); - } - - if (aseq2[count] != GAP_INDEX) - { - aseq2[count] = seq2[j]; - sb2.append(s2str.charAt(j)); - } + aseq1[count] = seq1[i]; + sb1.append(s1str.charAt(i)); + aseq2[count] = seq2[j]; + sb2.append(s2str.charAt(j)); //get initial gaps while (j > 0 || i > 0) @@ -1304,7 +1295,6 @@ public class AlignSeq */ public void meanScore() { - //int length = (indelfreeAstr1.length() > indelfreeAstr2.length()) ? indelfreeAstr1.length() : indelfreeAstr2.length(); int length = indelfreeAstr1.length(); //both have the same length //create HashMap for counting residues in each sequence HashMap seq1ResCount = new HashMap(); @@ -1392,7 +1382,7 @@ public class AlignSeq * if preprescore < 1 ~ alignmentScore = Float.NaN > * alignmentScore = ((preprescore - meanScore) / (hypotheticMaxScore - meanScore)) * coverage */ - public void scoreAlignment() throws RuntimeException + public void scoreAlignment() { getIndelfreeAstr(); @@ -1401,9 +1391,9 @@ public class AlignSeq // cannot calculate score because denominator would be zero if (this.hypotheticMaxScore == this.meanScore) { - throw new IllegalArgumentException(String.format("hypotheticMaxScore (%8.2f) == meanScore (%8.2f) - division by 0", hypotheticMaxScore, meanScore)); + this.alignmentScore = Float.NaN; + return; } - //int n = (astr1.length() > astr2.length()) ? astr1.length() : astr2.length(); int n = indelfreeAstr1.length(); float score = 0; @@ -1436,7 +1426,7 @@ public class AlignSeq float prescore = score; // only debug score *= coverage; - System.out.println(String.format("prepre-score: %f, pre-score: %f, longlength: %d\nscore: %1.16f, mean: %f, max: %d", preprescore, prescore, _max[1], score, this.meanScore, this.hypotheticMaxScore)); + //System.out.println(String.format("prepre-score: %f, pre-score: %f, longlength: %d\nscore: %1.16f, mean: %f, max: %d", preprescore, prescore, _max[1], score, this.meanScore, this.hypotheticMaxScore)); float minScore = 1f; this.alignmentScore = (preprescore < minScore) ? Float.NaN : score; } diff --git a/src/jalview/viewmodel/PaSiMapModel.java b/src/jalview/viewmodel/PaSiMapModel.java index 4bb6d8a..4cc831a 100644 --- a/src/jalview/viewmodel/PaSiMapModel.java +++ b/src/jalview/viewmodel/PaSiMapModel.java @@ -99,12 +99,12 @@ public class PaSiMapModel int width = pasimap.getWidth(); int height = pasimap.getHeight(); - top = height; + top = width; points = new Vector<>(); Point[] scores = pasimap.getComponents(width - 1, width - 2, width - 3, 1); - for (int i = 0; i < top; i++) + for (int i = 0; i < height; i++) { SequencePoint sp = new SequencePoint(seqs[i], scores[i]); points.add(sp); @@ -156,7 +156,7 @@ public class PaSiMapModel // note: actual indices for components are dim1-1, etc (patch for JAL-1123) Point[] scores = pasimap.getComponents(dim1 - 1, dim2 - 1, dim3 - 1, 1); - for (int i = 0; i < pasimap.getWidth(); i++) + for (int i = 0; i < pasimap.getHeight(); i++) { points.get(i).coord = scores[i]; }