X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=9d63cde5867d0e4abe881d47f7777e9260d9bf18;hb=24efbd38f2c3dceaf6d3e305eef41ba0b0c9ebdc;hp=2f40de403c9756b8725a98d87b9d83d07a32b8f8;hpb=577f505f54fe343e89f581461e780ea8308c20ec;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 2f40de4..9d63cde 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.*; @@ -15,13 +15,14 @@ public class AlignViewport int startSeq; int endSeq; - boolean showScores=false; + boolean showFullId = false; boolean showText=true; boolean showColourText=false; boolean showBoxes=true; boolean wrapAlignment=false; boolean renderGaps = true; boolean showSequenceFeatures = false; + boolean showAnnotation = true; boolean colourAppliesToAllGroups = true; ColourSchemeI globalColourScheme = null; @@ -42,46 +43,26 @@ public class AlignViewport ColumnSelection colSel = new ColumnSelection(); - String visibleConsensus; - int threshold; int increment; NJTree currentTree = null; - public AlignViewport(AlignmentI da, - boolean showScores, - boolean showText, - boolean showBoxes, - boolean wrapAlignment) { - this(0,da.getWidth()-1,0,da.getHeight()-1,showScores, - showText, - showBoxes, - wrapAlignment); - - setAlignment(da); - } - - public AlignViewport(int startRes, int endRes, - int startSeq, int endSeq, - boolean showScores, + public AlignViewport(AlignmentI al, boolean showText, boolean showBoxes, boolean wrapAlignment) { - this.startRes = startRes; - this.endRes = endRes; - this.startSeq = startSeq; - this.endSeq = endSeq; - - this.showScores = showScores; - 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; - // og = new AlignmentOutputGenerator(this); - + setAlignment(al); setFont( font ); } @@ -90,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 += (int)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; @@ -240,9 +302,7 @@ public class AlignViewport public void setAlignment(AlignmentI align) { this.alignment = align; } - public void setShowScores(boolean state) { - showScores = state; - } + public void setWrapAlignment(boolean state) { wrapAlignment = state; } @@ -273,9 +333,7 @@ public class AlignViewport public void setShowBoxes(boolean state) { showBoxes = state; } - public boolean getShowScores() { - return showScores; - } + public boolean getWrapAlignment() { return wrapAlignment; } @@ -331,7 +389,6 @@ public class AlignViewport } public void resetSeqLimits(int height) { - setStartSeq(0); setEndSeq(height/getCharHeight()); } public void setCurrentTree(NJTree tree) { @@ -355,5 +412,24 @@ public class AlignViewport public boolean getColourAppliesToAllGroups() {return colourAppliesToAllGroups; } + public boolean getShowFullId() + { + return showFullId; + } + + public void setShowFullId(boolean b) + { + showFullId = b; + } + + public boolean getShowAnnotation() + { + return showAnnotation; + } + + public void setShowAnnotation(boolean b) + { + showAnnotation = b; + } }