X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=7f8675375da91f3acaba5922e27fde0170325f5e;hb=32ce9ddb7ce1a68add53dd81785ae428ca136a83;hp=e98fb9f61d6ed43bd897aa93bdc3188a8bd0ba41;hpb=9fff97021c2c637e426f6971d54dcf3fd4191985;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index e98fb9f..7f86753 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -1,4 +1,4 @@ -/* + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * @@ -43,7 +43,7 @@ public class AlignViewport int endRes; int startSeq; int endSeq; - boolean showFullId = false; + boolean showJVSuffix = true; boolean showText = true; boolean showColourText = false; boolean showBoxes = true; @@ -61,8 +61,7 @@ public class AlignViewport SequenceGroup selectionGroup; int charHeight; int charWidth; - int chunkWidth; - int chunkHeight; + int wrappedWidth; Font font = new Font("SansSerif", Font.PLAIN, 10); AlignmentI alignment; ColumnSelection colSel = new ColumnSelection(); @@ -87,6 +86,15 @@ public class AlignViewport boolean ignoreGapsInConsensusCalculation = false; + boolean isDataset = false; + + + public AlignViewport(AlignmentI al, boolean dataset) + { + isDataset = dataset; + setAlignment(al); + init(); + } /** * Creates a new AlignViewport object. * @@ -95,20 +103,17 @@ public class AlignViewport public AlignViewport(AlignmentI al) { setAlignment(al); - this.startRes = 0; - this.endRes = al.getWidth() - 1; - this.startSeq = 0; - this.endSeq = al.getHeight() - 1; - - updateFromPreferences(); + init(); } - /** - * DOCUMENT ME! - */ - public void updateFromPreferences() + void init() { - showFullId = Cache.getDefault("SHOW_FULL_ID", true); + this.startRes = 0; + this.endRes = alignment.getWidth() - 1; + this.startSeq = 0; + this.endSeq = alignment.getHeight() - 1; + + showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true); showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true); showConservation = Cache.getDefault("SHOW_CONSERVATION", true); @@ -138,8 +143,11 @@ public class AlignViewport // We must set conservation and consensus before setting colour, // as Blosum and Clustal require this to be done - updateConservation(); - updateConsensus(); + if(vconsensus==null && !isDataset) + { + updateConservation(); + updateConsensus(); + } if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null) { @@ -176,9 +184,13 @@ public class AlignViewport */ public void updateConservation() { + if(alignment.isNucleotide()) + return; + + try{ Conservation cons = new jalview.analysis.Conservation("All", - jalview.schemes.ResidueProperties.propHash, 3, - alignment.getSequences(), 0, alignment.getWidth() - 1); + jalview.schemes.ResidueProperties.propHash, 3, + alignment.getSequences(), 0, alignment.getWidth() - 1); cons.calculate(); cons.verdict(false, ConsPercGaps); cons.findQuality(); @@ -207,71 +219,89 @@ public class AlignViewport for (int i = 0; i < alWidth; i++) { - float value = 0; - - try + float value = 0; + + try + { + value = Integer.parseInt(sequence.charAt(i) + ""); + } + catch (Exception ex) + { + if (sequence.charAt(i) == '*') { - value = Integer.parseInt(sequence.charAt(i) + ""); + value = 11; } - catch (Exception ex) - { - if (sequence.charAt(i) == '*') - { - value = 11; - } - if (sequence.charAt(i) == '+') - { - value = 10; - } + if (sequence.charAt(i) == '+') + { + value = 10; } - - float vprop = value - min; - vprop /= max; - annotations[i] = new Annotation(sequence.charAt(i) + "", - String.valueOf(value), ' ', 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))); + } + + float vprop = value - min; + vprop /= max; + annotations[i] = new Annotation(sequence.charAt(i) + "", + String.valueOf(value), ' ', 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 less than " + - ConsPercGaps + "% gaps", annotations, 0f, // cons.qualityRange[0].floatValue(), - 11f, // cons.qualityRange[1].floatValue() - 1); - - if (showConservation) - { - alignment.addAnnotation(conservation); - } - - quality = new AlignmentAnnotation("Quality", - "Alignment Quality based on Blosum62 scores", qannotations, - cons.qualityRange[0].floatValue(), - cons.qualityRange[1].floatValue(), 1); - - if (showQuality) - { - alignment.addAnnotation(quality); - } + conservation = new AlignmentAnnotation("Conservation", + "Conservation of total alignment less than " + + ConsPercGaps + "% gaps", + annotations, 0f, // cons.qualityRange[0].floatValue(), + 11f, // cons.qualityRange[1].floatValue() + 1); + + if (showConservation) + { + alignment.addAnnotation(conservation); + } + + quality = new AlignmentAnnotation("Quality", + "Alignment Quality based on Blosum62 scores", + qannotations, + cons.qualityRange[0].floatValue(), + cons.qualityRange[1].floatValue(), + 1); + + if (showQuality) + { + alignment.addAnnotation(quality); + } } else { - conservation.annotations = annotations; - quality.annotations = qannotations; - quality.graphMax = cons.qualityRange[1].floatValue(); + conservation.annotations = annotations; + quality.annotations = qannotations; + quality.graphMax = cons.qualityRange[1].floatValue(); } + } + catch (OutOfMemoryError error) + { + javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Out of memory calculating conservation!!" + + + "\nSee help files for increasing Java Virtual Machine memory." + , "Out of memory", + javax.swing.JOptionPane.WARNING_MESSAGE); + System.out.println("Conservation calculation: " + error); + System.gc(); + + } } /** @@ -279,6 +309,7 @@ public class AlignViewport */ public void updateConsensus() { + try{ Annotation[] annotations = new Annotation[alignment.getWidth()]; // this routine prevents vconsensus becoming a new object each time @@ -286,63 +317,76 @@ public class AlignViewport // and PID colouring of alignment if (vconsensus == null) { - vconsensus = alignment.getAAFrequency(); + vconsensus = alignment.getAAFrequency(); } else { - Vector temp = alignment.getAAFrequency(); - vconsensus.clear(); + Vector temp = alignment.getAAFrequency(); + vconsensus.clear(); - Enumeration e = temp.elements(); + Enumeration e = temp.elements(); - while (e.hasMoreElements()) - { - vconsensus.add(e.nextElement()); - } + while (e.hasMoreElements()) + { + vconsensus.add(e.nextElement()); + } } Hashtable hash = null; for (int i = 0; i < alignment.getWidth(); i++) { - hash = (Hashtable) vconsensus.elementAt(i); + hash = (Hashtable) vconsensus.elementAt(i); - float value = 0; - if(ignoreGapsInConsensusCalculation) - value = ((Float)hash.get("pid_nogaps")).floatValue(); - else - value = ((Float)hash.get("pid_gaps")).floatValue(); + float value = 0; + if (ignoreGapsInConsensusCalculation) + value = ( (Float) hash.get("pid_nogaps")).floatValue(); + else + value = ( (Float) hash.get("pid_gaps")).floatValue(); - String maxRes = hash.get("maxResidue").toString(); - String mouseOver = hash.get("maxResidue")+" "; + String maxRes = hash.get("maxResidue").toString(); + String mouseOver = hash.get("maxResidue") + " "; - if (maxRes.length() > 1) - { - mouseOver = "[" + maxRes + "] "; - maxRes = "+"; - } + if (maxRes.length() > 1) + { + mouseOver = "[" + maxRes + "] "; + maxRes = "+"; + } - mouseOver += ((int) value + "%"); - annotations[i] = new Annotation(maxRes, mouseOver, ' ', value); + mouseOver += ( (int) value + "%"); + annotations[i] = new Annotation(maxRes, mouseOver, ' ', value); } if (consensus == null) { - consensus = new AlignmentAnnotation("Consensus", "PID", - annotations, 0f, 100f, 1); + consensus = new AlignmentAnnotation("Consensus", "PID", + annotations, 0f, 100f, 1); - if (showIdentity) - { - alignment.addAnnotation(consensus); - } + if (showIdentity) + { + alignment.addAnnotation(consensus); + } } else { - consensus.annotations = annotations; + consensus.annotations = annotations; } - if(globalColourScheme!=null) + if (globalColourScheme != null) globalColourScheme.setConsensus(vconsensus); + + }catch(OutOfMemoryError error) + { + javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Out of memory calculating consensus!!" + + + "\nSee help files for increasing Java Virtual Machine memory." + , "Out of memory", + javax.swing.JOptionPane.WARNING_MESSAGE); + System.out.println("Consensus calculation: " + error); + System.gc(); + } + } /** @@ -597,9 +641,9 @@ public class AlignViewport * * @param w DOCUMENT ME! */ - public void setChunkWidth(int w) + public void setWrappedWidth(int w) { - this.chunkWidth = w; + this.wrappedWidth = w; } /** @@ -607,30 +651,11 @@ public class AlignViewport * * @return DOCUMENT ME! */ - public int getChunkWidth() + public int getWrappedWidth() { - return chunkWidth; + return wrappedWidth; } - /** - * DOCUMENT ME! - * - * @param h DOCUMENT ME! - */ - public void setChunkHeight(int h) - { - this.chunkHeight = h; - } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public int getChunkHeight() - { - return chunkHeight; - } /** * DOCUMENT ME! @@ -851,15 +876,6 @@ public class AlignViewport return colSel; } - /** - * DOCUMENT ME! - * - * @param height DOCUMENT ME! - */ - public void resetSeqLimits(int height) - { - setEndSeq(height / getCharHeight()); - } /** * DOCUMENT ME! @@ -906,9 +922,9 @@ public class AlignViewport * * @return DOCUMENT ME! */ - public boolean getShowFullId() + public boolean getShowJVSuffix() { - return showFullId; + return showJVSuffix; } /** @@ -916,11 +932,12 @@ public class AlignViewport * * @param b DOCUMENT ME! */ - public void setShowFullId(boolean b) + public void setShowJVSuffix(boolean b) { - showFullId = b; + showJVSuffix = b; } + /** * DOCUMENT ME! * @@ -1002,7 +1019,7 @@ public class AlignViewport } /** - * DOCUMENT ME! + * Property change listener for changes in alignment * * @param listener DOCUMENT ME! */ @@ -1024,7 +1041,7 @@ public class AlignViewport } /** - * DOCUMENT ME! + * Property change listener for changes in alignment * * @param prop DOCUMENT ME! * @param oldvalue DOCUMENT ME! @@ -1039,12 +1056,9 @@ public class AlignViewport { ignoreGapsInConsensusCalculation = b; updateConsensus(); - if(globalColourScheme!=null && globalColourScheme instanceof ResidueColourScheme) + if(globalColourScheme!=null) { - ((ResidueColourScheme) globalColourScheme).setThreshold( - ((ResidueColourScheme) globalColourScheme).getThreshold(), ignoreGapsInConsensusCalculation); - - + globalColourScheme.setThreshold(globalColourScheme.getThreshold(), ignoreGapsInConsensusCalculation); } } @@ -1053,4 +1067,14 @@ public class AlignViewport { return ignoreGapsInConsensusCalculation; } + + public void setDataset(boolean b) + { + isDataset = b; + } + + public boolean isDataset() + { + return isDataset; + } }