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;
28 import jalview.datamodel.SequenceI;
30 import java.util.ConcurrentModificationException;
31 import java.util.Hashtable;
34 * A thread to recompute the consensus of the cDNA complement for a linked
40 public class ComplementConsensusThread extends ConsensusThread
43 public ComplementConsensusThread(AlignViewportI alignViewport,
44 AlignmentViewPanel alignPanel)
46 super(alignViewport, alignPanel);
50 protected AlignmentAnnotation getConsensusAnnotation()
52 return alignViewport.getComplementConsensusAnnotation();
56 protected Hashtable[] getViewportConsensus()
58 return alignViewport.getComplementConsensusHash();
62 * Calculate the cDNA consensus and store it on the Viewport
65 protected void computeConsensus(AlignmentI alignment)
67 Hashtable[] hconsensus = new Hashtable[alignment.getWidth()];
69 SequenceI[] aseqs = getSequences();
72 * Allow 3 tries at this, since this thread can start up while we are still
73 * modifying protein-codon mappings on the alignment
75 for (int i = 0; i < 3; i++)
79 AAFrequency.calculateCdna(alignment, hconsensus);
81 } catch (ConcurrentModificationException e)
87 alignViewport.setComplementConsensusHash(hconsensus);
91 * Convert the computed consensus data into the desired annotation for
94 * @param consensusAnnotation
95 * the annotation to be populated
96 * @param consensusData
97 * the computed consensus data
100 protected void deriveConsensus(AlignmentAnnotation consensusAnnotation,
101 Hashtable[] consensusData)
103 AAFrequency.completeCdnaConsensus(consensusAnnotation, consensusData,
104 alignViewport.isShowSequenceLogo(), getSequences().length);