| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.appletgui; |
| 22 |
|
|
| 23 |
|
import jalview.analysis.AlignSeq; |
| 24 |
|
import jalview.datamodel.Alignment; |
| 25 |
|
import jalview.datamodel.Sequence; |
| 26 |
|
import jalview.datamodel.SequenceI; |
| 27 |
|
import jalview.util.MessageManager; |
| 28 |
|
|
| 29 |
|
import java.awt.BorderLayout; |
| 30 |
|
import java.awt.Button; |
| 31 |
|
import java.awt.Panel; |
| 32 |
|
import java.awt.ScrollPane; |
| 33 |
|
import java.awt.TextArea; |
| 34 |
|
import java.awt.event.ActionEvent; |
| 35 |
|
import java.awt.event.ActionListener; |
| 36 |
|
import java.util.Vector; |
| 37 |
|
|
| |
|
| 0% |
Uncovered Elements: 79 (79) |
Complexity: 17 |
Complexity Density: 0.32 |
|
| 38 |
|
public class PairwiseAlignPanel extends Panel implements ActionListener |
| 39 |
|
{ |
| 40 |
|
Vector sequences = new Vector(); |
| 41 |
|
|
| 42 |
|
AlignmentPanel ap; |
| 43 |
|
|
| |
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 12 |
Complexity Density: 0.32 |
|
| 44 |
0 |
public PairwiseAlignPanel(AlignmentPanel ap)... |
| 45 |
|
{ |
| 46 |
0 |
try |
| 47 |
|
{ |
| 48 |
0 |
jbInit(); |
| 49 |
|
} catch (Exception e) |
| 50 |
|
{ |
| 51 |
0 |
e.printStackTrace(); |
| 52 |
|
} |
| 53 |
0 |
this.ap = ap; |
| 54 |
0 |
sequences = new Vector(); |
| 55 |
|
|
| 56 |
0 |
SequenceI[] seqs; |
| 57 |
0 |
String[] seqStrings = ap.av.getViewAsString(true); |
| 58 |
|
|
| 59 |
0 |
if (ap.av.getSelectionGroup() == null) |
| 60 |
|
{ |
| 61 |
0 |
seqs = ap.av.getAlignment().getSequencesArray(); |
| 62 |
|
} |
| 63 |
|
else |
| 64 |
|
{ |
| 65 |
0 |
seqs = ap.av.getSelectionGroup() |
| 66 |
|
.getSequencesInOrder(ap.av.getAlignment()); |
| 67 |
|
} |
| 68 |
|
|
| 69 |
0 |
float scores[][] = new float[seqs.length][seqs.length]; |
| 70 |
0 |
double totscore = 0; |
| 71 |
0 |
int count = ap.av.getSelectionGroup().getSize(); |
| 72 |
0 |
String type = (ap.av.getAlignment().isNucleotide()) ? AlignSeq.DNA |
| 73 |
|
: AlignSeq.PEP; |
| 74 |
0 |
Sequence seq; |
| 75 |
|
|
| 76 |
0 |
for (int i = 1; i < count; i++) |
| 77 |
|
{ |
| 78 |
0 |
for (int j = 0; j < i; j++) |
| 79 |
|
{ |
| 80 |
|
|
| 81 |
0 |
AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], seqs[j], |
| 82 |
|
seqStrings[j], type); |
| 83 |
|
|
| 84 |
0 |
if (as.s1str.length() == 0 || as.s2str.length() == 0) |
| 85 |
|
{ |
| 86 |
0 |
continue; |
| 87 |
|
} |
| 88 |
|
|
| 89 |
0 |
as.calcScoreMatrix(); |
| 90 |
0 |
as.traceAlignment(); |
| 91 |
|
|
| 92 |
0 |
as.printAlignment(System.out); |
| 93 |
0 |
scores[i][j] = (float) as.getMaxScore() |
| 94 |
|
/ (float) as.getASeq1().length; |
| 95 |
0 |
totscore = totscore + scores[i][j]; |
| 96 |
|
|
| 97 |
0 |
textarea.append(as.getOutput()); |
| 98 |
0 |
sequences.add(as.getAlignedSeq1()); |
| 99 |
0 |
sequences.add(as.getAlignedSeq1()); |
| 100 |
|
} |
| 101 |
|
} |
| 102 |
|
|
| 103 |
0 |
if (count > 2) |
| 104 |
|
{ |
| 105 |
0 |
jalview.bin.Console.outPrintln( |
| 106 |
|
"Pairwise alignment scaled similarity score matrix\n"); |
| 107 |
|
|
| 108 |
0 |
for (int i = 0; i < count; i++) |
| 109 |
|
{ |
| 110 |
0 |
jalview.util.Format.print(System.out, "%s \n", |
| 111 |
|
("" + i) + " " + seqs[i].getName()); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
0 |
jalview.bin.Console.outPrintln("\n"); |
| 115 |
|
|
| 116 |
0 |
for (int i = 0; i < count; i++) |
| 117 |
|
{ |
| 118 |
0 |
for (int j = 0; j < i; j++) |
| 119 |
|
{ |
| 120 |
0 |
jalview.util.Format.print(System.out, "%7.3f", |
| 121 |
|
scores[i][j] / totscore); |
| 122 |
|
} |
| 123 |
|
} |
| 124 |
|
|
| 125 |
0 |
jalview.bin.Console.outPrintln("\n"); |
| 126 |
|
} |
| 127 |
|
} |
| 128 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 129 |
0 |
public void actionPerformed(ActionEvent evt)... |
| 130 |
|
{ |
| 131 |
0 |
if (evt.getSource() == viewInEditorButton) |
| 132 |
|
{ |
| 133 |
0 |
viewInEditorButton_actionPerformed(); |
| 134 |
|
} |
| 135 |
|
} |
| 136 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 137 |
0 |
protected void viewInEditorButton_actionPerformed()... |
| 138 |
|
{ |
| 139 |
|
|
| 140 |
0 |
Sequence[] seq = new Sequence[sequences.size()]; |
| 141 |
|
|
| 142 |
0 |
for (int i = 0; i < sequences.size(); i++) |
| 143 |
|
{ |
| 144 |
0 |
seq[i] = (Sequence) sequences.elementAt(i); |
| 145 |
|
} |
| 146 |
|
|
| 147 |
0 |
new AlignFrame(new Alignment(seq), ap.av.applet, |
| 148 |
|
"Pairwise Aligned Sequences", false); |
| 149 |
|
|
| 150 |
|
} |
| 151 |
|
|
| 152 |
|
protected ScrollPane scrollPane = new ScrollPane(); |
| 153 |
|
|
| 154 |
|
protected TextArea textarea = new TextArea(); |
| 155 |
|
|
| 156 |
|
protected Button viewInEditorButton = new Button(); |
| 157 |
|
|
| 158 |
|
Panel jPanel1 = new Panel(); |
| 159 |
|
|
| 160 |
|
BorderLayout borderLayout1 = new BorderLayout(); |
| 161 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
| 162 |
0 |
private void jbInit() throws Exception... |
| 163 |
|
{ |
| 164 |
0 |
this.setLayout(borderLayout1); |
| 165 |
0 |
textarea.setFont(new java.awt.Font("Monospaced", 0, 12)); |
| 166 |
0 |
textarea.setText(""); |
| 167 |
0 |
viewInEditorButton.setFont(new java.awt.Font("Verdana", 0, 12)); |
| 168 |
0 |
viewInEditorButton.setLabel( |
| 169 |
|
MessageManager.getString("label.view_alignment_editor")); |
| 170 |
0 |
viewInEditorButton.addActionListener(this); |
| 171 |
0 |
this.add(scrollPane, BorderLayout.CENTER); |
| 172 |
0 |
scrollPane.add(textarea); |
| 173 |
0 |
this.add(jPanel1, BorderLayout.SOUTH); |
| 174 |
0 |
jPanel1.add(viewInEditorButton, null); |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
} |