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