Clover icon

Coverage Report

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

File ConservationThread.java

 

Coverage histogram

../../img/srcFileCovDistChart8.png
20% of files have more coverage

Code metrics

10
28
4
1
117
77
19
0.68
7
4
4.75

Classes

Class Line # Actions
ConservationThread 32 28 19
0.7142857371.4%
 

Contributing tests

This file is covered by 195 tests. .

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.workers;
22   
23    import jalview.analysis.Conservation;
24    import jalview.api.AlignViewportI;
25    import jalview.api.AlignmentViewPanel;
26    import jalview.datamodel.AlignmentAnnotation;
27    import jalview.datamodel.AlignmentI;
28   
29    import java.util.ArrayList;
30    import java.util.List;
31   
 
32    public class ConservationThread extends AlignCalcWorker
33    {
34   
35    private int ConsPercGaps = 25; // JBPNote : This should be a configurable
36    // property!
37   
 
38  401 toggle public ConservationThread(AlignViewportI alignViewport,
39    AlignmentViewPanel alignPanel)
40    {
41  401 super(alignViewport, alignPanel);
42  401 ConsPercGaps = alignViewport.getConsPercGaps();
43    }
44   
45    private Conservation cons;
46   
47    AlignmentAnnotation conservation, quality;
48   
49    int alWidth;
50   
 
51  863 toggle @Override
52    public void run()
53    {
54  863 if ((alignViewport == null) || (calcMan == null)
55    || (alignViewport.isClosed()))
56    {
57  0 abortAndDestroy();
58  0 return;
59    }
60  863 List<AlignmentAnnotation> ourAnnot = new ArrayList<>();
61  863 AlignmentI alignment = alignViewport.getAlignment();
62  863 conservation = alignViewport.getAlignmentConservationAnnotation();
63  863 quality = alignViewport.getAlignmentQualityAnnot();
64  863 ourAnnot.add(conservation);
65  863 ourAnnot.add(quality);
66  863 ourAnnots = ourAnnot;
67  863 ConsPercGaps = alignViewport.getConsPercGaps();
68    // AlignViewport.UPDATING_CONSERVATION = true;
69   
70  ? if (alignment == null || (alWidth = alignment.getWidth()) < 0)
71    {
72    // .updatingConservation = false;
73    // AlignViewport.UPDATING_CONSERVATION = false;
74  0 return;
75    }
76  863 try
77    {
78  863 cons = Conservation.calculateConservation("All",
79    alignment.getSequences(), 0, alWidth - 1, false,
80    ConsPercGaps, quality != null);
81    } catch (IndexOutOfBoundsException x)
82    {
83    // probable race condition. just finish and return without any fuss.
84  0 return;
85    }
86  861 updateResultAnnotation(true);
87   
88  859 if ((alignViewport == null) || (calcMan == null)
89    || (alignViewport.isClosed()))
90    {
91  6 abortAndDestroy();
92  0 return;
93    }
94  853 if (ap != null)
95    {
96  853 ap.paintAlignment(true, true);
97    }
98   
99    }
100   
 
101  861 toggle private void updateResultAnnotation(boolean b)
102    {
103  861 if (b || !calcMan.isWorking(this) && cons != null
104    && conservation != null && quality != null)
105    {
106  861 alignViewport.setConservation(cons);
107  861 cons.completeAnnotations(conservation, quality, 0, alWidth);
108    }
109    }
110   
 
111  0 toggle @Override
112    public void updateAnnotation()
113    {
114  0 updateResultAnnotation(false);
115   
116    }
117    }