/** DOCUMENT ME!! */
public Hashtable[] hconsensus;
-
+
+ public Hashtable[] hStrucConsensus;
+
AlignmentAnnotation consensus;
+
+ AlignmentAnnotation strucConsensus;
AlignmentAnnotation conservation;
AlignmentAnnotation[] groupConservation;
boolean autoCalculateConsensus = true;
+
+ boolean autoCalculateStrucConsensus = true;
+
/** DOCUMENT ME!! */
public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
ConservationThread conservationThread;
ConsensusThread consensusThread;
+
+ StrucConsensusThread strucConsensusThread;
boolean consUpdateNeeded = false;
static boolean UPDATING_CONSENSUS = false;
+
+ static boolean UPDATING_STRUC_CONSENSUS = false;
static boolean UPDATING_CONSERVATION = false;
boolean updatingConsensus = false;
+
+ boolean updatingStrucConsensus = false;
boolean updatingConservation = false;
AAFrequency.calculate(alignment.getSequencesArray(), 0,
alignment.getWidth(), hconsensus, true);
updateAnnotation(true);
-
if (globalColourScheme != null)
{
globalColourScheme.setConsensus(hconsensus);
}
}
}
+
+ //--------START Structure Conservation
+ public void updateStrucConsensus(final AlignmentPanel ap)
+ {
+ // see note in mantis : issue number 8585
+ if (strucConsensus == null || !autoCalculateStrucConsensus)
+ {
+ return;
+ }
+ strucConsensusThread = new StrucConsensusThread(ap);
+ strucConsensusThread.start();
+ }
+
+ class StrucConsensusThread extends Thread
+ {
+ AlignmentPanel ap;
+
+ public StrucConsensusThread(AlignmentPanel ap)
+ {
+ this.ap = ap;
+ }
+
+ public void run()
+ {
+ updatingStrucConsensus = true;
+ while (UPDATING_STRUC_CONSENSUS)
+ {
+ try
+ {
+ if (ap != null)
+ {
+ ap.paintAlignment(false);
+ }
+
+ Thread.sleep(200);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ UPDATING_STRUC_CONSENSUS = true;
+
+ try
+ {
+ int aWidth = (alignment != null) ? alignment.getWidth() : -1; // null
+ // pointer
+ // possibility
+ // here.
+ if (aWidth <= 0)
+ {
+ updatingStrucConsensus = false;
+ UPDATING_STRUC_CONSENSUS = false;
+ return;
+ }
+
+ strucConsensus.annotations = null;
+ strucConsensus.annotations = new Annotation[aWidth];
+
+ hStrucConsensus = new Hashtable[aWidth];
+ AlignmentAnnotation rna = ap.av.getAlignment().getAlignmentAnnotation()[0];
+ StructureFrequency.calculate(alignment.getSequencesArray(), 0,
+ alignment.getWidth(), hStrucConsensus, true, rna);
+ //TODO AlignmentAnnotation rnaStruc!!!
+ updateAnnotation(true);
+ if (globalColourScheme != null)
+ {
+ globalColourScheme.setConsensus(hStrucConsensus);
+ }
+
+ } catch (OutOfMemoryError error)
+ {
+ alignment.deleteAnnotation(consensus);
+
+ strucConsensus = null;
+ hStrucConsensus = null;
+ new OOMWarning("calculating structure consensus", error);
+ }
+ UPDATING_STRUC_CONSENSUS = false;
+ updatingStrucConsensus = false;
+
+ if (ap != null)
+ {
+ ap.paintAlignment(true);
+ }
+ }
+
+ /**
+ * update the consensus annotation from the sequence profile data using
+ * current visualization settings.
+ */
+ public void updateAnnotation()
+ {
+ updateAnnotation(false);
+ }
+
+ protected void updateAnnotation(boolean immediate)
+ {
+ // TODO: make calls thread-safe, so if another thread calls this method,
+ // it will either return or wait until one calculation is finished.
+ if (immediate
+ || (!updatingConsensus && consensus != null && hconsensus != null))
+ {
+ StructureFrequency.completeConsensus(strucConsensus, hStrucConsensus, 0,
+ hStrucConsensus.length, ignoreGapsInConsensusCalculation,
+ showSequenceLogo);
+ }
+ }
+ }
+ //--------END Structure Conservation
/**
* get the consensus sequence as displayed under the PID consensus annotation
{
updateConsensus(ap);
}
+
+ if(autoCalculateStrucConsensus)
+ {
+ updateStrucConsensus(ap);
+ }
// Reset endRes of groups if beyond alignment width
int alWidth = alignment.getWidth();