From b430a2bf68f36fe09aa488d219977c2e6e6259ea Mon Sep 17 00:00:00 2001 From: MorellThomas Date: Fri, 15 Mar 2024 07:54:42 +0100 Subject: [PATCH] Alogirthm working, but still giving slightly off results --- src/jalview/analysis/PaSiMap.java | 19 +++++++++++-------- src/jalview/gui/PairwiseAlignPanel.java | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/jalview/analysis/PaSiMap.java b/src/jalview/analysis/PaSiMap.java index 81d44f5..de89953 100755 --- a/src/jalview/analysis/PaSiMap.java +++ b/src/jalview/analysis/PaSiMap.java @@ -35,6 +35,7 @@ import jalview.viewmodel.AlignmentViewport; import java.io.PrintStream; +import java.util.ArrayList; import java.util.Hashtable; import java.util.HashMap; import java.util.HashSet; @@ -216,8 +217,8 @@ System.out.println(see.getName()); float[][] scores = new float[nSeqs][nSeqs]; // rows, cols int nSplits = 1; - //while ((nSeqs / nSplits) > 300) // heap full at 341 - while (((float) nSeqs / nSplits) > 5f) // heap full at 341 + while (((float) nSeqs / nSplits) > 300f) // heap full at 341 + //while (((float) nSeqs / nSplits) > 5f) // heap full at 341 nSplits++; int splitSeqs = (int) Math.ceil((float) nSeqs / nSplits); System.out.println(String.format("%d -> %d splits into %d seqs", nSeqs, nSplits, splitSeqs)); @@ -245,14 +246,13 @@ pairwiseScores.print(System.out, "%1.4f "); pairwiseScores = new Matrix(scores); pairwiseScores.print(System.out, "%1.4f "); -/* +*/ pairwiseScores.fillDiagonal(); eigenMatrix = pairwiseScores.copy(); ccAnalysis cc = new ccAnalysis(pairwiseScores, dim); eigenMatrix = cc.run(); -*/ } catch (Exception q) { @@ -288,7 +288,7 @@ pairwiseScores.print(System.out, "%1.4f "); int g = 0; // group count for (int[] group : allGroups) { - HashSet sg = new HashSet(); + ArrayList sg = new ArrayList(); //SequenceGroup sg = new SequenceGroup(); for (int index : group) { @@ -312,6 +312,7 @@ pairwiseScores.print(System.out, "%1.4f "); result.put(new int[]{s1 + g * s, s1 + g * s}, Float.NaN); // self score = Float.NaN for (int s2 = 0; s2 < s1; s2++) // col { +System.out.println(String.format("%s x %s -> [%d][%d] (%f)", sgArray[s1].getName(), sgArray[s2].getName(), s1+g*s, s2+g*s, scores[s1][s2])); result.put(new int[]{s1 + g * s, s2 + g * s}, scores[s1][s2]); } } @@ -340,16 +341,17 @@ pairwiseScores.print(System.out, "%1.4f "); // align each subsplit with subsplits from other split groups for (int subsplitN = 0; subsplitN < newGroups.length; subsplitN++) { - int c = 1; // current split block + int c = 1; // current subsplit block while (newGroups[subsplitN][0] > smallS * c) { c++; } for (int nextSplit = subsplitN + 1; nextSplit < newGroups.length; nextSplit++) { - if (newGroups[nextSplit][0] >= s * c) // if next subsplit of next split group -> align seqs +System.out.println(String.format("subsplitN %d, nextSplit %d, %d > %d * %d", subsplitN, nextSplit, allGroups[(int) Math.floor((float) nextSplit / 2)][0], smallS, c)); + if (allGroups[(int) Math.floor((float) nextSplit / 2)][0] > smallS * c) { - HashSet sg = new HashSet(); + ArrayList sg = new ArrayList(); //SequenceGroup sg = new SequenceGroup(); for (int index : newGroups[subsplitN]) { @@ -380,6 +382,7 @@ pairwiseScores.print(System.out, "%1.4f "); for (int s2 = 0; s2 < s1; s2++) // col { if (s1 >= smallS && s2 < smallS) +System.out.println(String.format("%s x %s -> [%d][%d] (%f)", sgArray[s1].getName(), sgArray[s2].getName(), s1+(nextSplit-1)*smallS, s2+subsplitN*smallS, scores[s1][s2])); result.put(new int[]{s1 + (nextSplit-1) * smallS, s2 + subsplitN * smallS}, scores[s1][s2]); } } diff --git a/src/jalview/gui/PairwiseAlignPanel.java b/src/jalview/gui/PairwiseAlignPanel.java index fc862fe..2379e27 100755 --- a/src/jalview/gui/PairwiseAlignPanel.java +++ b/src/jalview/gui/PairwiseAlignPanel.java @@ -139,6 +139,7 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel first = false; as.printAlignment(System.out); scores[i][j] = as.getMaxScore() / as.getASeq1().length; +System.out.println(String.format("%s x %s -> [%d][%d] (%f)", seqs[i].getName(), seqs[j].getName(), i, j, as.getAlignmentScore())); alignmentScores[i][j] = as.getAlignmentScore(); totscore = totscore + scores[i][j]; -- 1.7.10.2