1 package jalview.workers;
3 import java.util.Hashtable;
5 import jalview.analysis.AAFrequency;
6 import jalview.analysis.StructureFrequency;
7 import jalview.api.AlignCalcWorkerI;
8 import jalview.api.AlignViewportI;
9 import jalview.api.AlignmentViewPanel;
10 import jalview.datamodel.AlignmentAnnotation;
11 import jalview.datamodel.AlignmentI;
12 import jalview.datamodel.Annotation;
14 public class StrucConsensusThread extends AlignCalcWorker implements AlignCalcWorkerI
16 public StrucConsensusThread(AlignViewportI alignViewport,
17 AlignmentViewPanel alignPanel)
19 super(alignViewport, alignPanel);
21 AlignmentAnnotation strucConsensus;
22 Hashtable[] hStrucConsensus;
28 calcMan.notifyStart(this);
29 while (!calcMan.notifyWorking(this))
35 ap.paintAlignment(false);
39 } catch (Exception ex)
44 if (alignViewport.isClosed())
48 AlignmentI alignment = alignViewport.getAlignment();
52 if (alignment == null || (aWidth = alignment.getWidth()) < 0)
54 calcMan.workerComplete(this);
57 strucConsensus=alignViewport.getAlignmentStrucConsensusAnnotation();
58 hStrucConsensus=alignViewport.getRnaStructureConsensusHash();
59 strucConsensus.annotations = null;
60 strucConsensus.annotations = new Annotation[aWidth];
62 hStrucConsensus = new Hashtable[aWidth];
64 AlignmentAnnotation[] aa = alignViewport.getAlignment()
65 .getAlignmentAnnotation();
66 AlignmentAnnotation rnaStruc = null;
67 // select rna struct to use for calculation
68 for (int i = 0; i < aa.length; i++)
70 if (aa[i].getRNAStruc() != null && aa[i].isValidStruc())
76 // check to see if its valid
78 if (rnaStruc==null || !rnaStruc.isValidStruc())
80 calcMan.workerComplete(this);
84 jalview.analysis.StructureFrequency.calculate(alignment.getSequencesArray(), 0,
85 alignment.getWidth(), hStrucConsensus, true, rnaStruc);
86 alignViewport.setRnaStructureConsensusHash(hStrucConsensus);
87 // TODO AlignmentAnnotation rnaStruc!!!
88 updateResultAnnotation(true);
89 if (alignViewport.getGlobalColourScheme()!= null)
91 alignViewport.getGlobalColourScheme().setConsensus(hStrucConsensus);
94 } catch (OutOfMemoryError error)
96 calcMan.workerCannotRun(this);
100 ap.raiseOOMWarning("calculating RNA structure consensus", error);
103 calcMan.workerComplete(this);
106 ap.paintAlignment(true);
111 * update the consensus annotation from the sequence profile data using
112 * current visualization settings.
114 public void updateAnnotation()
116 updateResultAnnotation(false);
119 public void updateResultAnnotation(boolean immediate)
121 if (immediate || !calcMan.isWorking(this) && strucConsensus!=null && hStrucConsensus!=null)
123 StructureFrequency.completeConsensus(strucConsensus,
124 hStrucConsensus, 0, hStrucConsensus.length,
125 alignViewport.getIgnoreGapsConsensus(),
126 alignViewport.isShowSequenceLogo());