Clover icon

Coverage Report

  1. Project Clover database Wed Jan 7 2026 02:39:37 GMT
  2. Package jalview.workers

File ConservationThread.java

 

Coverage histogram

../../img/srcFileCovDistChart7.png
30% of files have more coverage

Code metrics

12
28
4
1
119
78
20
0.71
7
4
5

Classes

Class Line # Actions
ConservationThread 33 28 20
0.7045454470.5%
 

Contributing tests

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