- if (fontStyle.equals("bold"))
- {
- style = 1;
- }
- else if (fontStyle.equals("italic"))
- {
- style = 2;
- }
-
- setFont(new Font(fontName, style, Integer.parseInt(fontSize)));
-
-
- alignment.setGapCharacter( Cache.getDefault("GAP_SYMBOL", "-").charAt(0) );
-
-
- // We must set conservation and consensus before setting colour,
- // as Blosum and Clustal require this to be done
- if(hconsensus==null && !isDataset)
- {
- updateConservation();
- updateConsensus();
- }
-
- if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null)
- {
- globalColourScheme = ColourSchemeProperty.getColour(alignment,
- jalview.bin.Cache.getProperty("DEFAULT_COLOUR"));
-
- if (globalColourScheme instanceof UserColourScheme)
- {
- globalColourScheme = UserDefinedColours.loadDefaultColours();
- ((UserColourScheme)globalColourScheme).setThreshold(0, getIgnoreGapsConsensus());
- }
-
- if (globalColourScheme != null)
- {
- globalColourScheme.setConsensus(hconsensus);
- }
- }
- }
-
-
-
- /**
- * DOCUMENT ME!
- *
- * @param b DOCUMENT ME!
- */
- public void setShowSequenceFeatures(boolean b)
- {
- showSequenceFeatures = b;
- }
-
- public boolean getShowSequenceFeatures()
- {
- return showSequenceFeatures;
- }
-
- /**
- * DOCUMENT ME!
- */
- public void updateConservation()
- {
- if(alignment.isNucleotide())
- return;
-
- // System.out.println("UPDATING CONSERVATION");
-
- try{
- Conservation cons = new jalview.analysis.Conservation("All",
- jalview.schemes.ResidueProperties.propHash, 3,
- alignment.getSequences(), 0, alignment.getWidth() - 1);
- cons.calculate();
- 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();
- float minR;
- float minG;
- float minB;
- float maxR;
- float maxG;
- float 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++)
- {
- float value = 0;
-
- try
- {
- value = Integer.parseInt(sequence.charAt(i) + "");
- }
- catch (Exception ex)
- {
- 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) + "",
- 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()
- AlignmentAnnotation.BAR_GRAPH);
-
- if (showConservation)
- {
- alignment.addAnnotation(conservation);
- }
-
- quality = new AlignmentAnnotation("Quality",
- "Alignment Quality based on Blosum62 scores",
- qannotations,
- cons.qualityRange[0].floatValue(),
- cons.qualityRange[1].floatValue(),
- AlignmentAnnotation.BAR_GRAPH);
-
- if (showQuality)
- {
- alignment.addAnnotation(quality);
- }
- }
- else
- {
- conservation.annotations = annotations;
- quality.annotations = qannotations;
- quality.graphMax = cons.qualityRange[1].floatValue();
- }
- }
- catch (OutOfMemoryError error)
- {
- javax.swing.SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- 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();
-
- }
- }
-
-
- /**
- * DOCUMENT ME!
- */
- public void updateConsensus()
- {
- try{
- int aWidth = alignment.getWidth();
-
- Annotation[] annotations = new Annotation[aWidth];
-
- hconsensus = new Hashtable[aWidth];
- AAFrequency.calculate(alignment.getSequencesArray(),
- 0,
- alignment.getWidth(),
- hconsensus);
-
- for (int i = 0; i < aWidth; i++)
- {
- float value = 0;
- if (ignoreGapsInConsensusCalculation)
- value = ( (Float) hconsensus[i].get("pid_nogaps")).floatValue();
- else
- value = ( (Float) hconsensus[i].get("pid_gaps")).floatValue();
-
- String maxRes = hconsensus[i].get("maxResidue").toString();
- String mouseOver = hconsensus[i].get("maxResidue") + " ";
-
- if (maxRes.length() > 1)
- {
- mouseOver = "[" + maxRes + "] ";
- maxRes = "+";
- }
-
- mouseOver += ( (int) value + "%");
- annotations[i] = new Annotation(maxRes, mouseOver, ' ', value);
- }