X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPairwiseAlignPanel.java;h=e736a1103ecacb117c0c1814fd70f5b1f4a28547;hb=ff638b98db095ffd7dc792f5d91fe5a0de6fc2ba;hp=4aea4b1a08395f3fb078295415145ec3e6bad269;hpb=427421de47dacacac55ac29deca78e2f0a1c5408;p=jalview.git diff --git a/src/jalview/gui/PairwiseAlignPanel.java b/src/jalview/gui/PairwiseAlignPanel.java index 4aea4b1..e736a11 100755 --- a/src/jalview/gui/PairwiseAlignPanel.java +++ b/src/jalview/gui/PairwiseAlignPanel.java @@ -21,13 +21,13 @@ package jalview.gui; import jalview.analysis.AlignSeq; +import jalview.api.AlignViewportI; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentView; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.jbgui.GPairwiseAlignPanel; import jalview.util.MessageManager; -import jalview.viewmodel.AlignmentViewport; import java.awt.event.ActionEvent; import java.util.Vector; @@ -43,7 +43,7 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel private static final String DASHES = "---------------------\n"; - AlignmentViewport av; + AlignViewportI av; Vector sequences; @@ -51,14 +51,13 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel * Creates a new PairwiseAlignPanel object. * * @param viewport - * DOCUMENT ME! */ - public PairwiseAlignPanel(AlignmentViewport viewport) + public PairwiseAlignPanel(AlignViewportI viewport) { super(); this.av = viewport; - sequences = new Vector(); + sequences = new Vector<>(); SequenceGroup selectionGroup = viewport.getSelectionGroup(); boolean isSelection = selectionGroup != null @@ -83,7 +82,7 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel : AlignSeq.PEP; float[][] scores = new float[seqs.length][seqs.length]; - double totscore = 0; + double totscore = 0D; int count = seqs.length; boolean first = true; @@ -121,26 +120,53 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel if (count > 2) { - System.out.println( - "Pairwise alignment scaled similarity score matrix\n"); + printScoreMatrix(seqs, scores, totscore); + } + } - for (int i = 0; i < count; i++) - { - System.out.println(String.format("%d %s", i, - seqs[i].getDisplayId(true))); - } + /** + * Prints a matrix of seqi-seqj pairwise alignment scores to sysout + * + * @param seqs + * @param scores + * @param totscore + */ + protected void printScoreMatrix(SequenceI[] seqs, float[][] scores, + double totscore) + { + System.out + .println("Pairwise alignment scaled similarity score matrix\n"); - for (int i = 0; i < count; i++) + for (int i = 0; i < seqs.length; i++) + { + System.out.println(String.format("%3d %s", i + 1, + seqs[i].getDisplayId(true))); + } + + /* + * table heading columns for sequences 1, 2, 3... + */ + System.out.print("\n "); + for (int i = 0; i < seqs.length; i++) + { + System.out.print(String.format("%7d", i + 1)); + } + System.out.println(); + + for (int i = 0; i < seqs.length; i++) + { + System.out.print(String.format("%3d", i + 1)); + for (int j = 0; j < i; j++) { - for (int j = 0; j < i; j++) - { - System.out.print(String.format("%7.3f", scores[i][j] / totscore)); - } - System.out.println(); + /* + * as a fraction of tot score, outputs are 0 <= score <= 1 + */ + System.out.print(String.format("%7.3f", scores[i][j] / totscore)); } - - System.out.println("\n"); + System.out.println(); } + + System.out.println("\n"); } /**