Clover icon

Coverage Report

  1. Project Clover database Fri Dec 6 2024 13:47:14 GMT
  2. Package jalview.workers

File ConservationThread.java

 

Coverage histogram

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

Code metrics

14
40
4
1
147
101
24
0.6
10
4
6

Classes

Class Line # Actions
ConservationThread 32 40 24
0.758620775.9%
 

Contributing tests

This file is covered by 164 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  448 toggle public ConservationThread(AlignViewportI alignViewport,
39    AlignmentViewPanel alignPanel)
40    {
41  448 super(alignViewport, alignPanel);
42  448 ConsPercGaps = alignViewport.getConsPercGaps();
43    }
44   
45    private Conservation cons;
46   
47    AlignmentAnnotation conservation, quality;
48   
49    int alWidth;
50   
 
51  1039 toggle @Override
52    public void run()
53    {
54  1039 try
55    {
56  1039 calcMan.notifyStart(this); // updatingConservation = true;
57   
58  1253 while ((calcMan != null) && (!calcMan.notifyWorking(this)))
59    {
60  214 try
61    {
62  214 if (ap != null)
63    {
64    // ap.paintAlignment(false);
65    }
66  214 Thread.sleep(200);
67    } catch (Exception ex)
68    {
69  0 ex.printStackTrace();
70    }
71    }
72  1039 if ((alignViewport == null) || (calcMan == null)
73    || (alignViewport.isClosed()))
74    {
75  23 abortAndDestroy();
76  23 return;
77    }
78  1016 List<AlignmentAnnotation> ourAnnot = new ArrayList<>();
79  1016 AlignmentI alignment = alignViewport.getAlignment();
80  1016 conservation = alignViewport.getAlignmentConservationAnnotation();
81  1016 quality = alignViewport.getAlignmentQualityAnnot();
82  1016 ourAnnot.add(conservation);
83  1016 ourAnnot.add(quality);
84  1016 ourAnnots = ourAnnot;
85  1016 ConsPercGaps = alignViewport.getConsPercGaps();
86    // AlignViewport.UPDATING_CONSERVATION = true;
87   
88  ? if (alignment == null || (alWidth = alignment.getWidth()) < 0)
89    {
90  0 calcMan.workerComplete(this);
91    // .updatingConservation = false;
92    // AlignViewport.UPDATING_CONSERVATION = false;
93   
94  0 return;
95    }
96  1016 try
97    {
98  1016 cons = Conservation.calculateConservation("All",
99    alignment.getSequences(), 0, alWidth - 1, false,
100    ConsPercGaps, quality != null);
101    } catch (IndexOutOfBoundsException x)
102    {
103    // probable race condition. just finish and return without any fuss.
104  0 calcMan.workerComplete(this);
105  0 return;
106    }
107  1016 updateResultAnnotation(true);
108    } catch (OutOfMemoryError error)
109    {
110  0 ap.raiseOOMWarning("calculating conservation", error);
111  0 calcMan.disableWorker(this);
112    // alignViewport.conservation = null;
113    // this.alignViewport.quality = null;
114   
115    }
116  1016 calcMan.workerComplete(this);
117   
118  1016 if ((alignViewport == null) || (calcMan == null)
119    || (alignViewport.isClosed()))
120    {
121  11 abortAndDestroy();
122  11 return;
123    }
124  1005 if (ap != null)
125    {
126  1005 ap.paintAlignment(true, true);
127    }
128   
129    }
130   
 
131  1016 toggle private void updateResultAnnotation(boolean b)
132    {
133  1016 if (b || !calcMan.isWorking(this) && cons != null
134    && conservation != null && quality != null)
135    {
136  1016 alignViewport.setConservation(cons);
137  1016 cons.completeAnnotations(conservation, quality, 0, alWidth);
138    }
139    }
140   
 
141  0 toggle @Override
142    public void updateAnnotation()
143    {
144  0 updateResultAnnotation(false);
145   
146    }
147    }