getGroup().getName());\r
if (sg.cs instanceof ResidueColourScheme)\r
{\r
- ( (ResidueColourScheme) sg.cs).setThreshold(threshold);\r
+ ( (ResidueColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
}\r
else if (sg.cs instanceof ScoreColourScheme)\r
{\r
- ( (ScoreColourScheme) sg.cs).setThreshold(threshold);\r
+ ( (ScoreColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
}\r
\r
SliderPanel.showPIDSlider();\r
else // remove PIDColouring\r
{\r
ResidueColourScheme rcs = (ResidueColourScheme) sg.cs;\r
- rcs.setThreshold(0);\r
+ rcs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
sg.cs = rcs;\r
}\r
\r
\r
if (cs instanceof ResidueColourScheme)\r
{\r
- ( (ResidueColourScheme) cs).setThreshold(threshold);\r
+ ( (ResidueColourScheme) cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
}\r
\r
viewport.setGlobalColourScheme(cs);\r
}\r
else if (cs instanceof ResidueColourScheme)\r
{\r
- ( (ResidueColourScheme) cs).setThreshold(0);\r
+ ( (ResidueColourScheme) cs).setThreshold(0, viewport.getIgnoreGapsConsensus());\r
}\r
\r
if (viewport.getConservationSelected())\r
{\r
if (sg.cs instanceof ResidueColourScheme)\r
{\r
- ( (ResidueColourScheme) sg.cs).setThreshold(threshold);\r
+ ( (ResidueColourScheme) sg.cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
}\r
\r
sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
}\r
}\r
\r
+ updateCSConsensus();\r
+\r
if (alignPanel.getOverviewPanel() != null)\r
{\r
alignPanel.getOverviewPanel().updateOverviewImage();\r
alignPanel.repaint();\r
}\r
\r
+ public void updateCSConsensus()\r
+ {\r
+ //Colour schemes must have their consensus updated\r
+\r
+ }\r
+\r
protected void modifyPID_actionPerformed(ActionEvent e)\r
{\r
if (viewport.getAbovePIDThreshold())\r
boolean scaleLeftWrapped = true;\r
boolean scaleRightWrapped = true;\r
\r
+\r
+ boolean ignoreGapsInConsensusCalculation = false;\r
+\r
public AlignViewport(AlignmentI al, JalviewLite applet)\r
{\r
setAlignment(al);\r
for (int i = 0; i < alignment.getWidth(); i++)\r
{\r
hash = (Hashtable) vconsensus.elementAt(i);\r
- float value = new Float(hash.get("maxCount").toString()).floatValue();\r
- value /= new Float(hash.get("size").toString()).floatValue();\r
+ float value = 0;\r
+ if(ignoreGapsInConsensusCalculation)\r
+ value = ((Float)hash.get("pid_nogaps")).floatValue();\r
+ else\r
+ value = ((Float)hash.get("pid_gaps")).floatValue();\r
\r
- value *= 100;\r
- String maxRes = hash.get("maxResidue") + " ";\r
+ String maxRes = hash.get("maxResidue").toString();\r
String mouseOver = hash.get("maxResidue") + " ";\r
- if (maxRes.length() > 2)\r
+ if (maxRes.length() > 1)\r
{\r
mouseOver = "[" + maxRes + "] ";\r
- maxRes = "+ ";\r
+ maxRes = "+";\r
}\r
\r
+\r
mouseOver += (int) value + "%";\r
annotations[i] = new Annotation(maxRes, mouseOver, ' ', value);\r
\r
scaleRightWrapped = b;\r
}\r
\r
+ public void setIgnoreGapsConsensus(boolean b)\r
+ {\r
+ ignoreGapsInConsensusCalculation = b;\r
+ updateConsensus();\r
+ if (globalColourScheme!=null && globalColourScheme instanceof ResidueColourScheme)\r
+ {\r
+ ( (ResidueColourScheme) globalColourScheme).setThreshold(\r
+ ( (ResidueColourScheme) globalColourScheme).getThreshold(),\r
+ ignoreGapsInConsensusCalculation);\r
+\r
+ }\r
+\r
+ }\r
+\r
+ public boolean getIgnoreGapsConsensus()\r
+ {\r
+ return ignoreGapsInConsensusCalculation;\r
+ }\r
+\r
+\r
}\r
item = new MenuItem(OUTPUT_TEXT);\r
item.addActionListener(this);\r
pop.add(item);\r
- pop.show(this, evt.getX(), evt.getY());\r
+\r
+ if (aa[selectedRow].label.equals("Consensus"))\r
+ {\r
+ pop.addSeparator();\r
+ final CheckboxMenuItem cbmi = new CheckboxMenuItem(\r
+ "Ignore gaps in calculation",\r
+ ap.av.getIgnoreGapsConsensus());\r
+\r
+ cbmi.addItemListener(new ItemListener()\r
+ {\r
+ public void itemStateChanged(ItemEvent e)\r
+ {\r
+ ap.av.setIgnoreGapsConsensus(cbmi.getState());\r
+ ap.repaint();\r
+ }\r
+ });\r
+ pop.add(cbmi);\r
+ }\r
+\r
+ pop.show(this, evt.getX(), evt.getY());\r
\r
}\r
\r
fm.charWidth(row.annotations[j].displayCharacter.\r
charAt(0))) / 2;\r
g.setColor(row.annotations[j].colour);\r
- if (j == 0)\r
+ if (j == 0 || row.isGraph)\r
{\r
if (row.annotations[0].secondaryStructure == 'H'\r
|| row.annotations[0].secondaryStructure == 'E')\r
}\r
else\r
{\r
- ( (ResidueColourScheme) toChange).setThreshold(i);\r
+ ( (ResidueColourScheme) toChange).setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
}\r
\r
groupIndex--;\r
}\r
\r
UserColourScheme ucs = new UserColourScheme(newColours);\r
- ucs.setThreshold(0);\r
+ ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
\r
if (seqGroup != null)\r
{\r
ap.repaint();\r
}\r
\r
- public static UserColourScheme loadDefaultColours(String file)\r
- {\r
- UserColourScheme ucs = null;\r
- try\r
- {\r
- BufferedReader in = new BufferedReader(new FileReader(file));\r
- Color[] newColours = new Color[24];\r
- for (int i = 0; i < 24; i++)\r
- {\r
- newColours[i] = new Color(Integer.parseInt(in.readLine()));\r
- }\r
-\r
- ucs = new UserColourScheme(newColours);\r
- ucs.setThreshold(0);\r
-\r
- }\r
- catch (Exception ex)\r
- {}\r
-\r
- return ucs;\r
- }\r
\r
protected void cancelButton_actionPerformed(ActionEvent e)\r
{\r
\r
if (cs instanceof ResidueColourScheme)\r
{\r
- ((ResidueColourScheme) cs).setThreshold(threshold);\r
+ ((ResidueColourScheme) cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
}\r
else if (cs instanceof ScoreColourScheme)\r
{\r
- ((ScoreColourScheme) cs).setThreshold(threshold);\r
+ ((ScoreColourScheme) cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
}\r
\r
viewport.setGlobalColourScheme(cs);\r
}\r
else if (cs instanceof ResidueColourScheme)\r
{\r
- ((ResidueColourScheme) cs).setThreshold(0);\r
+ ((ResidueColourScheme) cs).setThreshold(0, viewport.getIgnoreGapsConsensus());\r
}\r
else if (cs instanceof ScoreColourScheme)\r
{\r
- ((ScoreColourScheme) cs).setThreshold(0);\r
+ ((ScoreColourScheme) cs).setThreshold(0, viewport.getIgnoreGapsConsensus());\r
}\r
\r
if (viewport.getConservationSelected())\r
\r
ccs = new ConservationColourScheme(c, cs);\r
\r
- // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
- ccs.setConsensus(viewport.vconsensus);\r
+\r
viewport.setGlobalColourScheme(ccs);\r
\r
ccs.inc = SliderPanel.setConservationSlider(alignPanel, ccs,\r
{\r
if (sg.cs instanceof ResidueColourScheme)\r
{\r
- ((ResidueColourScheme) sg.cs).setThreshold(threshold);\r
+ ((ResidueColourScheme) sg.cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
}\r
else if (sg.cs instanceof ScoreColourScheme)\r
{\r
- ((ScoreColourScheme) sg.cs).setThreshold(threshold);\r
+ ((ScoreColourScheme) sg.cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
}\r
\r
sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0,\r
// JBPNote Prolly only need this in the applet version.\r
private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this);\r
\r
+ boolean ignoreGapsInConsensusCalculation = false;\r
+\r
/**\r
* Creates a new AlignViewport object.\r
*\r
if (globalColourScheme instanceof UserColourScheme)\r
{\r
globalColourScheme = UserDefinedColours.loadDefaultColours();\r
+ ((UserColourScheme)globalColourScheme).setThreshold(0, getIgnoreGapsConsensus());\r
}\r
\r
if (globalColourScheme != null)\r
{\r
hash = (Hashtable) vconsensus.elementAt(i);\r
\r
- float value = Float.parseFloat(hash.get("maxCount").toString());\r
- value /= Float.parseFloat(hash.get("size").toString());\r
-\r
- value *= 100;\r
+ float value = 0;\r
+ if(ignoreGapsInConsensusCalculation)\r
+ value = ((Float)hash.get("pid_nogaps")).floatValue();\r
+ else\r
+ value = ((Float)hash.get("pid_gaps")).floatValue();\r
\r
- String maxRes = hash.get("maxResidue") + " ";\r
- String mouseOver = hash.get("maxResidue") + " ";\r
+ String maxRes = hash.get("maxResidue").toString();\r
+ String mouseOver = hash.get("maxResidue")+" ";\r
\r
- if (maxRes.length() > 2)\r
+ if (maxRes.length() > 1)\r
{\r
mouseOver = "[" + maxRes + "] ";\r
- maxRes = "+ ";\r
+ maxRes = "+";\r
}\r
\r
mouseOver += ((int) value + "%");\r
{\r
consensus.annotations = annotations;\r
}\r
+\r
+ if(globalColourScheme!=null)\r
+ globalColourScheme.setConsensus(vconsensus);\r
}\r
\r
/**\r
{\r
changeSupport.firePropertyChange(prop, oldvalue, newvalue);\r
}\r
+\r
+ public void setIgnoreGapsConsensus(boolean b)\r
+ {\r
+ ignoreGapsInConsensusCalculation = b;\r
+ updateConsensus();\r
+ if(globalColourScheme!=null && globalColourScheme instanceof ResidueColourScheme)\r
+ {\r
+ ((ResidueColourScheme) globalColourScheme).setThreshold(\r
+ ((ResidueColourScheme) globalColourScheme).getThreshold(), ignoreGapsInConsensusCalculation);\r
+\r
+\r
+ }\r
+\r
+ }\r
+\r
+ public boolean getIgnoreGapsConsensus()\r
+ {\r
+ return ignoreGapsInConsensusCalculation;\r
+ }\r
}\r
cap.setText(aa[selectedRow].toString());\r
}\r
\r
+\r
ap.annotationPanel.adjustPanelHeight();\r
\r
Dimension d = ap.annotationScroller.getPreferredSize();\r
item = new JMenuItem(OUTPUT_TEXT);\r
item.addActionListener(this);\r
pop.add(item);\r
+\r
+ if (aa[selectedRow].label.equals("Consensus"))\r
+ {\r
+ pop.addSeparator();\r
+ final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(\r
+ "Ignore gaps in calculation",\r
+ ap.av.getIgnoreGapsConsensus());\r
+ cbmi.addActionListener(new ActionListener()\r
+ {public void actionPerformed(ActionEvent e)\r
+ {\r
+ ap.av.setIgnoreGapsConsensus(cbmi.getState());\r
+ ap.repaint();\r
+ }\r
+ });\r
+ pop.add(cbmi);\r
+\r
+ }\r
+\r
pop.show(this, evt.getX(), evt.getY());\r
}\r
\r
if (validRes &&\r
(row.annotations[j].displayCharacter.length() > 0))\r
{\r
+\r
int charOffset = (av.charWidth -\r
fm.charWidth(row.annotations[j].displayCharacter.charAt(\r
0))) / 2;\r
g.setColor(row.annotations[j].colour);\r
\r
- if (j == 0)\r
+ if (j == 0 || row.isGraph)\r
{\r
g.drawString(row.annotations[j].displayCharacter, x+charOffset,\r
y + iconOffset + 2);\r
}\r
catch (Exception ex)\r
{\r
+ ex.printStackTrace();\r
System.err.println("Exception whilst loading jalview XML file : " +\r
ex + "\n");\r
JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
\r
if (cs instanceof ResidueColourScheme)\r
{\r
- ((ResidueColourScheme) cs).setThreshold(groups[i].getPidThreshold());\r
+ ((ResidueColourScheme) cs).setThreshold(groups[i].getPidThreshold(), true);\r
}\r
else if (cs instanceof ScoreColourScheme)\r
{\r
- ((ScoreColourScheme) cs).setThreshold(groups[i].getPidThreshold());\r
+ ((ScoreColourScheme) cs).setThreshold(groups[i].getPidThreshold(), true);\r
}\r
}\r
\r
cs = ColourSchemeProperty.getColour(al, view.getBgColour());\r
}\r
\r
- if (cs instanceof ConservationColourScheme)\r
- {\r
- ((ConservationColourScheme) cs).inc = view.getConsThreshold();\r
- }\r
-\r
if (cs instanceof ResidueColourScheme)\r
{\r
- ((ResidueColourScheme) cs).setThreshold(view.getPidThreshold());\r
+ ((ResidueColourScheme) cs).setThreshold(view.getPidThreshold(), true);\r
}\r
else if (cs instanceof ScoreColourScheme)\r
{\r
- ((ScoreColourScheme) cs).setThreshold(view.getPidThreshold());\r
+ ((ScoreColourScheme) cs).setThreshold(view.getPidThreshold(), true);\r
}\r
+\r
+ if(cs!=null)\r
+ cs.setConsensus(af.viewport.vconsensus);\r
}\r
\r
+ af.setColourSelected(view.getBgColour());\r
af.viewport.setGlobalColourScheme(cs);\r
-\r
af.viewport.setColourAppliesToAllGroups(false);\r
af.changeColour(af.viewport.getGlobalColourScheme());\r
+ if (view.getConservationSelected())\r
+ {\r
+ ( (ConservationColourScheme) af.viewport.getGlobalColourScheme()).inc = view.getConsThreshold();\r
+ }\r
+\r
af.viewport.setColourAppliesToAllGroups(true);\r
\r
if (view.getShowSequenceFeatures())\r
\r
if (sg.cs instanceof ResidueColourScheme)\r
{\r
- ((ResidueColourScheme) sg.cs).setThreshold(threshold);\r
+ ((ResidueColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
}\r
else if (sg.cs instanceof ScoreColourScheme)\r
{\r
- ((ScoreColourScheme) sg.cs).setThreshold(threshold);\r
+ ((ScoreColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
}\r
\r
SliderPanel.showPIDSlider();\r
else // remove PIDColouring\r
{\r
ResidueColourScheme rcs = (ResidueColourScheme) sg.cs;\r
- rcs.setThreshold(0);\r
+ rcs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
sg.cs = rcs;\r
}\r
\r
}\r
else\r
{\r
- ((ResidueColourScheme) toChange).setThreshold(i);\r
+ ((ResidueColourScheme) toChange).setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
}\r
\r
groupIndex--;\r
\r
if (sg.cs != null)\r
{\r
- ((ResidueColourScheme) sg.cs).setThreshold(25);\r
+ ((ResidueColourScheme) sg.cs).setThreshold(25, av.getIgnoreGapsConsensus());\r
}\r
\r
if (av.getGlobalColourScheme() instanceof ConservationColourScheme)\r
}\r
\r
UserColourScheme ucs = new UserColourScheme(newColours);\r
- ucs.setThreshold(0);\r
+ ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
\r
if (seqGroup != null)\r
{\r
if (cols != null)\r
{\r
ucs = new UserColourScheme(cols);\r
- ucs.setThreshold(0);\r
}\r
\r
return ucs;\r