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