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