1 package jalview.workers;
3 import java.util.ConcurrentModificationException;
4 import java.util.Hashtable;
6 import jalview.analysis.AAFrequency;
7 import jalview.api.AlignViewportI;
8 import jalview.api.AlignmentViewPanel;
9 import jalview.datamodel.AlignmentAnnotation;
10 import jalview.datamodel.AlignmentI;
11 import jalview.datamodel.SequenceI;
14 * A thread to recompute the consensus of the cDNA complement for a linked
20 public class ComplementConsensusThread extends ConsensusThread
23 public ComplementConsensusThread(AlignViewportI alignViewport,
24 AlignmentViewPanel alignPanel)
26 super(alignViewport, alignPanel);
30 protected AlignmentAnnotation getConsensusAnnotation()
32 return alignViewport.getComplementConsensusAnnotation();
36 protected Hashtable[] getViewportConsensus()
38 return alignViewport.getComplementConsensusHash();
42 * Calculate the cDNA consensus and store it on the Viewport
45 protected void computeConsensus(AlignmentI alignment)
47 Hashtable[] hconsensus = new Hashtable[alignment.getWidth()];
49 SequenceI[] aseqs = getSequences();
52 * Allow 3 tries at this, since this thread can start up while we are still
53 * modifying protein-codon mappings on the alignment
55 for (int i = 0; i < 3; i++)
59 AAFrequency.calculateCdna(alignment, hconsensus);
61 } catch (ConcurrentModificationException e)
67 alignViewport.setComplementConsensusHash(hconsensus);
71 * Convert the computed consensus data into the desired annotation for
74 * @param consensusAnnotation
75 * the annotation to be populated
76 * @param consensusData
77 * the computed consensus data
80 protected void deriveConsensus(AlignmentAnnotation consensusAnnotation,
81 Hashtable[] consensusData)
83 AAFrequency.completeCdnaConsensus(consensusAnnotation, consensusData,
84 alignViewport.isShowSequenceLogo(), getSequences().length);