X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=19a206d2bcee9829ed4c1545806ba3a24de09ca3;hb=c59fb56cb143b05c5643a71f5b39996ac1cd2fef;hp=71427cad80d9329af2f8c201b1fce358f1f87c62;hpb=6052fd910ef378204b5ccdec5bc37f6a97a46b79;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 71427ca..19a206d 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -1,7 +1,7 @@ package jalview.gui; import java.awt.*; -import jalview.io.*; +import jalview.analysis.*; import jalview.analysis.NJTree; import jalview.datamodel.*; import jalview.schemes.*; @@ -42,7 +42,6 @@ public class AlignViewport ColumnSelection colSel = new ColumnSelection(); - String visibleConsensus; int threshold; int increment; @@ -50,32 +49,20 @@ public class AlignViewport NJTree currentTree = null; - public AlignViewport(AlignmentI da, + public AlignViewport(AlignmentI al, boolean showText, boolean showBoxes, boolean wrapAlignment) { - this(0,da.getWidth()-1,0,da.getHeight()-1, - showText, - showBoxes, - wrapAlignment); - - setAlignment(da); - } - public AlignViewport(int startRes, int endRes, - int startSeq, int endSeq, - boolean showText, - boolean showBoxes, - boolean wrapAlignment) { - - this.startRes = startRes; - this.endRes = endRes; - this.startSeq = startSeq; - this.endSeq = endSeq; - this.showText = showText; - this.showBoxes = showBoxes; + this.startRes = 0; + this.endRes = al.getWidth()-1; + this.startSeq = 0; + this.endSeq = al.getHeight()-1; + this.showText = showText; + this.showBoxes = showBoxes; this.wrapAlignment = wrapAlignment; + setAlignment(al); setFont( font ); } @@ -84,31 +71,112 @@ public class AlignViewport showSequenceFeatures = b; } + AlignmentAnnotation consensus; + AlignmentAnnotation conservation; + public void updateConservation() + { + Annotation [] annotations = new Annotation[alignment.getWidth()]; + + Conservation cons = new jalview.analysis.Conservation("All", + jalview.schemes.ResidueProperties.propHash, 3, + alignment.getSequences(), 0, + alignment.getWidth()); + cons.calculate(); + cons.verdict(false, 100); + + String sequence = cons.getConsSequence().getSequence(); + for (int i = 0; i < alignment.getWidth(); i++) + { + int value = 0; + try + { + value = Integer.parseInt(sequence.charAt(i) + ""); + } + catch (Exception ex) + { + if (sequence.charAt(i) == '*') value = 10; + } + + annotations[i] = new Annotation(sequence.charAt(i) + "", + "Conservation graph", ' ', value); + } + + if(conservation==null) + { + conservation = new AlignmentAnnotation("Conservation", + "Conservation of total alignment", + annotations, 0, 10, 1); + alignment.addAnnotation(conservation); + } + else + conservation.annotations = annotations; + + } + + public void updateConsensus() + { + Annotation [] annotations = new Annotation[alignment.getWidth()]; + + Vector cons = alignment.getAAFrequency(); + Hashtable hash = null; + for (int i = 0; i < alignment.getWidth(); i++) + { + hash = (Hashtable) cons.elementAt(i); + float value = Float.parseFloat(hash.get("maxCount").toString()); + value /= Float.parseFloat(hash.get("size").toString()); + + value *= 100; + String maxRes = hash.get("maxResidue")+" "; + String mouseOver = hash.get("maxResidue")+" "; + if(maxRes.length()>2) + { + mouseOver = "["+maxRes+"] "; + maxRes = "+ "; + } + + mouseOver += value+"%"; + annotations[i] = new Annotation(maxRes, mouseOver, ' ', value); + + } + + if(consensus==null) + { + consensus = new AlignmentAnnotation("% Identity", + "PID", annotations, 0f, 100f, 1); + alignment.addAnnotation(consensus); + } + else + consensus.annotations = annotations; + + } + public String getVisibleConsensus() { return visibleConsensus; } - Vector consensus = new Vector(); + String visibleConsensus; + Vector consensusV = new Vector(); public Vector getConsensus(boolean recalculate) { - if(recalculate || consensus.size()<1) + if(recalculate || consensusV.size()<1) { - consensus = alignment.getAAFrequency(); + consensusV = alignment.getAAFrequency(); StringBuffer sb = new StringBuffer(); Hashtable hash = null; - for (int i = 0; i < consensus.size(); i++) + for (int i = 0; i < consensusV.size(); i++) { - hash = (Hashtable) consensus.elementAt(i); + hash = (Hashtable) consensusV.elementAt(i); sb.append(hash.get("maxResidue").toString().charAt(0)); } visibleConsensus = sb.toString(); } - return consensus; + return consensusV; } + public SequenceGroup getSelectionGroup() { return selectionGroup;