2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.workers;
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;
29 import java.util.ConcurrentModificationException;
30 import java.util.Hashtable;
33 * A thread to recompute the consensus of the cDNA complement for a linked
39 public class ComplementConsensusThread extends ConsensusThread
42 public ComplementConsensusThread(AlignViewportI alignViewport,
43 AlignmentViewPanel alignPanel)
45 super(alignViewport, alignPanel);
49 protected AlignmentAnnotation getConsensusAnnotation()
51 return alignViewport.getComplementConsensusAnnotation();
55 protected Hashtable<String, Object>[] getViewportConsensus()
57 return alignViewport.getComplementConsensusHash();
61 * Calculate the cDNA consensus and store it on the Viewport
64 protected void computeConsensus(AlignmentI alignment)
66 @SuppressWarnings("unchecked")
67 Hashtable<String, Object>[] hconsensus = new Hashtable[alignment
70 // SequenceI[] aseqs = getSequences();
73 * Allow 3 tries at this, since this thread can start up while we are still
74 * modifying protein-codon mappings on the alignment
76 for (int i = 0; i < 3; i++)
80 AAFrequency.calculateCdna(alignment, hconsensus);
82 } catch (ConcurrentModificationException e)
88 alignViewport.setComplementConsensusHash(hconsensus);
92 * Convert the computed consensus data into the desired annotation for
95 * @param consensusAnnotation
96 * the annotation to be populated
97 * @param consensusData
98 * the computed consensus data
100 protected void deriveConsensus(AlignmentAnnotation consensusAnnotation,
101 Hashtable<String, Object>[] consensusData)
103 AAFrequency.completeCdnaConsensus(consensusAnnotation, consensusData,
104 alignViewport.isShowSequenceLogo(), getSequences().length);
108 public void updateResultAnnotation(boolean immediate)
110 AlignmentAnnotation consensus = getConsensusAnnotation();
111 Hashtable<String, Object>[] hconsensus = getViewportConsensus();
112 if (immediate || !calcMan.isWorking(this) && consensus != null
113 && hconsensus != null)
115 deriveConsensus(consensus, hconsensus);