Clover icon

Coverage Report

  1. Project Clover database Fri Nov 1 2024 11:46:37 GMT
  2. Package jalview.workers

File ComplementConsensusThread.java

 

Coverage histogram

../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

4
14
6
1
119
61
12
0.86
2.33
6
2

Classes

Class Line # Actions
ComplementConsensusThread 39 14 12
0.916666791.7%
 

Contributing tests

This file is covered by 3 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.AAFrequency;
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.ConcurrentModificationException;
30    import java.util.Hashtable;
31   
32    /**
33    * A thread to recompute the consensus of the cDNA complement for a linked
34    * protein alignment.
35    *
36    * @author gmcarstairs
37    *
38    */
 
39    public class ComplementConsensusThread extends ConsensusThread
40    {
41   
 
42  4 toggle public ComplementConsensusThread(AlignViewportI alignViewport,
43    AlignmentViewPanel alignPanel)
44    {
45  4 super(alignViewport, alignPanel);
46    }
47   
 
48  12 toggle @Override
49    protected AlignmentAnnotation getConsensusAnnotation()
50    {
51  12 return alignViewport.getComplementConsensusAnnotation();
52    }
53   
 
54  4 toggle @Override
55    protected Hashtable<String, Object>[] getViewportConsensus()
56    {
57  4 return alignViewport.getComplementConsensusHash();
58    }
59   
60    /**
61    * Calculate the cDNA consensus and store it on the Viewport
62    */
 
63  4 toggle @Override
64    protected void computeConsensus(AlignmentI alignment)
65    {
66  4 @SuppressWarnings("unchecked")
67    Hashtable<String, Object>[] hconsensus = new Hashtable[alignment
68    .getWidth()];
69   
70    // SequenceI[] aseqs = getSequences();
71   
72    /*
73    * Allow 3 tries at this, since this thread can start up while we are still
74    * modifying protein-codon mappings on the alignment
75    */
76  4 for (int i = 0; i < 3; i++)
77    {
78  4 try
79    {
80  4 AAFrequency.calculateCdna(alignment, hconsensus);
81  4 break;
82    } catch (ConcurrentModificationException e)
83    {
84    // try again
85    }
86    }
87   
88  4 alignViewport.setComplementConsensusHash(hconsensus);
89    }
90   
91    /**
92    * Convert the computed consensus data into the desired annotation for
93    * display.
94    *
95    * @param consensusAnnotation
96    * the annotation to be populated
97    * @param consensusData
98    * the computed consensus data
99    */
 
100  4 toggle protected void deriveConsensus(AlignmentAnnotation consensusAnnotation,
101    Hashtable<String, Object>[] consensusData)
102    {
103  4 AAFrequency.completeCdnaConsensus(consensusAnnotation, consensusData,
104    alignViewport.isShowSequenceLogo(), getSequences().length);
105    }
106   
 
107  4 toggle @Override
108    public void updateResultAnnotation(boolean immediate)
109    {
110  4 AlignmentAnnotation consensus = getConsensusAnnotation();
111  4 Hashtable<String, Object>[] hconsensus = getViewportConsensus();
112  4 if (immediate || !calcMan.isWorking(this) && consensus != null
113    && hconsensus != null)
114    {
115  4 deriveConsensus(consensus, hconsensus);
116    }
117    }
118   
119    }