+ public void alignmentChanged(AlignmentPanel ap)
+ {
+ if (padGaps)
+ {
+ alignment.padGaps();
+ }
+
+ if (hconsensus != null && autoCalculateConsensus)
+ {
+ updateConsensus(ap);
+ updateConservation(ap);
+ }
+
+ //Reset endRes of groups if beyond alignment width
+ int alWidth = alignment.getWidth();
+ Vector groups = alignment.getGroups();
+ if(groups!=null)
+ {
+ for(int i=0; i<groups.size(); i++)
+ {
+ SequenceGroup sg = (SequenceGroup)groups.elementAt(i);
+ if(sg.getEndRes()>alWidth)
+ {
+ sg.setEndRes(alWidth-1);
+ }
+ }
+ }
+
+ if(selectionGroup!=null && selectionGroup.getEndRes()>alWidth)
+ {
+ selectionGroup.setEndRes(alWidth-1);
+ }
+
+ resetAllColourSchemes();
+
+ // alignment.adjustSequenceAnnotations();
+ }
+
+
+ void resetAllColourSchemes()
+ {
+ ColourSchemeI cs = globalColourScheme;
+ if(cs!=null)
+ {
+ if (cs instanceof ClustalxColourScheme)
+ {
+ ( (ClustalxColourScheme) cs).
+ resetClustalX(alignment.getSequences(),
+ alignment.getWidth());
+ }
+
+ cs.setConsensus(hconsensus);
+ if (cs.conservationApplied())
+ {
+ Alignment al = (Alignment) alignment;
+ Conservation c = new Conservation("All",
+ ResidueProperties.propHash, 3,
+ al.getSequences(), 0,
+ al.getWidth() - 1);
+ c.calculate();
+ c.verdict(false, ConsPercGaps);
+
+ cs.setConservation(c);
+ }
+ }
+
+ int s, sSize = alignment.getGroups().size();
+ for(s=0; s<sSize; s++)
+ {
+ SequenceGroup sg = (SequenceGroup)alignment.getGroups().elementAt(s);
+ if(sg.cs!=null && sg.cs instanceof ClustalxColourScheme)
+ {
+ ((ClustalxColourScheme)sg.cs).resetClustalX(
+ sg.getSequences(hiddenRepSequences), sg.getWidth());
+ }
+ sg.recalcConservation();
+ }
+ }
+
+
+ public Color getSequenceColour(SequenceI seq)
+ {
+ if(sequenceColours==null || !sequenceColours.containsKey(seq))
+ {
+ return Color.white;
+ }
+ else
+ {
+ return (Color)sequenceColours.get(seq);
+ }
+ }
+
+ public void setSequenceColour(SequenceI seq, Color col)
+ {
+ if(sequenceColours==null)
+ {
+ sequenceColours = new Hashtable();
+ }
+
+ if(col == null)
+ {
+ sequenceColours.remove(seq);
+ }
+ else
+ {
+ sequenceColours.put(seq, col);
+ }
+ }
+ /**
+ * returns the visible column regions of the alignment
+ * @param selectedRegionOnly true to just return the contigs intersecting with the selected area
+ * @return
+ */
+ public int[] getViewAsVisibleContigs(boolean selectedRegionOnly) {
+ int[] viscontigs=null;
+ int start = 0, end = 0;
+ if(selectedRegionOnly && selectionGroup!=null)
+ {
+ start = selectionGroup.getStartRes();
+ end = selectionGroup.getEndRes()+1;
+ }
+ else
+ {
+ end = alignment.getWidth();
+ }
+ viscontigs = colSel.getVisibleContigs(start, end);
+ return viscontigs;
+ }
+
+