Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 16:11:35 GMT
  2. Package jalview.api

File AlignViewportI.java

 

Code metrics

0
0
0
1
637
148
0
-
-
0
-

Classes

Class Line # Actions
AlignViewportI 54 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

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 java.awt.Color;
24    import java.awt.Font;
25    import java.util.Hashtable;
26    import java.util.Iterator;
27    import java.util.List;
28    import java.util.Map;
29   
30    import jalview.analysis.AlignmentUtils;
31    import jalview.analysis.Conservation;
32    import jalview.analysis.TreeModel;
33    import jalview.datamodel.AlignmentAnnotation;
34    import jalview.datamodel.AlignmentExportData;
35    import jalview.datamodel.AlignmentI;
36    import jalview.datamodel.AlignmentView;
37    import jalview.datamodel.ColumnSelection;
38    import jalview.datamodel.ContactListI;
39    import jalview.datamodel.ContactMatrixI;
40    import jalview.datamodel.ProfilesI;
41    import jalview.datamodel.SearchResultsI;
42    import jalview.datamodel.SequenceCollectionI;
43    import jalview.datamodel.SequenceGroup;
44    import jalview.datamodel.SequenceI;
45    import jalview.renderer.ResidueShaderI;
46    import jalview.schemes.ColourSchemeI;
47    import jalview.util.Constants;
48    import jalview.viewmodel.ViewportRanges;
49   
50    /**
51    * @author jimp
52    *
53    */
 
54    public interface AlignViewportI extends ViewStyleI
55    {
56   
57    /**
58    * Get the ranges object containing details of the start and end sequences and
59    * residues
60    *
61    * @return
62    */
63    ViewportRanges getRanges();
64   
65    /**
66    * calculate the height for visible annotation, revalidating bounds where
67    * necessary ABSTRACT GUI METHOD
68    *
69    * @return total height of annotation
70    */
71    int calcPanelHeight();
72   
73    /**
74    * Answers true if the viewport has at least one column selected
75    *
76    * @return
77    */
78    boolean hasSelectedColumns();
79   
80    /**
81    * Answers true if the viewport has at least one hidden column
82    *
83    * @return
84    */
85    boolean hasHiddenColumns();
86   
87    boolean isValidCharWidth();
88   
89    boolean isShowConsensusHistogram();
90   
91    boolean isShowSequenceLogo();
92   
93    boolean isNormaliseSequenceLogo();
94   
95    boolean isShowInformationHistogram();
96   
97    boolean isShowHMMSequenceLogo();
98   
99    boolean isNormaliseHMMSequenceLogo();
100   
101    ColourSchemeI getGlobalColourScheme();
102   
103    /**
104    * Returns an object that describes colouring (including any thresholding or
105    * fading) of the alignment
106    *
107    * @return
108    */
109    ResidueShaderI getResidueShading();
110   
111    AlignmentI getAlignment();
112   
113    ColumnSelection getColumnSelection();
114   
115    ProfilesI getSequenceConsensusHash();
116   
117    /**
118    * Get consensus data table for the cDNA complement of this alignment (if any)
119    *
120    * @return
121    */
122    Hashtable<String, Object>[] getComplementConsensusHash();
123   
124    Hashtable<String, Object>[] getRnaStructureConsensusHash();
125   
126    boolean isIgnoreGapsConsensus();
127   
128    boolean isIgnoreBelowBackground();
129   
130    boolean isCalculationInProgress(AlignmentAnnotation alignmentAnnotation);
131   
132    AlignmentAnnotation getAlignmentQualityAnnot();
133   
134    AlignmentAnnotation getAlignmentConservationAnnotation();
135   
136    /**
137    * get the container for alignment consensus annotation
138    *
139    * @return
140    */
141    AlignmentAnnotation getAlignmentConsensusAnnotation();
142   
143    List<AlignmentAnnotation> getAlignmentSecondaryStructureConsensusAnnotation();
144   
145    /**
146    * get the container for alignment gap annotation
147    *
148    * @return
149    */
150    AlignmentAnnotation getAlignmentGapAnnotation();
151   
152    /**
153    * get the container for cDNA complement consensus annotation
154    *
155    * @return
156    */
157    AlignmentAnnotation getComplementConsensusAnnotation();
158   
159    /**
160    * Test to see if viewport is still open and active
161    *
162    * @return true indicates that all references to viewport should be dropped
163    */
164    boolean isClosed();
165   
166    /**
167    * Dispose of all references or resources held by the viewport
168    */
169    void dispose();
170   
171    /**
172    * get the associated calculation thread manager for the view
173    *
174    * @return
175    */
176    AlignCalcManagerI2 getCalcManager();
177   
178    /**
179    * get the percentage gaps allowed in a conservation calculation
180    *
181    */
182    public int getConsPercGaps();
183   
184    /**
185    * set the consensus result object for the viewport
186    *
187    * @param hconsensus
188    */
189    void setSequenceConsensusHash(ProfilesI hconsensus);
190   
191    void setSequenceSSConsensusHash(
192    Map<String, ProfilesI> hSSConsesnusProfileMap);
193   
194    /**
195    * Set the cDNA complement consensus for the viewport
196    *
197    * @param hconsensus
198    */
199    void setComplementConsensusHash(Hashtable<String, Object>[] hconsensus);
200   
201    /**
202    *
203    * @return the alignment annotation row for the structure consensus
204    * calculation
205    */
206    AlignmentAnnotation getAlignmentStrucConsensusAnnotation();
207   
208    /**
209    * set the Rna structure consensus result object for the viewport
210    *
211    * @param hStrucConsensus
212    */
213    void setRnaStructureConsensusHash(
214    Hashtable<String, Object>[] hStrucConsensus);
215   
216    /**
217    * Sets the colour scheme for the background alignment (as distinct from
218    * sub-groups, which may have their own colour schemes). A null value is used
219    * for no residue colour (white).
220    *
221    * @param cs
222    */
223    void setGlobalColourScheme(ColourSchemeI cs);
224   
225    Map<SequenceI, SequenceCollectionI> getHiddenRepSequences();
226   
227    void setHiddenRepSequences(
228    Map<SequenceI, SequenceCollectionI> hiddenRepSequences);
229   
230    /**
231    * hides or shows dynamic annotation rows based on groups and group and
232    * alignment associated auto-annotation state flags apply the current
233    * group/autoannotation settings to the alignment view. Usually you should
234    * call the AlignmentViewPanel.adjustAnnotationHeight() method afterwards to
235    * ensure the annotation panel bounds are set correctly.
236    *
237    * @param applyGlobalSettings
238    * - apply to all autoannotation rows or just the ones associated
239    * with the current visible region
240    * @param preserveNewGroupSettings
241    * - don't apply global settings to groups which don't already have
242    * group associated annotation
243    */
244    void updateGroupAnnotationSettings(boolean applyGlobalSettings,
245    boolean preserveNewGroupSettings);
246   
247    void setSequenceColour(SequenceI seq, Color col);
248   
249    Color getSequenceColour(SequenceI seq);
250   
251    void updateSequenceIdColours();
252   
253    SequenceGroup getSelectionGroup();
254   
255    /**
256    * get the currently selected sequence objects or all the sequences in the
257    * alignment. TODO: change to List<>
258    *
259    * @return array of references to sequence objects
260    */
261    SequenceI[] getSequenceSelection();
262   
263    void clearSequenceColours();
264   
265    /**
266    * return a compact representation of the current alignment selection to pass
267    * to an analysis function
268    *
269    * @param selectedOnly
270    * boolean true to just return the selected view
271    * @return AlignmentView
272    */
273    AlignmentView getAlignmentView(boolean selectedOnly);
274   
275    /**
276    * return a compact representation of the current alignment selection to pass
277    * to an analysis function
278    *
279    * @param selectedOnly
280    * boolean true to just return the selected view
281    * @param markGroups
282    * boolean true to annotate the alignment view with groups on the
283    * alignment (and intersecting with selected region if selectedOnly
284    * is true)
285    * @return AlignmentView
286    */
287    AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups);
288   
289    /**
290    * This method returns the visible alignment as text, as seen on the GUI, ie
291    * if columns are hidden they will not be returned in the result. Use this for
292    * calculating trees, PCA, redundancy etc on views which contain hidden
293    * columns. This method doesn't exclude hidden sequences from the output.
294    *
295    * @param selectedRegionOnly
296    * - determines if only the selected region or entire alignment is
297    * exported
298    * @return String[]
299    */
300    String[] getViewAsString(boolean selectedRegionOnly);
301   
302    /**
303    * This method returns the visible alignment as text, as seen on the GUI, ie
304    * if columns are hidden they will not be returned in the result. Use this for
305    * calculating trees, PCA, redundancy etc on views which contain hidden
306    * columns.
307    *
308    * @param selectedRegionOnly
309    * - determines if only the selected region or entire alignment is
310    * exported
311    * @param isExportHiddenSeqs
312    * - determines if hidden sequences would be exported or not.
313    *
314    * @return String[]
315    */
316    String[] getViewAsString(boolean selectedRegionOnly,
317    boolean isExportHiddenSeqs);
318   
319    void setSelectionGroup(SequenceGroup sg);
320   
321    char getGapCharacter();
322   
323    void setColumnSelection(ColumnSelection cs);
324   
325    void setConservation(Conservation cons);
326   
327    /**
328    * get a copy of the currently visible alignment annotation
329    *
330    * @param selectedOnly
331    * if true - trim to selected regions on the alignment
332    * @return an empty list or new alignment annotation objects shown only
333    * visible columns trimmed to selected region only
334    */
335    List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
336    boolean selectedOnly);
337   
338    FeaturesDisplayedI getFeaturesDisplayed();
339   
340    String getSequenceSetId();
341   
342    boolean areFeaturesDisplayed();
343   
344    void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI);
345   
346    void alignmentChanged(AlignmentViewPanel ap);
347   
348    /**
349    * @return the padGaps
350    */
351    boolean isPadGaps();
352   
353    /**
354    * @param padGaps
355    * the padGaps to set
356    */
357    void setPadGaps(boolean padGaps);
358   
359    /**
360    * return visible region boundaries within given column range
361    *
362    * @param min
363    * first column (inclusive, from 0)
364    * @param max
365    * last column (exclusive)
366    * @return int[][] range of {start,end} visible positions
367    */
368    List<int[]> getVisibleRegionBoundaries(int min, int max);
369   
370    /**
371    * This method returns an array of new SequenceI objects derived from the
372    * whole alignment or just the current selection with start and end points
373    * adjusted
374    *
375    * @note if you need references to the actual SequenceI objects in the
376    * alignment or currently selected then use getSequenceSelection()
377    * @return selection as new sequenceI objects
378    */
379    SequenceI[] getSelectionAsNewSequence();
380   
381    void invertColumnSelection();
382   
383    /**
384    * broadcast selection to any interested parties
385    */
386    void sendSelection();
387   
388    /**
389    * calculate the row position for alignmentIndex if all hidden sequences were
390    * shown
391    *
392    * @param alignmentIndex
393    * @return adjusted row position
394    */
395    int adjustForHiddenSeqs(int alignmentIndex);
396   
397    boolean hasHiddenRows();
398   
399    /**
400    *
401    * @return a copy of this view's current display settings
402    */
403    public ViewStyleI getViewStyle();
404   
405    /**
406    * update the view's display settings with the given style set
407    *
408    * @param settingsForView
409    */
410    public void setViewStyle(ViewStyleI settingsForView);
411   
412    /**
413    * Returns a viewport which holds the cDna for this (protein), or vice versa,
414    * or null if none is set.
415    *
416    * @return
417    */
418    AlignViewportI getCodingComplement();
419   
420    /**
421    * Sets the viewport which holds the cDna for this (protein), or vice versa.
422    * Implementation should guarantee that the reciprocal relationship is always
423    * set, i.e. each viewport is the complement of the other.
424    */
425    void setCodingComplement(AlignViewportI sl);
426   
427    /**
428    * Answers true if viewport hosts DNA/RNA, else false.
429    *
430    * @return
431    */
432    boolean isNucleotide();
433   
434    /**
435    * Returns an id guaranteed to be unique for this viewport.
436    *
437    * @return
438    */
439    String getViewId();
440   
441    /**
442    * Return true if view should scroll to show the highlighted region of a
443    * sequence
444    *
445    * @return
446    */
447    boolean isFollowHighlight();
448   
449    /**
450    * Set whether view should scroll to show the highlighted region of a sequence
451    */
452    void setFollowHighlight(boolean b);
453   
454    /**
455    * configure the feature renderer with predefined feature settings
456    *
457    * @param featureSettings
458    */
459    public void applyFeaturesStyle(FeatureSettingsModelI featureSettings);
460   
461    /**
462    * Apply the given feature settings on top of existing feature settings.
463    */
464    public void mergeFeaturesStyle(FeatureSettingsModelI featureSettings);
465   
466    /**
467    * check if current selection group is defined on the view, or is simply a
468    * temporary group.
469    *
470    * @return true if group is defined on the alignment
471    */
472    boolean isSelectionDefinedGroup();
473   
474    /**
475    *
476    * @return true if there are search results on the view
477    */
478    boolean hasSearchResults();
479   
480    /**
481    * set the search results for the view
482    *
483    * @param results
484    * - or null to clear current results
485    */
486    void setSearchResults(SearchResultsI results);
487   
488    /**
489    * get search results for this view (if any)
490    *
491    * @return search results or null
492    */
493    SearchResultsI getSearchResults();
494   
495    /**
496    * Retrieve a ContactListI corresponding to column in an annotation row in an
497    * alignment.
498    *
499    * @param _aa
500    * - annotation with associated matrix data
501    * @param column
502    * - column in alignment where _aa is associated
503    */
504    ContactListI getContactList(AlignmentAnnotation _aa, int column);
505   
506    /**
507    * Updates view settings with the given font. You may need to call
508    * AlignmentPanel.fontChanged to update the layout geometry.
509    *
510    * @param setGrid
511    * when true, charWidth/height is set according to font metrics
512    */
513    void setFont(Font newFont, boolean b);
514   
515    /**
516    * Answers true if split screen protein and cDNA use the same font
517    *
518    * @return
519    */
520    @Override
521    boolean isProteinFontAsCdna();
522   
523    /**
524    * Set the flag for whether split screen protein and cDNA use the same font
525    *
526    * @return
527    */
528    @Override
529    void setProteinFontAsCdna(boolean b);
530   
531    void setHmmProfiles(ProfilesI info);
532   
533    ProfilesI getHmmProfiles();
534   
535    /**
536    * Registers and starts a worker thread to calculate Information Content
537    * annotation, if it is not already registered
538    *
539    * @param ap
540    */
541    void initInformationWorker(AlignmentViewPanel ap);
542   
543    boolean isInfoLetterHeight();
544   
545    public abstract TreeModel getCurrentTree();
546   
547    /**
548    * Answers a data bean containing data for export as configured by the
549    * supplied options
550    *
551    * @param options
552    * @return
553    */
554    AlignmentExportData getAlignExportData(AlignExportSettingsI options);
555   
556    public abstract void setCurrentTree(TreeModel tree);
557   
558    /**
559    * @param update
560    * - set the flag for updating structures on next repaint
561    */
562    void setUpdateStructures(boolean update);
563   
564    /**
565    *
566    * @return true if structure views will be updated on next refresh
567    */
568    boolean isUpdateStructures();
569   
570    /**
571    * check if structure views need to be updated, and clear the flag afterwards.
572    *
573    * @return if an update is needed
574    */
575    boolean needToUpdateStructureViews();
576   
577    /**
578    * Adds sequencegroup to the alignment in the view. Also adds a group to the
579    * complement view if one is defined.
580    *
581    * @param sequenceGroup
582    * - a group defined on sequences in the alignment held by the view
583    */
584    void addSequenceGroup(SequenceGroup sequenceGroup);
585   
586    /**
587    * Returns an interator over the [start, end] column positions of the visible
588    * regions of the alignment
589    *
590    * @param selectedRegionOnly
591    * if true, and the view has a selection region, then only the
592    * intersection of visible columns with the selection region is
593    * returned
594    * @return
595    */
596    Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly);
597   
598    /**
599    * notify all concerned that the alignment data has changed and derived data
600    * needs to be recalculated
601    */
602    public void notifyAlignmentChanged();
603   
604    /**
605    * retrieve a matrix associated with the view's alignment's annotation
606    *
607    * @param alignmentAnnotation
608    * @return contact matrix or NULL
609    */
610    ContactMatrixI getContactMatrix(AlignmentAnnotation alignmentAnnotation);
611   
612    Map<String, ProfilesI> getSequenceSSConsensusHash();
613   
614    List<String> getSecondaryStructureSources();
615   
616    void setSecondaryStructureSources(List<String> secondaryStructureSources);
617   
618    Color getAnnotationColour(AlignmentAnnotation annot);
619   
620    void setAnnotationColour(AlignmentAnnotation annot, Color col);
621   
622    void updateAnnotationColours();
623   
624    void clearAnnotationColours();
625   
626    Map<AlignmentAnnotation, Color> getAnnotationColours();
627   
628    void setAnnotationColours(
629    Map<AlignmentAnnotation, Color> annotationColours);
630   
631    /**
632    * Get the Consensus annotation for the alignment
633    *
634    * @return
635    */
636    public void setSecondaryStructureSources();
637    }