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