JAL-2089 patch broken merge to master for Release 2.10.0b1
[jalview.git] / src / jalview / api / AlignViewportI.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.api;
22
23 import jalview.analysis.Conservation;
24 import jalview.datamodel.AlignmentAnnotation;
25 import jalview.datamodel.AlignmentI;
26 import jalview.datamodel.AlignmentView;
27 import jalview.datamodel.CigarArray;
28 import jalview.datamodel.ColumnSelection;
29 import jalview.datamodel.SequenceCollectionI;
30 import jalview.datamodel.SequenceGroup;
31 import jalview.datamodel.SequenceI;
32 import jalview.schemes.ColourSchemeI;
33
34 import java.awt.Color;
35 import java.util.Hashtable;
36 import java.util.List;
37 import java.util.Map;
38
39 /**
40  * @author jimp
41  * 
42  */
43 public interface AlignViewportI extends ViewStyleI
44 {
45
46   int getEndRes();
47
48   /**
49    * calculate the height for visible annotation, revalidating bounds where
50    * necessary ABSTRACT GUI METHOD
51    * 
52    * @return total height of annotation
53    */
54   public int calcPanelHeight();
55
56   /**
57    * Answers true if the viewport has at least one column selected
58    * 
59    * @return
60    */
61   boolean hasSelectedColumns();
62
63   /**
64    * Answers true if the viewport has at least one hidden column
65    * 
66    * @return
67    */
68   boolean hasHiddenColumns();
69
70   boolean isValidCharWidth();
71
72   boolean isShowConsensusHistogram();
73
74   boolean isShowSequenceLogo();
75
76   boolean isNormaliseSequenceLogo();
77
78   ColourSchemeI getGlobalColourScheme();
79
80   AlignmentI getAlignment();
81
82   ColumnSelection getColumnSelection();
83
84   Hashtable[] getSequenceConsensusHash();
85
86   /**
87    * Get consensus data table for the cDNA complement of this alignment (if any)
88    * 
89    * @return
90    */
91   Hashtable[] getComplementConsensusHash();
92
93   Hashtable[] getRnaStructureConsensusHash();
94
95   boolean isIgnoreGapsConsensus();
96
97   boolean isCalculationInProgress(AlignmentAnnotation alignmentAnnotation);
98
99   AlignmentAnnotation getAlignmentQualityAnnot();
100
101   AlignmentAnnotation getAlignmentConservationAnnotation();
102
103   /**
104    * get the container for alignment consensus annotation
105    * 
106    * @return
107    */
108   AlignmentAnnotation getAlignmentConsensusAnnotation();
109
110   /**
111    * get the container for cDNA complement consensus annotation
112    * 
113    * @return
114    */
115   AlignmentAnnotation getComplementConsensusAnnotation();
116
117   /**
118    * Test to see if viewport is still open and active
119    * 
120    * @return true indicates that all references to viewport should be dropped
121    */
122   boolean isClosed();
123
124   /**
125    * Dispose of all references or resources held by the viewport
126    */
127   void dispose();
128
129   /**
130    * get the associated calculation thread manager for the view
131    * 
132    * @return
133    */
134   AlignCalcManagerI getCalcManager();
135
136   /**
137    * get the percentage gaps allowed in a conservation calculation
138    * 
139    */
140   public int getConsPercGaps();
141
142   /**
143    * set the consensus result object for the viewport
144    * 
145    * @param hconsensus
146    */
147   void setSequenceConsensusHash(Hashtable[] hconsensus);
148
149   /**
150    * Set the cDNA complement consensus for the viewport
151    * 
152    * @param hconsensus
153    */
154   void setComplementConsensusHash(Hashtable[] hconsensus);
155
156   /**
157    * 
158    * @return the alignment annotatino row for the structure consensus
159    *         calculation
160    */
161   AlignmentAnnotation getAlignmentStrucConsensusAnnotation();
162
163   /**
164    * set the Rna structure consensus result object for the viewport
165    * 
166    * @param hStrucConsensus
167    */
168   void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus);
169
170   /**
171    * set global colourscheme
172    * 
173    * @param rhc
174    */
175   void setGlobalColourScheme(ColourSchemeI rhc);
176
177   Map<SequenceI, SequenceCollectionI> getHiddenRepSequences();
178
179   void setHiddenRepSequences(
180           Map<SequenceI, SequenceCollectionI> hiddenRepSequences);
181
182   /**
183    * hides or shows dynamic annotation rows based on groups and group and
184    * alignment associated auto-annotation state flags apply the current
185    * group/autoannotation settings to the alignment view. Usually you should
186    * call the AlignmentViewPanel.adjustAnnotationHeight() method afterwards to
187    * ensure the annotation panel bounds are set correctly.
188    * 
189    * @param applyGlobalSettings
190    *          - apply to all autoannotation rows or just the ones associated
191    *          with the current visible region
192    * @param preserveNewGroupSettings
193    *          - don't apply global settings to groups which don't already have
194    *          group associated annotation
195    */
196   void updateGroupAnnotationSettings(boolean applyGlobalSettings,
197           boolean preserveNewGroupSettings);
198
199   void setSequenceColour(SequenceI seq, Color col);
200
201   Color getSequenceColour(SequenceI seq);
202
203   void updateSequenceIdColours();
204
205   SequenceGroup getSelectionGroup();
206
207   /**
208    * get the currently selected sequence objects or all the sequences in the
209    * alignment. TODO: change to List<>
210    * 
211    * @return array of references to sequence objects
212    */
213   SequenceI[] getSequenceSelection();
214
215   void clearSequenceColours();
216
217   /**
218    * This method returns the visible alignment as text, as seen on the GUI, ie
219    * if columns are hidden they will not be returned in the result. Use this for
220    * calculating trees, PCA, redundancy etc on views which contain hidden
221    * columns.
222    * 
223    * @return String[]
224    */
225   CigarArray getViewAsCigars(boolean selectedRegionOnly);
226
227   /**
228    * return a compact representation of the current alignment selection to pass
229    * to an analysis function
230    * 
231    * @param selectedOnly
232    *          boolean true to just return the selected view
233    * @return AlignmentView
234    */
235   AlignmentView getAlignmentView(boolean selectedOnly);
236
237   /**
238    * return a compact representation of the current alignment selection to pass
239    * to an analysis function
240    * 
241    * @param selectedOnly
242    *          boolean true to just return the selected view
243    * @param markGroups
244    *          boolean true to annotate the alignment view with groups on the
245    *          alignment (and intersecting with selected region if selectedOnly
246    *          is true)
247    * @return AlignmentView
248    */
249   AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups);
250
251   /**
252    * This method returns the visible alignment as text, as seen on the GUI, ie
253    * if columns are hidden they will not be returned in the result. Use this for
254    * calculating trees, PCA, redundancy etc on views which contain hidden
255    * columns. This method doesn't exclude hidden sequences from the output.
256    *
257    * @param selectedRegionOnly
258    *          - determines if only the selected region or entire alignment is
259    *          exported
260    * @return String[]
261    */
262   String[] getViewAsString(boolean selectedRegionOnly);
263
264   /**
265    * This method returns the visible alignment as text, as seen on the GUI, ie
266    * if columns are hidden they will not be returned in the result. Use this for
267    * calculating trees, PCA, redundancy etc on views which contain hidden
268    * columns.
269    * 
270    * @param selectedRegionOnly
271    *          - determines if only the selected region or entire alignment is
272    *          exported
273    * @param isExportHiddenSeqs
274    *          - determines if hidden sequences would be exported or not.
275    * 
276    * @return String[]
277    */
278   String[] getViewAsString(boolean selectedRegionOnly,
279           boolean isExportHiddenSeqs);
280
281   void setSelectionGroup(SequenceGroup sg);
282
283   char getGapCharacter();
284
285   void setColumnSelection(ColumnSelection cs);
286
287   void setConservation(Conservation cons);
288
289   /**
290    * get a copy of the currently visible alignment annotation
291    * 
292    * @param selectedOnly
293    *          if true - trim to selected regions on the alignment
294    * @return an empty list or new alignment annotation objects shown only
295    *         visible columns trimmed to selected region only
296    */
297   List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
298           boolean selectedOnly);
299
300   FeaturesDisplayedI getFeaturesDisplayed();
301
302   String getSequenceSetId();
303
304   boolean areFeaturesDisplayed();
305
306   void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI);
307
308   void alignmentChanged(AlignmentViewPanel ap);
309
310   /**
311    * @return the padGaps
312    */
313   boolean isPadGaps();
314
315   /**
316    * @param padGaps
317    *          the padGaps to set
318    */
319   void setPadGaps(boolean padGaps);
320
321   /**
322    * return visible region boundaries within given column range
323    * 
324    * @param min
325    *          first column (inclusive, from 0)
326    * @param max
327    *          last column (exclusive)
328    * @return int[][] range of {start,end} visible positions
329    */
330   List<int[]> getVisibleRegionBoundaries(int min, int max);
331
332   /**
333    * This method returns an array of new SequenceI objects derived from the
334    * whole alignment or just the current selection with start and end points
335    * adjusted
336    * 
337    * @note if you need references to the actual SequenceI objects in the
338    *       alignment or currently selected then use getSequenceSelection()
339    * @return selection as new sequenceI objects
340    */
341   SequenceI[] getSelectionAsNewSequence();
342
343   void invertColumnSelection();
344
345   /**
346    * broadcast selection to any interested parties
347    */
348   void sendSelection();
349
350   /**
351    * calculate the row position for alignmentIndex if all hidden sequences were
352    * shown
353    * 
354    * @param alignmentIndex
355    * @return adjusted row position
356    */
357   int adjustForHiddenSeqs(int alignmentIndex);
358
359   boolean hasHiddenRows();
360
361   /**
362    * 
363    * @return a copy of this view's current display settings
364    */
365   public ViewStyleI getViewStyle();
366
367   /**
368    * update the view's display settings with the given style set
369    * 
370    * @param settingsForView
371    */
372   public void setViewStyle(ViewStyleI settingsForView);
373
374   /**
375    * Returns a viewport which holds the cDna for this (protein), or vice versa,
376    * or null if none is set.
377    * 
378    * @return
379    */
380   AlignViewportI getCodingComplement();
381
382   /**
383    * Sets the viewport which holds the cDna for this (protein), or vice versa.
384    * Implementation should guarantee that the reciprocal relationship is always
385    * set, i.e. each viewport is the complement of the other.
386    */
387   void setCodingComplement(AlignViewportI sl);
388
389   /**
390    * Answers true if viewport hosts DNA/RNA, else false.
391    * 
392    * @return
393    */
394   boolean isNucleotide();
395
396   /**
397    * Returns an id guaranteed to be unique for this viewport.
398    * 
399    * @return
400    */
401   String getViewId();
402
403   /**
404    * Return true if view should scroll to show the highlighted region of a
405    * sequence
406    * 
407    * @return
408    */
409   boolean isFollowHighlight();
410
411   /**
412    * Set whether view should scroll to show the highlighted region of a sequence
413    */
414   void setFollowHighlight(boolean b);
415
416   public void applyFeaturesStyle(FeatureSettingsModelI featureSettings);
417
418   /**
419    * check if current selection group is defined on the view, or is simply a
420    * temporary group.
421    * 
422    * @return true if group is defined on the alignment
423    */
424   boolean isSelectionDefinedGroup();
425 }