X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FPairwiseAlignPanel.java;h=5e65f1e23ac186f5de13599d194dcddbb5644deb;hb=f4fd7b0e74572c8fddbfe9e3e55bc624f8ba0c6a;hp=910a20678eafa1cd40d13e730b546b77be6e7bc1;hpb=55e2e9b22b133db8b9ff0979b0338a33081fc8fd;p=jalview.git diff --git a/src/jalview/appletgui/PairwiseAlignPanel.java b/src/jalview/appletgui/PairwiseAlignPanel.java index 910a206..5e65f1e 100755 --- a/src/jalview/appletgui/PairwiseAlignPanel.java +++ b/src/jalview/appletgui/PairwiseAlignPanel.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,7 +28,7 @@ import jalview.datamodel.*; import java.awt.*; public class PairwiseAlignPanel - extends Panel + extends Panel implements ActionListener { Vector sequences = new Vector(); AlignmentPanel ap; @@ -42,38 +42,78 @@ public class PairwiseAlignPanel catch (Exception e) { e.printStackTrace(); - } + } this.ap = ap; - float scores[][] = new float[ap.av.alignment.getHeight()][ap.av.alignment. - getHeight()]; + sequences = new Vector(); + + SequenceI[] seqs; + String[] seqStrings = ap.av.getViewAsString(true); + + if (ap.av.getSelectionGroup() == null) + { + seqs = ap.av.alignment.getSequencesArray(); + } + else + { + seqs = ap.av.getSelectionGroup().getSequencesInOrder(ap.av.alignment); + } + + float scores[][] = new float[seqs.length][seqs.length]; double totscore = 0; - int count = ap.av.getSelectionGroup().getSize(); + int count = ap.av.getSelectionGroup().getSize(false); + + Sequence seq; - int acount = 0; for (int i = 1; i < count; i++) { for (int j = 0; j < i; j++) { - acount++; - AlignSeq as = new AlignSeq(ap.av.getSelectionGroup().getSequenceAt(i), - ap.av.getSelectionGroup().getSequenceAt(j), - "pep"); + + AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], + seqs[j], seqStrings[j], "pep"); + + if (as.s1str.length() == 0 || as.s2str.length() == 0) + { + continue; + } as.calcScoreMatrix(); as.traceAlignment(); + as.printAlignment(System.out); scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length; totscore = totscore + scores[i][j]; textarea.append(as.getOutput()); - sequences.addElement(new Sequence(as.getS1().getName(), as.getAStr1())); - sequences.addElement(new Sequence(as.getS2().getName(), as.getAStr2())); - + seq = new Sequence(as.getS1().getName(), + as.getAStr1(), + as.getS1().getStart(), + as.getS1().getEnd() + ); + sequences.addElement(seq); + + seq = new Sequence(as.getS2().getName(), + as.getAStr2(), + as.getS2().getStart(), + as.getS2().getEnd()); + sequences.addElement(seq); } } if (count > 2) { + System.out.println( + "Pairwise alignment scaled similarity score matrix\n"); + + for (int i = 0; i < count; i++) + { + jalview.util.Format.print(System.out, "%s \n", + ("" + i) + " " + + seqs[i].getName()); + } + + System.out.println("\n"); + for (int i = 0; i < count; i++) { for (int j = 0; j < i; j++) @@ -82,10 +122,17 @@ public class PairwiseAlignPanel scores[i][j] / totscore); } } + + System.out.println("\n"); } } + public void actionPerformed(ActionEvent evt) + { + if(evt.getSource()==viewInEditorButton) + viewInEditorButton_actionPerformed(); + } - protected void viewInEditorButton_actionPerformed(ActionEvent e) + protected void viewInEditorButton_actionPerformed() { Sequence[] seq = new Sequence[sequences.size()]; @@ -96,8 +143,9 @@ public class PairwiseAlignPanel } new AlignFrame(new Alignment(seq), - ap.alignFrame.applet, - "Pairwise Aligned Sequences"); + ap.av.applet, + "Pairwise Aligned Sequences", + false); } protected ScrollPane scrollPane = new ScrollPane(); @@ -112,11 +160,7 @@ public class PairwiseAlignPanel textarea.setText(""); viewInEditorButton.setFont(new java.awt.Font("Verdana", 0, 12)); viewInEditorButton.setLabel("View in alignment editor"); - viewInEditorButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - viewInEditorButton_actionPerformed(e); - } - }); + viewInEditorButton.addActionListener(this); this.add(scrollPane, BorderLayout.CENTER); scrollPane.add(textarea); this.add(jPanel1, BorderLayout.SOUTH);