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 showConservation = true;
55 boolean showQuality = true;
56 boolean showIdentity = true;
57 boolean colourAppliesToAllGroups = true;
58 ColourSchemeI globalColourScheme = null;
59 boolean conservationColourSelected = false;
60 boolean abovePIDThreshold = false;
61 SequenceGroup selectionGroup;
64 boolean validCharWidth;
68 ColumnSelection colSel = new ColumnSelection();
71 NJTree currentTree = null;
72 boolean scaleAboveWrapped = false;
73 boolean scaleLeftWrapped = true;
74 boolean scaleRightWrapped = true;
75 boolean hasHiddenColumns = false;
76 boolean hasHiddenRows = false;
77 boolean showHiddenMarkers = true;
79 boolean cursorMode = false;
81 // The following vector holds the features which are
82 // currently visible, in the correct order or rendering
83 Hashtable featuresDisplayed = null;
87 public Hashtable [] hconsensus;
88 AlignmentAnnotation consensus;
89 AlignmentAnnotation conservation;
90 AlignmentAnnotation quality;
91 boolean autoCalculateConsensus = true;
94 public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
96 // JBPNote Prolly only need this in the applet version.
97 private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this);
99 boolean ignoreGapsInConsensusCalculation = false;
101 boolean isDataset = false;
103 boolean antiAlias = false;
105 boolean padGaps = false;
107 Rectangle explodedPosition;
111 String sequenceSetID;
113 boolean gatherViewsHere = false;
116 public AlignViewport(AlignmentI al, boolean dataset)
123 * Creates a new AlignViewport object.
125 * @param al DOCUMENT ME!
127 public AlignViewport(AlignmentI al)
133 * Create a new AlignViewport with hidden regions
134 * @param al AlignmentI
135 * @param hiddenColumns ColumnSelection
137 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns) {
139 if (hiddenColumns!=null) {
140 this.colSel = hiddenColumns;
141 if (hiddenColumns.getHiddenColumns() != null)
142 hasHiddenColumns = true;
150 this.endRes = alignment.getWidth() - 1;
152 this.endSeq = alignment.getHeight() - 1;
154 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
156 showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true);
157 showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true);
158 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
160 showQuality = Cache.getDefault("SHOW_QUALITY", true);
161 showIdentity = Cache.getDefault("SHOW_IDENTITY", true);
163 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
165 padGaps = Cache.getDefault("PAD_GAPS", false);
167 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
168 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "") ;
169 String fontSize = Cache.getDefault("FONT_SIZE", "10");
173 if (fontStyle.equals("bold"))
177 else if (fontStyle.equals("italic"))
182 setFont(new Font(fontName, style, Integer.parseInt(fontSize)));
185 alignment.setGapCharacter( Cache.getDefault("GAP_SYMBOL", "-").charAt(0) );
188 // We must set conservation and consensus before setting colour,
189 // as Blosum and Clustal require this to be done
190 if(hconsensus==null && !isDataset)
192 if(!alignment.isNucleotide())
194 conservation = new AlignmentAnnotation("Conservation",
195 "Conservation of total alignment less than " +
196 ConsPercGaps + "% gaps",
197 new Annotation[1], 0f,
199 AlignmentAnnotation.BAR_GRAPH);
200 conservation.hasText = true;
202 if (showConservation)
204 alignment.addAnnotation(conservation);
209 quality = new AlignmentAnnotation("Quality",
210 "Alignment Quality based on Blosum62 scores",
214 AlignmentAnnotation.BAR_GRAPH);
216 alignment.addAnnotation(quality);
220 consensus = new AlignmentAnnotation("Consensus", "PID",
221 new Annotation[1], 0f, 100f,
222 AlignmentAnnotation.BAR_GRAPH);
223 consensus.hasText = true;
227 alignment.addAnnotation(consensus);
232 if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null)
234 globalColourScheme = ColourSchemeProperty.getColour(alignment,
235 jalview.bin.Cache.getProperty("DEFAULT_COLOUR"));
237 if (globalColourScheme instanceof UserColourScheme)
239 globalColourScheme = UserDefinedColours.loadDefaultColours();
240 ((UserColourScheme)globalColourScheme).setThreshold(0, getIgnoreGapsConsensus());
243 if (globalColourScheme != null)
245 globalColourScheme.setConsensus(hconsensus);
255 * @param b DOCUMENT ME!
257 public void setShowSequenceFeatures(boolean b)
259 showSequenceFeatures = b;
262 public boolean getShowSequenceFeatures()
264 return showSequenceFeatures;
269 class ConservationThread extends Thread
272 public ConservationThread(AlignmentPanel ap)
281 long t = System.currentTimeMillis();
283 Conservation cons = new jalview.analysis.Conservation("All",
284 jalview.schemes.ResidueProperties.propHash, 3,
285 alignment.getSequences(), 0, alignment.getWidth() - 1);
288 cons.verdict(false, ConsPercGaps);
295 System.out.println("Conservation took " + (System.currentTimeMillis() - t) +
298 int alWidth = alignment.getWidth();
299 String sequence = cons.getConsSequence().getSequence();
311 maxB = 0f - minB; // scalable range for colouring both Conservation and Quality
320 conservation.annotations = new Annotation[alWidth];
324 quality.annotations = new Annotation[alWidth];
325 qmin = cons.qualityRange[0].floatValue();
326 qmax = cons.qualityRange[1].floatValue();
329 for (int i = 0; i < alWidth; i++)
333 c = sequence.charAt(i);
335 if (Character.isDigit(c))
336 value = (int) (c - '0');
342 float vprop = value - min;
344 conservation.annotations[i] =
345 new Annotation(String.valueOf(c),
346 String.valueOf(value), ' ', value,
347 new Color(minR + (maxR * vprop),
348 minG + (maxG * vprop),
349 minB + (maxB * vprop)));
354 value = ( (Double) cons.quality.get(i)).floatValue();
355 vprop = value - qmin;
357 quality.annotations[i] = new Annotation(" ", String.valueOf(value), ' ',
359 new Color(minR + (maxR * vprop),
360 minG + (maxG * vprop),
361 minB + (maxB * vprop)));
367 quality.graphMax = cons.qualityRange[1].floatValue();
370 catch (OutOfMemoryError error)
372 javax.swing.SwingUtilities.invokeLater(new Runnable()
376 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
377 "Out of memory calculating conservation!!"
379 "\nSee help files for increasing Java Virtual Machine memory."
381 javax.swing.JOptionPane.WARNING_MESSAGE);
385 System.out.println("Conservation calculation: " + error);
392 ap.annotationPanel.repaint();
394 updatingConservation = false;
399 ConservationThread conservationThread;
401 ConsensusThread consensusThread;
403 boolean consUpdateNeeded = false;
405 boolean updatingConsensus = false;
407 boolean updatingConservation = false;
412 public void updateConservation(AlignmentPanel ap)
414 if (alignment.isNucleotide())
417 updatingConservation = true;
419 if (conservationThread == null || !conservationThread.isAlive())
421 conservationThread = new ConservationThread(ap);
422 conservationThread.start();
426 consUpdateNeeded = true;
427 System.out.println("come back later");
434 public void updateConsensus(AlignmentPanel ap)
436 updatingConsensus = true;
438 if (consensusThread == null || !consensusThread.isAlive())
440 consensusThread = new ConsensusThread(ap);
441 consensusThread.start();
445 consUpdateNeeded = true;
446 System.out.println("come back later");
451 class ConsensusThread extends Thread
454 public ConsensusThread(AlignmentPanel ap)
462 int aWidth = alignment.getWidth();
464 consensus.annotations = null;
465 consensus.annotations = new Annotation[aWidth];
467 long t = System.currentTimeMillis();
468 hconsensus = new Hashtable[aWidth];
469 AAFrequency.calculate(alignment.getSequencesArray(),
471 alignment.getWidth(),
474 System.out.println("Consensus took " +
475 (System.currentTimeMillis() - t) + "ms");
477 for (int i = 0; i < aWidth; i++)
480 if (ignoreGapsInConsensusCalculation)
481 value = ( (Float) hconsensus[i].get(AAFrequency.PID_NOGAPS)).
484 value = ( (Float) hconsensus[i].get(AAFrequency.PID_GAPS)).
487 String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE).toString();
488 String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE) + " ";
490 if (maxRes.length() > 1)
492 mouseOver = "[" + maxRes + "] ";
496 mouseOver += ( (int) value + "%");
497 consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ', value);
501 if (globalColourScheme != null)
502 globalColourScheme.setConsensus(hconsensus);
505 catch (OutOfMemoryError error)
507 javax.swing.SwingUtilities.invokeLater(new Runnable()
511 javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
512 "Out of memory calculating consensus!!"
514 "\nSee help files for increasing Java Virtual Machine memory."
516 javax.swing.JOptionPane.WARNING_MESSAGE);
520 System.out.println("Consensus calculation: " + error);
526 ap.annotationPanel.repaint();
530 updatingConsensus = false;
534 * get the consensus sequence as displayed under the PID consensus annotation row.
535 * @return consensus sequence as a new sequence object
537 public SequenceI getConsensusSeq() {
539 updateConsensus(null);
542 StringBuffer seqs=new StringBuffer();
543 for (int i=0; i<consensus.annotations.length; i++) {
544 if (consensus.annotations[i]!=null) {
545 if (consensus.annotations[i].description.charAt(0) == '[')
546 seqs.append(consensus.annotations[i].description.charAt(1));
548 seqs.append(consensus.annotations[i].displayCharacter);
551 SequenceI sq = new Sequence("Consensus", seqs.toString());
552 sq.setDescription("Percentage Identity Consensus "+((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
558 * @return DOCUMENT ME!
560 public SequenceGroup getSelectionGroup()
562 return selectionGroup;
568 * @param sg DOCUMENT ME!
570 public void setSelectionGroup(SequenceGroup sg)
578 * @return DOCUMENT ME!
580 public boolean getConservationSelected()
582 return conservationColourSelected;
588 * @param b DOCUMENT ME!
590 public void setConservationSelected(boolean b)
592 conservationColourSelected = b;
598 * @return DOCUMENT ME!
600 public boolean getAbovePIDThreshold()
602 return abovePIDThreshold;
608 * @param b DOCUMENT ME!
610 public void setAbovePIDThreshold(boolean b)
612 abovePIDThreshold = b;
618 * @return DOCUMENT ME!
620 public int getStartRes()
628 * @return DOCUMENT ME!
630 public int getEndRes()
638 * @return DOCUMENT ME!
640 public int getStartSeq()
648 * @param cs DOCUMENT ME!
650 public void setGlobalColourScheme(ColourSchemeI cs)
652 globalColourScheme = cs;
658 * @return DOCUMENT ME!
660 public ColourSchemeI getGlobalColourScheme()
662 return globalColourScheme;
668 * @param res DOCUMENT ME!
670 public void setStartRes(int res)
678 * @param seq DOCUMENT ME!
680 public void setStartSeq(int seq)
688 * @param res DOCUMENT ME!
690 public void setEndRes(int res)
692 if (res > (alignment.getWidth() - 1))
694 // log.System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));
695 res = alignment.getWidth() - 1;
709 * @param seq DOCUMENT ME!
711 public void setEndSeq(int seq)
713 if (seq > alignment.getHeight())
715 seq = alignment.getHeight();
729 * @return DOCUMENT ME!
731 public int getEndSeq()
739 * @param f DOCUMENT ME!
741 public void setFont(Font f)
745 Container c = new Container();
747 java.awt.FontMetrics fm = c.getFontMetrics(font);
748 setCharHeight(fm.getHeight());
749 setCharWidth(fm.charWidth('M'));
750 validCharWidth = true;
756 * @return DOCUMENT ME!
758 public Font getFont()
766 * @param w DOCUMENT ME!
768 public void setCharWidth(int w)
776 * @return DOCUMENT ME!
778 public int getCharWidth()
786 * @param h DOCUMENT ME!
788 public void setCharHeight(int h)
796 * @return DOCUMENT ME!
798 public int getCharHeight()
806 * @param w DOCUMENT ME!
808 public void setWrappedWidth(int w)
810 this.wrappedWidth = w;
816 * @return DOCUMENT ME!
818 public int getWrappedWidth()
827 * @return DOCUMENT ME!
829 public AlignmentI getAlignment()
837 * @param align DOCUMENT ME!
839 public void setAlignment(AlignmentI align)
841 this.alignment = align;
847 * @param state DOCUMENT ME!
849 public void setWrapAlignment(boolean state)
851 wrapAlignment = state;
857 * @param state DOCUMENT ME!
859 public void setShowText(boolean state)
867 * @param state DOCUMENT ME!
869 public void setRenderGaps(boolean state)
877 * @return DOCUMENT ME!
879 public boolean getColourText()
881 return showColourText;
887 * @param state DOCUMENT ME!
889 public void setColourText(boolean state)
891 showColourText = state;
897 * @param state DOCUMENT ME!
899 public void setShowBoxes(boolean state)
907 * @return DOCUMENT ME!
909 public boolean getWrapAlignment()
911 return wrapAlignment;
917 * @return DOCUMENT ME!
919 public boolean getShowText()
927 * @return DOCUMENT ME!
929 public boolean getShowBoxes()
937 * @return DOCUMENT ME!
939 public char getGapCharacter()
941 return getAlignment().getGapCharacter();
947 * @param gap DOCUMENT ME!
949 public void setGapCharacter(char gap)
951 if (getAlignment() != null)
953 getAlignment().setGapCharacter(gap);
960 * @param thresh DOCUMENT ME!
962 public void setThreshold(int thresh)
970 * @return DOCUMENT ME!
972 public int getThreshold()
980 * @param inc DOCUMENT ME!
982 public void setIncrement(int inc)
990 * @return DOCUMENT ME!
992 public int getIncrement()
1001 * @return DOCUMENT ME!
1003 public ColumnSelection getColumnSelection()
1012 * @param tree DOCUMENT ME!
1014 public void setCurrentTree(NJTree tree)
1022 * @return DOCUMENT ME!
1024 public NJTree getCurrentTree()
1032 * @param b DOCUMENT ME!
1034 public void setColourAppliesToAllGroups(boolean b)
1036 colourAppliesToAllGroups = b;
1042 * @return DOCUMENT ME!
1044 public boolean getColourAppliesToAllGroups()
1046 return colourAppliesToAllGroups;
1052 * @return DOCUMENT ME!
1054 public boolean getShowJVSuffix()
1056 return showJVSuffix;
1062 * @param b DOCUMENT ME!
1064 public void setShowJVSuffix(boolean b)
1073 * @return DOCUMENT ME!
1075 public boolean getShowAnnotation()
1077 return showAnnotation;
1083 * @param b DOCUMENT ME!
1085 public void setShowAnnotation(boolean b)
1093 * @return DOCUMENT ME!
1095 public boolean getScaleAboveWrapped()
1097 return scaleAboveWrapped;
1103 * @return DOCUMENT ME!
1105 public boolean getScaleLeftWrapped()
1107 return scaleLeftWrapped;
1113 * @return DOCUMENT ME!
1115 public boolean getScaleRightWrapped()
1117 return scaleRightWrapped;
1123 * @param b DOCUMENT ME!
1125 public void setScaleAboveWrapped(boolean b)
1127 scaleAboveWrapped = b;
1133 * @param b DOCUMENT ME!
1135 public void setScaleLeftWrapped(boolean b)
1137 scaleLeftWrapped = b;
1143 * @param b DOCUMENT ME!
1145 public void setScaleRightWrapped(boolean b)
1147 scaleRightWrapped = b;
1151 * Property change listener for changes in alignment
1153 * @param listener DOCUMENT ME!
1155 public void addPropertyChangeListener(
1156 java.beans.PropertyChangeListener listener)
1158 changeSupport.addPropertyChangeListener(listener);
1164 * @param listener DOCUMENT ME!
1166 public void removePropertyChangeListener(
1167 java.beans.PropertyChangeListener listener)
1169 changeSupport.removePropertyChangeListener(listener);
1173 * Property change listener for changes in alignment
1175 * @param prop DOCUMENT ME!
1176 * @param oldvalue DOCUMENT ME!
1177 * @param newvalue DOCUMENT ME!
1179 public void firePropertyChange(String prop, Object oldvalue, Object newvalue)
1181 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1184 public void setIgnoreGapsConsensus(boolean b, AlignmentPanel ap)
1186 ignoreGapsInConsensusCalculation = b;
1187 updateConsensus(ap);
1188 if(globalColourScheme!=null)
1190 globalColourScheme.setThreshold(globalColourScheme.getThreshold(), ignoreGapsInConsensusCalculation);
1194 public boolean getIgnoreGapsConsensus()
1196 return ignoreGapsInConsensusCalculation;
1199 public void setDataset(boolean b)
1204 public boolean isDataset()
1210 public void hideSelectedColumns()
1212 if (colSel.size() < 1)
1215 colSel.hideSelectedColumns();
1216 setSelectionGroup(null);
1218 hasHiddenColumns = true;
1222 public void hideColumns(int start, int end)
1225 colSel.hideColumns(start);
1227 colSel.hideColumns(start, end);
1229 hasHiddenColumns = true;
1232 public void hideAllSelectedSeqs()
1234 if (selectionGroup == null)
1237 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1241 setSelectionGroup(null);
1244 public void hideSequence(SequenceI [] seq)
1248 for (int i = 0; i < seq.length; i++)
1249 alignment.getHiddenSequences().hideSequence(seq[i]);
1251 hasHiddenRows = true;
1252 firePropertyChange("alignment", null, alignment.getSequences());
1256 public void showSequence(int index)
1258 Vector tmp = alignment.getHiddenSequences().showSequence(index);
1261 if(selectionGroup==null)
1263 selectionGroup = new SequenceGroup();
1264 selectionGroup.setEndRes(alignment.getWidth()-1);
1267 for (int t = 0; t < tmp.size(); t++)
1269 selectionGroup.addSequence(
1270 (SequenceI) tmp.elementAt(t), false
1273 firePropertyChange("alignment", null, alignment.getSequences());
1276 if(alignment.getHiddenSequences().getSize()<1)
1277 hasHiddenRows = false;
1280 public void showColumn(int col)
1282 colSel.revealHiddenColumns(col);
1283 if(colSel.getHiddenColumns()==null)
1284 hasHiddenColumns = false;
1287 public void showAllHiddenColumns()
1289 colSel.revealAllHiddenColumns();
1290 hasHiddenColumns = false;
1293 public void showAllHiddenSeqs()
1295 if(alignment.getHiddenSequences().getSize()>0)
1297 if(selectionGroup==null)
1299 selectionGroup = new SequenceGroup();
1300 selectionGroup.setEndRes(alignment.getWidth()-1);
1302 Vector tmp = alignment.getHiddenSequences().showAll();
1303 for(int t=0; t<tmp.size(); t++)
1305 selectionGroup.addSequence(
1306 (SequenceI)tmp.elementAt(t), false
1309 firePropertyChange("alignment", null, alignment.getSequences());
1310 hasHiddenRows = false;
1314 public void invertColumnSelection()
1317 for(int i=0; i<alignment.getWidth(); i++)
1321 if(colSel.contains(column))
1322 colSel.removeElement(column);
1324 colSel.addElement(column);
1330 public int adjustForHiddenSeqs(int alignmentIndex)
1332 return alignment.getHiddenSequences().adjustForHiddenSeqs(alignmentIndex);
1336 * This method returns the a new SequenceI [] with
1337 * the selection sequence and start and end points adjusted
1340 public SequenceI[] getSelectionAsNewSequence()
1342 SequenceI[] sequences;
1344 if (selectionGroup == null)
1345 sequences = alignment.getSequencesArray();
1347 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1353 * This method returns the visible alignment as text, as
1354 * seen on the GUI, ie if columns are hidden they will not
1355 * be returned in the result.
1356 * Use this for calculating trees, PCA, redundancy etc on views
1357 * which contain hidden columns.
1360 public jalview.datamodel.CigarArray getViewAsCigars(boolean selectedRegionOnly)
1362 CigarArray selection=null;
1363 SequenceI [] seqs= null;
1365 int start = 0, end = 0;
1366 if(selectedRegionOnly && selectionGroup!=null)
1368 iSize = selectionGroup.getSize(false);
1369 seqs = selectionGroup.getSequencesInOrder(alignment);
1370 start = selectionGroup.getStartRes();
1371 end = selectionGroup.getEndRes(); // inclusive for start and end in SeqCigar constructor
1375 iSize = alignment.getHeight();
1376 seqs = alignment.getSequencesArray();
1377 end = alignment.getWidth()-1;
1379 SeqCigar[] selseqs = new SeqCigar[iSize];
1380 for(i=0; i<iSize; i++)
1382 selseqs[i] = new SeqCigar(seqs[i], start, end);
1384 selection=new CigarArray(selseqs);
1385 // now construct the CigarArray operations
1386 if (hasHiddenColumns) {
1387 Vector regions = colSel.getHiddenColumns();
1389 int hideStart, hideEnd;
1391 for (int j = 0; last<end & j < regions.size(); j++)
1393 region = (int[]) regions.elementAt(j);
1394 hideStart = region[0];
1395 hideEnd = region[1];
1396 // edit hidden regions to selection range
1397 if(hideStart<last) {
1411 if (hideStart>hideEnd)
1414 * form operations...
1417 selection.addOperation(CigarArray.M, hideStart-last);
1418 selection.addOperation(CigarArray.D, 1+hideEnd-hideStart);
1421 // Final match if necessary.
1423 selection.addOperation(CigarArray.M, end-last+1);
1425 selection.addOperation(CigarArray.M, end-start+1);
1430 * return a compact representation of the current alignment selection to
1431 * pass to an analysis function
1432 * @param selectedOnly boolean true to just return the selected view
1433 * @return AlignmentView
1435 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly) {
1437 // this is here because the AlignmentView constructor modifies the CigarArray
1438 // object. Refactoring of Cigar and alignment view representation should
1439 // be done to remove redundancy.
1440 CigarArray aligview = getViewAsCigars(selectedOnly);
1441 if (aligview!=null) {
1442 return new AlignmentView(aligview,
1443 (selectedOnly && selectionGroup!=null) ? selectionGroup.getStartRes() : 0);
1448 * This method returns the visible alignment as text, as
1449 * seen on the GUI, ie if columns are hidden they will not
1450 * be returned in the result.
1451 * Use this for calculating trees, PCA, redundancy etc on views
1452 * which contain hidden columns.
1455 public String [] getViewAsString(boolean selectedRegionOnly)
1457 String [] selection = null;
1458 SequenceI [] seqs= null;
1460 int start = 0, end = 0;
1461 if(selectedRegionOnly && selectionGroup!=null)
1463 iSize = selectionGroup.getSize(false);
1464 seqs = selectionGroup.getSequencesInOrder(alignment);
1465 start = selectionGroup.getStartRes();
1466 end = selectionGroup.getEndRes()+1;
1470 iSize = alignment.getHeight();
1471 seqs = alignment.getSequencesArray();
1472 end = alignment.getWidth();
1475 selection = new String[iSize];
1476 if (hasHiddenColumns) {
1477 selection = colSel.getVisibleSequenceStrings(start, end, seqs);
1479 for(i=0; i<iSize; i++)
1481 selection[i] = seqs[i].getSequence(start, end);
1488 public boolean getShowHiddenMarkers()
1490 return showHiddenMarkers;
1493 public void setShowHiddenMarkers(boolean show)
1495 showHiddenMarkers = show;
1498 public String getSequenceSetId()
1500 if(sequenceSetID==null)
1501 sequenceSetID = alignment.hashCode()+"";
1503 return sequenceSetID;