Clover icon

Coverage Report

  1. Project Clover database Mon Nov 18 2024 09:56:54 GMT
  2. Package jalview.workers

File ConservationThread.java

 

Coverage histogram

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

Code metrics

16
40
4
1
149
102
25
0.62
10
4
6.25

Classes

Class Line # Actions
ConservationThread 33 40 25
0.7575%
 

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