X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=9d63cde5867d0e4abe881d47f7777e9260d9bf18;hb=d1055a6dd6cc9d065e9e589eae260c16cb941265;hp=b21f47e67c792ad0067c4d9903cd9ef634f4fb64;hpb=e142bcca7d3c8a10695b87f94bc724cc2f5ab165;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index b21f47e..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,19 +15,21 @@ 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 = false; - boolean groupEdit = false; - boolean groupDefiningMode = true; + boolean renderGaps = true; + boolean showSequenceFeatures = false; + boolean showAnnotation = true; + boolean colourAppliesToAllGroups = true; ColourSchemeI globalColourScheme = null; boolean conservationColourSelected = false; + boolean abovePIDThreshold = false; - SequenceGroup rubberbandGroup = null; + SequenceGroup selectionGroup = new SequenceGroup(); RendererI renderer = new SequenceRenderer(this); @@ -39,94 +41,153 @@ public class AlignViewport Font font = new Font("SansSerif",Font.PLAIN,10); AlignmentI alignment; - Selection sel = new Selection(); ColumnSelection colSel = new ColumnSelection(); - OutputGenerator og; - - String visibleConsensus; - int threshold; int increment; NJTree currentTree = null; - int window = 50; - int baseline = 30; - Vector kmers; - - public AlignViewport(AlignmentI da, - boolean showScores, + public AlignViewport(AlignmentI al, boolean showText, boolean showBoxes, boolean wrapAlignment) { - this(0,da.getWidth()-1,0,da.getHeight()-1,showScores, - showText, - showBoxes, - wrapAlignment); - setAlignment(da); + 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 ); + } + + public void showSequenceFeatures(boolean b) + { + 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 AlignViewport(int startRes, int endRes, - int startSeq, int endSeq, - boolean showScores, - boolean showText, - boolean showBoxes, - boolean wrapAlignment) { + public void updateConsensus() + { + Annotation [] annotations = new Annotation[alignment.getWidth()]; - this.startRes = startRes; - this.endRes = endRes; - this.startSeq = startSeq; - this.endSeq = endSeq; + 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 = "+ "; + } - this.showScores = showScores; - this.showText = showText; - this.showBoxes = showBoxes; - this.wrapAlignment = wrapAlignment; + mouseOver += (int)value+"%"; + annotations[i] = new Annotation(maxRes, mouseOver, ' ', value); - // og = new AlignmentOutputGenerator(this); + } - setFont( font ); - } + 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 getRubberbandGroup() + + public SequenceGroup getSelectionGroup() { - return rubberbandGroup; + return selectionGroup; } - public void setRubberbandGroup(SequenceGroup sg) + public void setSelectionGroup(SequenceGroup sg) { - rubberbandGroup = sg; + selectionGroup = sg; } + public boolean getConservationSelected() { return conservationColourSelected; @@ -137,6 +198,16 @@ public class AlignViewport conservationColourSelected = b; } + public boolean getAbovePIDThreshold() + { + return abovePIDThreshold; + } + + public void setAbovePIDThreshold(boolean b) + { + abovePIDThreshold = b; + } + public int getStartRes() { return startRes; } @@ -231,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; } @@ -264,9 +333,7 @@ public class AlignViewport public void setShowBoxes(boolean state) { showBoxes = state; } - public boolean getShowScores() { - return showScores; - } + public boolean getWrapAlignment() { return wrapAlignment; } @@ -276,15 +343,7 @@ public class AlignViewport public boolean getShowBoxes() { return showBoxes; } - // public CommandParser getCommandLog() { - /// return log; - // } - public boolean getGroupEdit() { - return groupEdit; - } - public void setGroupEdit(boolean state) { - groupEdit = state; - } + public char getGapCharacter() { return getAlignment().getGapCharacter(); } @@ -324,17 +383,12 @@ public class AlignViewport } return -1; } - public Selection getSelection() { - return sel; - } + public ColumnSelection getColumnSelection() { return colSel; } - public OutputGenerator getOutputGenerator() { - return og; - } + public void resetSeqLimits(int height) { - setStartSeq(0); setEndSeq(height/getCharHeight()); } public void setCurrentTree(NJTree tree) { @@ -351,27 +405,31 @@ public class AlignViewport public RendererI getRenderer() { return renderer; } - public int getPIDWindow() { - return window; - } - public void setPIDWindow(int window) { - this.window = window; - } - public int getPIDBaseline() { - return baseline; - } - public void setPIDBaseline(int baseline) { - this.baseline = baseline; - } + public void setColourAppliesToAllGroups(boolean b) + { colourAppliesToAllGroups = b; } - public void setKmers(Vector kmers) { - this.kmers = kmers; - } + public boolean getColourAppliesToAllGroups() + {return colourAppliesToAllGroups; } - public Vector getKmers() { - return this.kmers; - } + public boolean getShowFullId() + { + return showFullId; + } + public void setShowFullId(boolean b) + { + showFullId = b; + } + + public boolean getShowAnnotation() + { + return showAnnotation; + } + + public void setShowAnnotation(boolean b) + { + showAnnotation = b; + } }