2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 import jalview.analysis.*;
25 import jalview.datamodel.*;
27 import jalview.schemes.*;
40 public class AlignViewport
46 boolean showJVSuffix = true;
47 boolean showText = true;
48 boolean showColourText = false;
49 boolean showBoxes = true;
50 boolean wrapAlignment = false;
51 boolean renderGaps = true;
52 boolean showSequenceFeatures = false;
53 boolean showAnnotation = true;
54 boolean colourAppliesToAllGroups = true;
55 ColourSchemeI globalColourScheme = null;
56 boolean conservationColourSelected = false;
57 boolean abovePIDThreshold = false;
58 SequenceGroup selectionGroup;
61 boolean validCharWidth;
65 ColumnSelection colSel = new ColumnSelection();
68 NJTree currentTree = null;
69 boolean scaleAboveWrapped = false;
70 boolean scaleLeftWrapped = true;
71 boolean scaleRightWrapped = true;
72 boolean hasHiddenColumns = false;
73 boolean hasHiddenRows = false;
74 boolean showHiddenMarkers = true;
76 boolean cursorMode = false;
78 // The following vector holds the features which are
79 // currently visible, in the correct order or rendering
80 Hashtable featuresDisplayed = null;
84 public Hashtable [] hconsensus;
85 AlignmentAnnotation consensus;
86 AlignmentAnnotation conservation;
87 AlignmentAnnotation quality;
88 boolean autoCalculateConsensus = true;
91 public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
93 // JBPNote Prolly only need this in the applet version.
94 private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this);
96 boolean ignoreGapsInConsensusCalculation = false;
98 boolean isDataset = false;
100 boolean antiAlias = false;
102 boolean padGaps = false;
104 Rectangle explodedPosition;
108 String sequenceSetID;
110 boolean gatherViewsHere = false;
113 * Creates a new AlignViewport object.
115 * @param al DOCUMENT ME!
117 public AlignViewport(AlignmentI al)
123 * Create a new AlignViewport with hidden regions
124 * @param al AlignmentI
125 * @param hiddenColumns ColumnSelection
127 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns) {
129 if (hiddenColumns!=null) {
130 this.colSel = hiddenColumns;
131 if (hiddenColumns.getHiddenColumns() != null)
132 hasHiddenColumns = true;
140 this.endRes = alignment.getWidth() - 1;
142 this.endSeq = alignment.getHeight() - 1;
144 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
146 showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true);
147 showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true);
149 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
151 padGaps = Cache.getDefault("PAD_GAPS", true);
153 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
154 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "") ;
155 String fontSize = Cache.getDefault("FONT_SIZE", "10");
159 if (fontStyle.equals("bold"))
163 else if (fontStyle.equals("italic"))
168 setFont(new Font(fontName, style, Integer.parseInt(fontSize)));
170 alignment.setGapCharacter( Cache.getDefault("GAP_SYMBOL", "-").charAt(0) );
173 // We must set conservation and consensus before setting colour,
174 // as Blosum and Clustal require this to be done
175 if(hconsensus==null && !isDataset)
177 if(!alignment.isNucleotide())
179 conservation = new AlignmentAnnotation("Conservation",
180 "Conservation of total alignment less than " +
181 ConsPercGaps + "% gaps",
182 new Annotation[1], 0f,
184 AlignmentAnnotation.BAR_GRAPH);
185 conservation.hasText = true;
188 if (Cache.getDefault("SHOW_CONSERVATION", true))
190 alignment.addAnnotation(conservation);
193 if (Cache.getDefault("SHOW_QUALITY", true))
195 quality = new AlignmentAnnotation("Quality",
196 "Alignment Quality based on Blosum62 scores",
200 AlignmentAnnotation.BAR_GRAPH);
201 quality.hasText = true;
203 alignment.addAnnotation(quality);
207 consensus = new AlignmentAnnotation("Consensus", "PID",
208 new Annotation[1], 0f, 100f,
209 AlignmentAnnotation.BAR_GRAPH);
210 consensus.hasText = true;
212 if (Cache.getDefault("SHOW_IDENTITY", true))
214 alignment.addAnnotation(consensus);
218 if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null)
220 globalColourScheme = ColourSchemeProperty.getColour(alignment,
221 jalview.bin.Cache.getProperty("DEFAULT_COLOUR"));
223 if (globalColourScheme instanceof UserColourScheme)
225 globalColourScheme = UserDefinedColours.loadDefaultColours();
226 ((UserColourScheme)globalColourScheme).setThreshold(0, getIgnoreGapsConsensus());
229 if (globalColourScheme != null)
231 globalColourScheme.setConsensus(hconsensus);
241 * @param b DOCUMENT ME!
243 public void setShowSequenceFeatures(boolean b)
245 showSequenceFeatures = b;
248 public boolean getShowSequenceFeatures()
250 return showSequenceFeatures;
255 class ConservationThread extends Thread
258 public ConservationThread(AlignmentPanel ap)
267 updatingConservation = true;
269 while (UPDATING_CONSERVATION)
281 ex.printStackTrace();
285 UPDATING_CONSERVATION = true;
288 int alWidth = alignment.getWidth();
292 Conservation cons = new jalview.analysis.Conservation("All",
293 jalview.schemes.ResidueProperties.propHash, 3,
294 alignment.getSequences(), 0, alWidth -1);
297 cons.verdict(false, ConsPercGaps);
304 String sequence = cons.getConsSequence().getSequence();
316 maxB = 0f - minB; // scalable range for colouring both Conservation and Quality
325 conservation.annotations = new Annotation[alWidth];
329 quality.graphMax = cons.qualityRange[1].floatValue();
330 quality.annotations = new Annotation[alWidth];
331 qmin = cons.qualityRange[0].floatValue();
332 qmax = cons.qualityRange[1].floatValue();
335 for (int i = 0; i < alWidth; i++)
339 c = sequence.charAt(i);
341 if (Character.isDigit(c))
342 value = (int) (c - '0');
348 float vprop = value - min;
350 conservation.annotations[i] =
351 new Annotation(String.valueOf(c),
352 String.valueOf(value), ' ', value,
353 new Color(minR + (maxR * vprop),
354 minG + (maxG * vprop),
355 minB + (maxB * vprop)));
360 value = ( (Double) cons.quality.get(i)).floatValue();
361 vprop = value - qmin;
363 quality.annotations[i] = new Annotation(" ", String.valueOf(value), ' ',
365 new Color(minR + (maxR * vprop),
366 minG + (maxG * vprop),
367 minB + (maxB * vprop)));
371 catch (OutOfMemoryError error)
373 javax.swing.SwingUtilities.invokeLater(new Runnable()
379 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
380 "Out of memory calculating conservation!!"
382 "\nSee help files for increasing Java Virtual Machine memory."
384 javax.swing.JOptionPane.WARNING_MESSAGE);
391 System.out.println("Conservation calculation: " + error);
396 UPDATING_CONSERVATION = false;
397 updatingConservation = false;
408 ConservationThread conservationThread;
410 ConsensusThread consensusThread;
412 boolean consUpdateNeeded = false;
414 static boolean UPDATING_CONSENSUS = false;
416 static boolean UPDATING_CONSERVATION = false;
418 boolean updatingConsensus = false;
420 boolean updatingConservation = false;
425 public void updateConservation(final AlignmentPanel ap)
427 if (alignment.isNucleotide() || conservation==null)
430 conservationThread = new ConservationThread(ap);
431 conservationThread.start();
437 public void updateConsensus(final AlignmentPanel ap)
439 consensusThread = new ConsensusThread(ap);
440 consensusThread.start();
444 class ConsensusThread extends Thread
447 public ConsensusThread(AlignmentPanel ap)
453 updatingConsensus = true;
454 while (UPDATING_CONSENSUS)
467 ex.printStackTrace();
472 UPDATING_CONSENSUS = true;
476 int aWidth = alignment.getWidth();
480 consensus.annotations = null;
481 consensus.annotations = new Annotation[aWidth];
484 hconsensus = new Hashtable[aWidth];
485 AAFrequency.calculate(alignment.getSequencesArray(),
487 alignment.getWidth(),
490 for (int i = 0; i < aWidth; i++)
493 if (ignoreGapsInConsensusCalculation)
494 value = ( (Float) hconsensus[i].get(AAFrequency.PID_NOGAPS)).
497 value = ( (Float) hconsensus[i].get(AAFrequency.PID_GAPS)).
500 String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE).toString();
501 String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE) + " ";
503 if (maxRes.length() > 1)
505 mouseOver = "[" + maxRes + "] ";
509 mouseOver += ( (int) value + "%");
510 consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ', value);
514 if (globalColourScheme != null)
515 globalColourScheme.setConsensus(hconsensus);
518 catch (OutOfMemoryError error)
520 alignment.deleteAnnotation(consensus);
524 javax.swing.SwingUtilities.invokeLater(new Runnable()
528 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
529 "Out of memory calculating consensus!!"
531 "\nSee help files for increasing Java Virtual Machine memory."
533 javax.swing.JOptionPane.WARNING_MESSAGE);
537 System.out.println("Consensus calculation: " + error);
540 UPDATING_CONSENSUS = false;
541 updatingConsensus = false;
550 * get the consensus sequence as displayed under the PID consensus annotation row.
551 * @return consensus sequence as a new sequence object
553 public SequenceI getConsensusSeq() {
555 updateConsensus(null);
558 StringBuffer seqs=new StringBuffer();
559 for (int i=0; i<consensus.annotations.length; i++) {
560 if (consensus.annotations[i]!=null) {
561 if (consensus.annotations[i].description.charAt(0) == '[')
562 seqs.append(consensus.annotations[i].description.charAt(1));
564 seqs.append(consensus.annotations[i].displayCharacter);
568 SequenceI sq = new Sequence("Consensus", seqs.toString());
569 sq.setDescription("Percentage Identity Consensus "+((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
575 * @return DOCUMENT ME!
577 public SequenceGroup getSelectionGroup()
579 return selectionGroup;
585 * @param sg DOCUMENT ME!
587 public void setSelectionGroup(SequenceGroup sg)
595 * @return DOCUMENT ME!
597 public boolean getConservationSelected()
599 return conservationColourSelected;
605 * @param b DOCUMENT ME!
607 public void setConservationSelected(boolean b)
609 conservationColourSelected = b;
615 * @return DOCUMENT ME!
617 public boolean getAbovePIDThreshold()
619 return abovePIDThreshold;
625 * @param b DOCUMENT ME!
627 public void setAbovePIDThreshold(boolean b)
629 abovePIDThreshold = b;
635 * @return DOCUMENT ME!
637 public int getStartRes()
645 * @return DOCUMENT ME!
647 public int getEndRes()
655 * @return DOCUMENT ME!
657 public int getStartSeq()
665 * @param cs DOCUMENT ME!
667 public void setGlobalColourScheme(ColourSchemeI cs)
669 globalColourScheme = cs;
675 * @return DOCUMENT ME!
677 public ColourSchemeI getGlobalColourScheme()
679 return globalColourScheme;
685 * @param res DOCUMENT ME!
687 public void setStartRes(int res)
695 * @param seq DOCUMENT ME!
697 public void setStartSeq(int seq)
705 * @param res DOCUMENT ME!
707 public void setEndRes(int res)
709 if (res > (alignment.getWidth() - 1))
711 // log.System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));
712 res = alignment.getWidth() - 1;
726 * @param seq DOCUMENT ME!
728 public void setEndSeq(int seq)
730 if (seq > alignment.getHeight())
732 seq = alignment.getHeight();
746 * @return DOCUMENT ME!
748 public int getEndSeq()
756 * @param f DOCUMENT ME!
758 public void setFont(Font f)
762 Container c = new Container();
764 java.awt.FontMetrics fm = c.getFontMetrics(font);
765 setCharHeight(fm.getHeight());
766 setCharWidth(fm.charWidth('M'));
767 validCharWidth = true;
773 * @return DOCUMENT ME!
775 public Font getFont()
783 * @param w DOCUMENT ME!
785 public void setCharWidth(int w)
793 * @return DOCUMENT ME!
795 public int getCharWidth()
803 * @param h DOCUMENT ME!
805 public void setCharHeight(int h)
813 * @return DOCUMENT ME!
815 public int getCharHeight()
823 * @param w DOCUMENT ME!
825 public void setWrappedWidth(int w)
827 this.wrappedWidth = w;
833 * @return DOCUMENT ME!
835 public int getWrappedWidth()
844 * @return DOCUMENT ME!
846 public AlignmentI getAlignment()
854 * @param align DOCUMENT ME!
856 public void setAlignment(AlignmentI align)
858 this.alignment = align;
864 * @param state DOCUMENT ME!
866 public void setWrapAlignment(boolean state)
868 wrapAlignment = state;
874 * @param state DOCUMENT ME!
876 public void setShowText(boolean state)
884 * @param state DOCUMENT ME!
886 public void setRenderGaps(boolean state)
894 * @return DOCUMENT ME!
896 public boolean getColourText()
898 return showColourText;
904 * @param state DOCUMENT ME!
906 public void setColourText(boolean state)
908 showColourText = state;
914 * @param state DOCUMENT ME!
916 public void setShowBoxes(boolean state)
924 * @return DOCUMENT ME!
926 public boolean getWrapAlignment()
928 return wrapAlignment;
934 * @return DOCUMENT ME!
936 public boolean getShowText()
944 * @return DOCUMENT ME!
946 public boolean getShowBoxes()
954 * @return DOCUMENT ME!
956 public char getGapCharacter()
958 return getAlignment().getGapCharacter();
964 * @param gap DOCUMENT ME!
966 public void setGapCharacter(char gap)
968 if (getAlignment() != null)
970 getAlignment().setGapCharacter(gap);
977 * @param thresh DOCUMENT ME!
979 public void setThreshold(int thresh)
987 * @return DOCUMENT ME!
989 public int getThreshold()
997 * @param inc DOCUMENT ME!
999 public void setIncrement(int inc)
1007 * @return DOCUMENT ME!
1009 public int getIncrement()
1018 * @return DOCUMENT ME!
1020 public ColumnSelection getColumnSelection()
1029 * @param tree DOCUMENT ME!
1031 public void setCurrentTree(NJTree tree)
1039 * @return DOCUMENT ME!
1041 public NJTree getCurrentTree()
1049 * @param b DOCUMENT ME!
1051 public void setColourAppliesToAllGroups(boolean b)
1053 colourAppliesToAllGroups = b;
1059 * @return DOCUMENT ME!
1061 public boolean getColourAppliesToAllGroups()
1063 return colourAppliesToAllGroups;
1069 * @return DOCUMENT ME!
1071 public boolean getShowJVSuffix()
1073 return showJVSuffix;
1079 * @param b DOCUMENT ME!
1081 public void setShowJVSuffix(boolean b)
1090 * @return DOCUMENT ME!
1092 public boolean getShowAnnotation()
1094 return showAnnotation;
1100 * @param b DOCUMENT ME!
1102 public void setShowAnnotation(boolean b)
1110 * @return DOCUMENT ME!
1112 public boolean getScaleAboveWrapped()
1114 return scaleAboveWrapped;
1120 * @return DOCUMENT ME!
1122 public boolean getScaleLeftWrapped()
1124 return scaleLeftWrapped;
1130 * @return DOCUMENT ME!
1132 public boolean getScaleRightWrapped()
1134 return scaleRightWrapped;
1140 * @param b DOCUMENT ME!
1142 public void setScaleAboveWrapped(boolean b)
1144 scaleAboveWrapped = b;
1150 * @param b DOCUMENT ME!
1152 public void setScaleLeftWrapped(boolean b)
1154 scaleLeftWrapped = b;
1160 * @param b DOCUMENT ME!
1162 public void setScaleRightWrapped(boolean b)
1164 scaleRightWrapped = b;
1168 * Property change listener for changes in alignment
1170 * @param listener DOCUMENT ME!
1172 public void addPropertyChangeListener(
1173 java.beans.PropertyChangeListener listener)
1175 changeSupport.addPropertyChangeListener(listener);
1181 * @param listener DOCUMENT ME!
1183 public void removePropertyChangeListener(
1184 java.beans.PropertyChangeListener listener)
1186 changeSupport.removePropertyChangeListener(listener);
1190 * Property change listener for changes in alignment
1192 * @param prop DOCUMENT ME!
1193 * @param oldvalue DOCUMENT ME!
1194 * @param newvalue DOCUMENT ME!
1196 public void firePropertyChange(String prop, Object oldvalue, Object newvalue)
1198 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1201 public void setIgnoreGapsConsensus(boolean b, AlignmentPanel ap)
1203 ignoreGapsInConsensusCalculation = b;
1204 updateConsensus(ap);
1205 if(globalColourScheme!=null)
1207 globalColourScheme.setThreshold(globalColourScheme.getThreshold(), ignoreGapsInConsensusCalculation);
1211 public boolean getIgnoreGapsConsensus()
1213 return ignoreGapsInConsensusCalculation;
1216 public void setDataset(boolean b)
1221 public boolean isDataset()
1227 public void hideSelectedColumns()
1229 if (colSel.size() < 1)
1232 colSel.hideSelectedColumns();
1233 setSelectionGroup(null);
1235 hasHiddenColumns = true;
1239 public void hideColumns(int start, int end)
1242 colSel.hideColumns(start);
1244 colSel.hideColumns(start, end);
1246 hasHiddenColumns = true;
1249 public void hideAllSelectedSeqs()
1251 if (selectionGroup == null)
1254 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1258 setSelectionGroup(null);
1261 public void hideSequence(SequenceI [] seq)
1265 for (int i = 0; i < seq.length; i++)
1266 alignment.getHiddenSequences().hideSequence(seq[i]);
1268 hasHiddenRows = true;
1269 firePropertyChange("alignment", null, alignment.getSequences());
1273 public void showSequence(int index)
1275 Vector tmp = alignment.getHiddenSequences().showSequence(index);
1278 if(selectionGroup==null)
1280 selectionGroup = new SequenceGroup();
1281 selectionGroup.setEndRes(alignment.getWidth()-1);
1284 for (int t = 0; t < tmp.size(); t++)
1286 selectionGroup.addSequence(
1287 (SequenceI) tmp.elementAt(t), false
1290 firePropertyChange("alignment", null, alignment.getSequences());
1293 if(alignment.getHiddenSequences().getSize()<1)
1294 hasHiddenRows = false;
1297 public void showColumn(int col)
1299 colSel.revealHiddenColumns(col);
1300 if(colSel.getHiddenColumns()==null)
1301 hasHiddenColumns = false;
1304 public void showAllHiddenColumns()
1306 colSel.revealAllHiddenColumns();
1307 hasHiddenColumns = false;
1310 public void showAllHiddenSeqs()
1312 if(alignment.getHiddenSequences().getSize()>0)
1314 if(selectionGroup==null)
1316 selectionGroup = new SequenceGroup();
1317 selectionGroup.setEndRes(alignment.getWidth()-1);
1319 Vector tmp = alignment.getHiddenSequences().showAll();
1320 for(int t=0; t<tmp.size(); t++)
1322 selectionGroup.addSequence(
1323 (SequenceI)tmp.elementAt(t), false
1326 firePropertyChange("alignment", null, alignment.getSequences());
1327 hasHiddenRows = false;
1331 public void invertColumnSelection()
1334 for(int i=0; i<alignment.getWidth(); i++)
1338 if(colSel.contains(column))
1339 colSel.removeElement(column);
1341 colSel.addElement(column);
1347 public int adjustForHiddenSeqs(int alignmentIndex)
1349 return alignment.getHiddenSequences().adjustForHiddenSeqs(alignmentIndex);
1353 * This method returns the a new SequenceI [] with
1354 * the selection sequence and start and end points adjusted
1357 public SequenceI[] getSelectionAsNewSequence()
1359 SequenceI[] sequences;
1361 if (selectionGroup == null)
1362 sequences = alignment.getSequencesArray();
1364 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1370 * This method returns the visible alignment as text, as
1371 * seen on the GUI, ie if columns are hidden they will not
1372 * be returned in the result.
1373 * Use this for calculating trees, PCA, redundancy etc on views
1374 * which contain hidden columns.
1377 public jalview.datamodel.CigarArray getViewAsCigars(boolean selectedRegionOnly)
1379 CigarArray selection=null;
1380 SequenceI [] seqs= null;
1382 int start = 0, end = 0;
1383 if(selectedRegionOnly && selectionGroup!=null)
1385 iSize = selectionGroup.getSize(false);
1386 seqs = selectionGroup.getSequencesInOrder(alignment);
1387 start = selectionGroup.getStartRes();
1388 end = selectionGroup.getEndRes(); // inclusive for start and end in SeqCigar constructor
1392 iSize = alignment.getHeight();
1393 seqs = alignment.getSequencesArray();
1394 end = alignment.getWidth()-1;
1396 SeqCigar[] selseqs = new SeqCigar[iSize];
1397 for(i=0; i<iSize; i++)
1399 selseqs[i] = new SeqCigar(seqs[i], start, end);
1401 selection=new CigarArray(selseqs);
1402 // now construct the CigarArray operations
1403 if (hasHiddenColumns) {
1404 Vector regions = colSel.getHiddenColumns();
1406 int hideStart, hideEnd;
1408 for (int j = 0; last<end & j < regions.size(); j++)
1410 region = (int[]) regions.elementAt(j);
1411 hideStart = region[0];
1412 hideEnd = region[1];
1413 // edit hidden regions to selection range
1414 if(hideStart<last) {
1428 if (hideStart>hideEnd)
1431 * form operations...
1434 selection.addOperation(CigarArray.M, hideStart-last);
1435 selection.addOperation(CigarArray.D, 1+hideEnd-hideStart);
1438 // Final match if necessary.
1440 selection.addOperation(CigarArray.M, end-last+1);
1442 selection.addOperation(CigarArray.M, end-start+1);
1447 * return a compact representation of the current alignment selection to
1448 * pass to an analysis function
1449 * @param selectedOnly boolean true to just return the selected view
1450 * @return AlignmentView
1452 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly) {
1454 // this is here because the AlignmentView constructor modifies the CigarArray
1455 // object. Refactoring of Cigar and alignment view representation should
1456 // be done to remove redundancy.
1457 CigarArray aligview = getViewAsCigars(selectedOnly);
1458 if (aligview!=null) {
1459 return new AlignmentView(aligview,
1460 (selectedOnly && selectionGroup!=null) ? selectionGroup.getStartRes() : 0);
1465 * This method returns the visible alignment as text, as
1466 * seen on the GUI, ie if columns are hidden they will not
1467 * be returned in the result.
1468 * Use this for calculating trees, PCA, redundancy etc on views
1469 * which contain hidden columns.
1472 public String [] getViewAsString(boolean selectedRegionOnly)
1474 String [] selection = null;
1475 SequenceI [] seqs= null;
1477 int start = 0, end = 0;
1478 if(selectedRegionOnly && selectionGroup!=null)
1480 iSize = selectionGroup.getSize(false);
1481 seqs = selectionGroup.getSequencesInOrder(alignment);
1482 start = selectionGroup.getStartRes();
1483 end = selectionGroup.getEndRes()+1;
1487 iSize = alignment.getHeight();
1488 seqs = alignment.getSequencesArray();
1489 end = alignment.getWidth();
1492 selection = new String[iSize];
1493 if (hasHiddenColumns) {
1494 selection = colSel.getVisibleSequenceStrings(start, end, seqs);
1496 for(i=0; i<iSize; i++)
1498 selection[i] = seqs[i].getSequence(start, end);
1505 public boolean getShowHiddenMarkers()
1507 return showHiddenMarkers;
1510 public void setShowHiddenMarkers(boolean show)
1512 showHiddenMarkers = show;
1515 public String getSequenceSetId()
1517 if(sequenceSetID==null)
1518 sequenceSetID = alignment.hashCode()+"";
1520 return sequenceSetID;
1523 public void alignmentChanged(AlignmentPanel ap)
1526 alignment.padGaps();
1528 if (hconsensus != null && autoCalculateConsensus)
1530 updateConsensus(ap);
1531 updateConservation(ap);
1534 resetAllColourSchemes();
1536 alignment.adjustSequenceAnnotations();
1541 void resetAllColourSchemes()
1543 ColourSchemeI cs = globalColourScheme;
1546 if (cs instanceof ClustalxColourScheme)
1548 ( (ClustalxColourScheme) cs).
1549 resetClustalX(alignment.getSequences(),
1550 alignment.getWidth());
1553 cs.setConsensus(hconsensus);
1554 if (cs.conservationApplied())
1556 Alignment al = (Alignment) alignment;
1557 Conservation c = new Conservation("All",
1558 ResidueProperties.propHash, 3,
1559 al.getSequences(), 0,
1562 c.verdict(false, ConsPercGaps);
1564 cs.setConservation(c);
1568 int s, sSize = alignment.getGroups().size();
1569 for(s=0; s<sSize; s++)
1571 SequenceGroup sg = (SequenceGroup)alignment.getGroups().elementAt(s);
1572 if(sg.cs!=null && sg.cs instanceof ClustalxColourScheme)
1574 ((ClustalxColourScheme)sg.cs).resetClustalX(
1575 sg.getSequences(true), sg.getWidth());
1577 sg.recalcConservation();