Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.workers

File ComplementConsensusThread.java

 

Coverage histogram

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

Code metrics

4
15
6
1
118
61
12
0.8
2.5
6
2

Classes

Class Line # Actions
ComplementConsensusThread 40 15 12 2
0.9292%
 

Contributing tests

This file is covered by 1 test. .

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