import jalview.api.FeaturesDisplayedI;
import jalview.api.ViewStyleI;
import jalview.commands.CommandI;
+import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
import jalview.structure.VamsasSource;
import jalview.viewmodel.styles.ViewStyle;
import jalview.workers.AlignCalcManager;
+import jalview.workers.ComplementConsensusThread;
import jalview.workers.ConsensusThread;
import jalview.workers.StrucConsensusThread;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* base class holding visualization and analysis attributes and common logic for
protected AlignmentAnnotation consensus;
+ protected AlignmentAnnotation complementConsensus;
+
protected AlignmentAnnotation strucConsensus;
protected AlignmentAnnotation conservation;
protected Hashtable[] hconsensus = null;
/**
+ * results of cDNA complement consensus visible portion of view
+ */
+ protected Hashtable[] hcomplementConsensus = null;
+
+ /**
* results of secondary structure base pair consensus for visible portion of
* view
*/
public void setSequenceConsensusHash(Hashtable[] hconsensus)
{
this.hconsensus = hconsensus;
+ }
+ @Override
+ public void setComplementConsensusHash(Hashtable[] hconsensus)
+ {
+ this.hcomplementConsensus = hconsensus;
}
@Override
}
@Override
+ public Hashtable[] getComplementConsensusHash()
+ {
+ return hcomplementConsensus;
+ }
+
+ @Override
public Hashtable[] getRnaStructureConsensusHash()
{
return hStrucConsensus;
}
@Override
+ public AlignmentAnnotation getComplementConsensusAnnotation()
+ {
+ return complementConsensus;
+ }
+
+ @Override
public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
{
return strucConsensus;
{
calculator.registerWorker(new ConsensusThread(this, ap));
}
+
+ /*
+ * A separate thread to compute cDNA consensus for a protein alignment
+ */
+ final AlignmentI al = this.getAlignment();
+ if (!al.isNucleotide() && al.getCodonFrames() != null
+ && !al.getCodonFrames().isEmpty())
+ {
+ if (calculator
+ .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
+ {
+ calculator.registerWorker(new ComplementConsensusThread(this, ap));
+ }
+ }
}
// --------START Structure Conservation
// annotation update method from alignframe to viewport
this.showSequenceLogo = showSequenceLogo;
calculator.updateAnnotationFor(ConsensusThread.class);
+ calculator.updateAnnotationFor(ComplementConsensusThread.class);
calculator.updateAnnotationFor(StrucConsensusThread.class);
}
this.showSequenceLogo = showSequenceLogo;
{
initRNAStructure();
}
- initConsensus();
+ consensus = new AlignmentAnnotation("Consensus", "PID",
+ new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
+ initConsensus(consensus);
+
+ if (!alignment.isNucleotide())
+ {
+ final Set<AlignedCodonFrame> codonMappings = alignment
+ .getCodonFrames();
+ if (codonMappings != null && !codonMappings.isEmpty())
+ {
+ complementConsensus = new AlignmentAnnotation("cDNA Consensus",
+ "PID for cDNA", new Annotation[1], 0f, 100f,
+ AlignmentAnnotation.BAR_GRAPH);
+ initConsensus(complementConsensus);
+ }
+ }
}
}
- private void initConsensus()
+ private void initConsensus(AlignmentAnnotation aa)
{
-
- consensus = new AlignmentAnnotation("Consensus", "PID",
- new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
- consensus.hasText = true;
- consensus.autoCalculated = true;
+ aa.hasText = true;
+ aa.autoCalculated = true;
if (showConsensus)
{
- alignment.addAnnotation(consensus);
+ alignment.addAnnotation(aa);
}
}
public int calcPanelHeight()
{
// setHeight of panels
- AlignmentAnnotation[] aa = getAlignment().getAlignmentAnnotation();
+ AlignmentAnnotation[] anns = getAlignment().getAlignmentAnnotation();
int height = 0;
int charHeight = getCharHeight();
- if (aa != null)
+ if (anns != null)
{
BitSet graphgrp = new BitSet();
- for (int i = 0; i < aa.length; i++)
+ for (AlignmentAnnotation aa : anns)
{
- if (aa[i] == null)
+ if (aa == null)
{
System.err.println("Null annotation row: ignoring.");
continue;
}
- if (!aa[i].visible)
+ if (!aa.visible)
{
continue;
}
- if (aa[i].graphGroup > -1)
+ if (aa.graphGroup > -1)
{
- if (graphgrp.get(aa[i].graphGroup))
+ if (graphgrp.get(aa.graphGroup))
{
continue;
}
else
{
- graphgrp.set(aa[i].graphGroup);
+ graphgrp.set(aa.graphGroup);
}
}
- aa[i].height = 0;
+ aa.height = 0;
- if (aa[i].hasText)
+ if (aa.hasText)
{
- aa[i].height += charHeight;
+ aa.height += charHeight;
}
- if (aa[i].hasIcons)
+ if (aa.hasIcons)
{
- aa[i].height += 16;
+ aa.height += 16;
}
- if (aa[i].graph > 0)
+ if (aa.graph > 0)
{
- aa[i].height += aa[i].graphHeight;
+ aa.height += aa.graphHeight;
}
- if (aa[i].height == 0)
+ if (aa.height == 0)
{
- aa[i].height = 20;
+ aa.height = 20;
}
- height += aa[i].height;
+ height += aa.height;
}
}
if (height == 0)