import jalview.structure.StructureSelectionManager;
import jalview.structure.VamsasSource;
import jalview.util.Comparison;
+import jalview.util.MapList;
import jalview.util.MappingUtils;
import jalview.viewmodel.styles.ViewStyle;
import jalview.workers.AlignCalcManager;
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
/*
* A separate thread to compute cDNA consensus for a protein alignment
+ * which has mapping to cDNA
*/
final AlignmentI al = this.getAlignment();
if (!al.isNucleotide() && al.getCodonFrames() != null
&& !al.getCodonFrames().isEmpty())
{
- if (calculator
- .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
+ /*
+ * fudge - check first mapping is protein-to-nucleotide
+ * (we don't want to do this for protein-to-protein)
+ */
+ AlignedCodonFrame mapping = al.getCodonFrames().iterator().next();
+ // TODO hold mapping type e.g. dna-to-protein in AlignedCodonFrame?
+ MapList[] mapLists = mapping.getdnaToProt();
+ // mapLists can be empty if project load has not finished resolving seqs
+ if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3)
{
- calculator.registerWorker(new ComplementConsensusThread(this, ap));
+ if (calculator
+ .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
+ {
+ calculator
+ .registerWorker(new ComplementConsensusThread(this, ap));
+ }
}
}
}
{
updateHiddenColumns();
}
+ isColSelChanged(true);
}
/**
*/
public boolean isColSelChanged(boolean b)
{
- int hc = (colSel == null || colSel.isEmpty()) ? -1 : colSel
- .hashCode();
+ int hc = (colSel == null || colSel.isEmpty()) ? -1 : colSel.hashCode();
if (hc != -1 && hc != colselhash)
{
if (b)
colSel.hideSelectedColumns();
setSelectionGroup(null);
-
+ isColSelChanged(true);
}
public void hideColumns(int start, int end)
{
colSel.hideColumns(start, end);
}
+ isColSelChanged(true);
}
public void showColumn(int col)
{
colSel.revealHiddenColumns(col);
-
+ isColSelChanged(true);
}
public void showAllHiddenColumns()
{
colSel.revealAllHiddenColumns();
+ isColSelChanged(true);
}
// common hide/show seq stuff
protected void setSequenceAnnotationsVisible(SequenceI sequenceI,
boolean visible)
{
- for (AlignmentAnnotation ann : alignment.getAlignmentAnnotation())
+ AlignmentAnnotation[] anns = alignment.getAlignmentAnnotation();
+ if (anns != null)
{
- if (ann.sequenceRef == sequenceI)
+ for (AlignmentAnnotation ann : anns)
{
- ann.visible = visible;
+ if (ann.sequenceRef == sequenceI)
+ {
+ ann.visible = visible;
+ }
}
}
}
if (hiddenRepSequences == null)
{
- hiddenRepSequences = new Hashtable();
+ hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
}
hiddenRepSequences.put(repSequence, sg);
}
+ /**
+ *
+ * @return null or the current reference sequence
+ */
+ public SequenceI getReferenceSeq()
+ {
+ return alignment.getSeqrep();
+ }
+
+ /**
+ * @param seq
+ * @return true iff seq is the reference for the alignment
+ */
+ public boolean isReferenceSeq(SequenceI seq)
+ {
+ return alignment.getSeqrep() == seq;
+ }
+
+ /**
+ *
+ * @param seq
+ * @return true if there are sequences represented by this sequence that are
+ * currently hidden
+ */
public boolean isHiddenRepSequence(SequenceI seq)
{
- return alignment.getSeqrep() == seq
- || (hiddenRepSequences != null && hiddenRepSequences
+ return (hiddenRepSequences != null && hiddenRepSequences
.containsKey(seq));
}
+ /**
+ *
+ * @param seq
+ * @return null or a sequence group containing the sequences that seq
+ * represents
+ */
public SequenceGroup getRepresentedSequences(SequenceI seq)
{
return (SequenceGroup) (hiddenRepSequences == null ? null
@Override
public String[] getViewAsString(boolean selectedRegionOnly)
{
+ return getViewAsString(selectedRegionOnly, true);
+ }
+
+ @Override
+ public String[] getViewAsString(boolean selectedRegionOnly,
+ boolean exportHiddenSeqs)
+ {
String[] selection = null;
SequenceI[] seqs = null;
int i, iSize;
}
else
{
- HiddenSequences hiddenSeqs = alignment.getHiddenSequences();
- if (hiddenSeqs != null && hiddenSeqs.hiddenSequences != null
- && hiddenSeqs.hiddenSequences.length > 0)
+ if (hasHiddenRows() && exportHiddenSeqs)
{
- iSize = alignment.getHiddenSequences().getFullAlignment()
- .getHeight();
- seqs = alignment.getHiddenSequences().getFullAlignment()
- .getSequencesArray();
- end = alignment.getHiddenSequences().getFullAlignment().getWidth();
+ AlignmentI fullAlignment = alignment.getHiddenSequences()
+ .getFullAlignment();
+ iSize = fullAlignment.getHeight();
+ seqs = fullAlignment.getSequencesArray();
+ end = fullAlignment.getWidth();
}
else
{
{
if (!alignment.isNucleotide())
{
- final Set<AlignedCodonFrame> codonMappings = alignment
+ final List<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);
+ // fudge: check mappings are not protein-to-protein
+ // TODO: nicer
+ AlignedCodonFrame mapping = codonMappings.iterator().next();
+ MapList[] mapLists = mapping.getdnaToProt();
+ // mapLists can be empty if project load has not finished resolving seqs
+ if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3)
+ {
+ complementConsensus = new AlignmentAnnotation("cDNA Consensus",
+ "PID for cDNA", new Annotation[1], 0f, 100f,
+ AlignmentAnnotation.BAR_GRAPH);
+ initConsensus(complementConsensus);
+ }
}
}
}
public boolean areFeaturesDisplayed()
{
return featuresDisplayed != null
- && featuresDisplayed.getRegisterdFeaturesCount() > 0;
+ && featuresDisplayed.getRegisteredFeaturesCount() > 0;
}
/**
{
return 0;
}
- final Set<AlignedCodonFrame> mappings = proteinAlignment
+ final List<AlignedCodonFrame> mappings = proteinAlignment
.getCodonFrames();
/*
sequence.findPosition(middleColumn), mappings);
return seqOffset;
}
+
+ /**
+ * synthesize a column selection if none exists so it covers the given
+ * selection group. if wholewidth is false, no column selection is made if the
+ * selection group covers the whole alignment width.
+ *
+ * @param sg
+ * @param wholewidth
+ */
+ public void expandColSelection(SequenceGroup sg, boolean wholewidth)
+ {
+ int sgs, sge;
+ if (sg != null
+ && (sgs = sg.getStartRes()) >= 0
+ && sg.getStartRes() <= (sge = sg.getEndRes())
+ && (colSel == null || colSel.getSelected() == null || colSel
+ .getSelected().size() == 0))
+ {
+ if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
+ {
+ // do nothing
+ return;
+ }
+ if (colSel == null)
+ {
+ colSel = new ColumnSelection();
+ }
+ for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
+ {
+ colSel.addElement(cspos);
+ }
+ }
+ }
+
+
}