X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=7fd746127eacd37f5c314def3b16c276386a7a18;hb=6284e948c178d7ea7b1fcf8399a54144fe395ce6;hp=d63c0c92615deb5d1e1e7d0469fffd47fec5e200;hpb=dab1ca7e4ee81d69d2222a9cacaf077cc859c6ec;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index d63c0c9..7fd7461 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -22,6 +22,7 @@ public class AlignViewport boolean wrapAlignment=false; boolean renderGaps = true; boolean showSequenceFeatures = false; + boolean showAnnotation = true; boolean colourAppliesToAllGroups = true; ColourSchemeI globalColourScheme = null; @@ -42,12 +43,15 @@ public class AlignViewport ColumnSelection colSel = new ColumnSelection(); - int threshold; int increment; NJTree currentTree = null; + boolean scaleAboveWrapped = false; + boolean scaleLeftWrapped = true; + boolean scaleRightWrapped = true; + public AlignViewport(AlignmentI al, boolean showText, @@ -71,45 +75,82 @@ public class AlignViewport showSequenceFeatures = b; } + public Vector vconsensus; AlignmentAnnotation consensus; AlignmentAnnotation conservation; + AlignmentAnnotation quality; + + public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! + 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()); + alignment.getWidth()-1); cons.calculate(); - cons.verdict(false, 100); - + cons.verdict(false, ConsPercGaps); + cons.findQuality(); + int alWidth = alignment.getWidth(); + Annotation [] annotations = new Annotation[alWidth]; + Annotation [] qannotations = new Annotation[alWidth]; String sequence = cons.getConsSequence().getSequence(); - for (int i = 0; i < alignment.getWidth(); i++) + float minR,minG,minB, maxR,maxG,maxB; + minR = 0.3f; + minG = 0.0f; + minB = 0f; + maxR = 1.0f-minR; maxG=0.9f-minG; maxB=0f-minB; // scalable range for colouring both Conservation and Quality + float min = 0f; + float max = 11f; + float qmin = cons.qualityRange[0].floatValue(); + float qmax = cons.qualityRange[1].floatValue(); + + for (int i = 0; i < alWidth; i++) { - int value = 0; + float value = 0; try - { - value = Integer.parseInt(sequence.charAt(i) + ""); - } + { + value = Integer.parseInt(sequence.charAt(i) + ""); + } catch (Exception ex) - { - if (sequence.charAt(i) == '*') value = 10; - } - + { + if (sequence.charAt(i) == '*') value = 11; + if (sequence.charAt(i) == '+') value = 10; + } + float vprop = value-min; + vprop/=max; annotations[i] = new Annotation(sequence.charAt(i) + "", - "Conservation graph", ' ', value); + "Conservation graph", ' ', value, new Color(minR+maxR*vprop, minG+maxG*vprop, minB+maxB*vprop)); + // Quality calc + value = ((Double) cons.quality.get(i)).floatValue(); + vprop = value - qmin; + vprop/=qmax; + qannotations[i] = new Annotation(" ", + String.valueOf(value), ' ', value, new Color(minR+maxR*vprop, minG+maxG*vprop, minB+maxB*vprop)); } if(conservation==null) { conservation = new AlignmentAnnotation("Conservation", - "Conservation of total alignment", - annotations, 0, 10, 1); + "Conservation of total alignment less than "+ConsPercGaps+"% gaps", + annotations, + 0f, // cons.qualityRange[0].floatValue(), + 11f, // cons.qualityRange[1].floatValue() + 1); alignment.addAnnotation(conservation); + quality = new AlignmentAnnotation("Quality", + "Alignment Quality based on Blosum62 scores", + qannotations, + cons.qualityRange[0].floatValue(), + cons.qualityRange[1].floatValue(), + 1); + alignment.addAnnotation(quality); } - else + else { conservation.annotations = annotations; + quality.annotations = qannotations; + } + } @@ -117,11 +158,25 @@ public class AlignViewport { Annotation [] annotations = new Annotation[alignment.getWidth()]; - Vector cons = alignment.getAAFrequency(); + // this routine prevents vconsensus becoming a new object each time + // consenus is calculated. Important for speed of Blosum62 + // and PID colouring of alignment + if(vconsensus == null) + vconsensus = alignment.getAAFrequency(); + else + { + Vector temp = alignment.getAAFrequency(); + vconsensus.clear(); + Enumeration e = temp.elements(); + while(e.hasMoreElements()) + { + vconsensus.add(e.nextElement()); + } + } Hashtable hash = null; - for (int i = 0; i < alignment.getWidth(); i++) + for (int i = 0; i alignment.getWidth()-1) { System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1)); - res = alignment.getWidth() -1; + res = alignment.getWidth()-1; } if (res < 0) { res = 0; @@ -421,4 +450,34 @@ public class AlignViewport { showFullId = b; } + + public boolean getShowAnnotation() + { + return showAnnotation; + } + + public void setShowAnnotation(boolean b) + { + showAnnotation = b; + } + + public boolean getScaleAboveWrapped() + { return scaleAboveWrapped;} + + public boolean getScaleLeftWrapped() + { return scaleLeftWrapped; } + + public boolean getScaleRightWrapped() + { return scaleRightWrapped; } + + public void setScaleAboveWrapped(boolean b) + { scaleAboveWrapped = b; } + + public void setScaleLeftWrapped(boolean b) + { scaleLeftWrapped = b; } + + public void setScaleRightWrapped(boolean b) + { scaleRightWrapped = b; } + + }