import jalview.api.AlignCalcManagerI;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
+import jalview.api.ColorI;
import jalview.api.FeaturesDisplayedI;
import jalview.api.ViewStyleI;
import jalview.commands.CommandI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.schemes.Blosum62ColourScheme;
+import jalview.schemes.Colour;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.PIDColourScheme;
import jalview.schemes.ResidueProperties;
import jalview.workers.ConsensusThread;
import jalview.workers.StrucConsensusThread;
-import java.awt.Color;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.BitSet;
&& !al.getCodonFrames().isEmpty())
{
/*
- * fudge - check first mapping is protein-to-nucleotide
+ * fudge - check first for protein-to-nucleotide mappings
* (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)
+ boolean doConsensus = false;
+ for (AlignedCodonFrame mapping : al.getCodonFrames())
+ {
+ // 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)
+ {
+ doConsensus = true;
+ break;
+ }
+ }
+ if (doConsensus)
{
if (calculator
.getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
}
@Override
+ public boolean hasSelectedColumns()
+ {
+ ColumnSelection columnSelection = getColumnSelection();
+ return columnSelection != null && columnSelection.hasSelectedColumns();
+ }
+
+ @Override
public boolean hasHiddenColumns()
{
return colSel != null && colSel.hasHiddenColumns();
protected boolean showConsensus = true;
- private Map<SequenceI, Color> sequenceColours = new HashMap<SequenceI, Color>();
+ private Map<SequenceI, ColorI> sequenceColours = new HashMap<SequenceI, ColorI>();
protected SequenceAnnotationOrder sortAnnotationsBy = null;
}
/**
+ * Hides the specified sequence, or the sequences it represents
+ *
+ * @param sequence
+ * the sequence to hide, or keep as representative
+ * @param representGroup
+ * if true, hide the current selection group except for the
+ * representative sequence
+ */
+ public void hideSequences(SequenceI sequence, boolean representGroup)
+ {
+ if (selectionGroup == null || selectionGroup.getSize() < 1)
+ {
+ hideSequence(new SequenceI[] { sequence });
+ return;
+ }
+
+ if (representGroup)
+ {
+ hideRepSequences(sequence, selectionGroup);
+ setSelectionGroup(null);
+ return;
+ }
+
+ int gsize = selectionGroup.getSize();
+ SequenceI[] hseqs = selectionGroup.getSequences().toArray(
+ new SequenceI[gsize]);
+
+ hideSequence(hseqs);
+ setSelectionGroup(null);
+ sendSelection();
+ }
+
+ /**
* Set visibility for any annotations for the given sequence.
*
* @param sequenceI
.getCodonFrames();
if (codonMappings != null && !codonMappings.isEmpty())
{
- // 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)
+ boolean doConsensus = false;
+ for (AlignedCodonFrame mapping : codonMappings)
+ {
+ // 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)
+ {
+ doConsensus = true;
+ break;
+ }
+ }
+ if (doConsensus)
{
complementConsensus = new AlignmentAnnotation("cDNA Consensus",
"PID for cDNA", new Annotation[1], 0f, 100f,
}
@Override
- public Color getSequenceColour(SequenceI seq)
+ public ColorI getSequenceColour(SequenceI seq)
{
- Color sqc = sequenceColours.get(seq);
- return (sqc == null ? Color.white : sqc);
+ ColorI sqc = sequenceColours.get(seq);
+ return (sqc == null ? Colour.white : sqc);
}
@Override
- public void setSequenceColour(SequenceI seq, Color col)
+ public void setSequenceColour(SequenceI seq, ColorI col)
{
if (col == null)
{
* @see jalview.api.ViewStyleI#getTextColour()
*/
@Override
- public Color getTextColour()
+ public ColorI getTextColour()
{
return viewStyle.getTextColour();
}
* @see jalview.api.ViewStyleI#getTextColour2()
*/
@Override
- public Color getTextColour2()
+ public ColorI getTextColour2()
{
return viewStyle.getTextColour2();
}
* @see jalview.api.ViewStyleI#setTextColour(java.awt.Color)
*/
@Override
- public void setTextColour(Color textColour)
+ public void setTextColour(ColorI textColour)
{
viewStyle.setTextColour(textColour);
}
* @see jalview.api.ViewStyleI#setTextColour2(java.awt.Color)
*/
@Override
- public void setTextColour2(Color textColour2)
+ public void setTextColour2(ColorI textColour2)
{
viewStyle.setTextColour2(textColour2);
}
* all gapped visible regions
*/
int lastSeq = alignment.getHeight() - 1;
+ List<AlignedCodonFrame> seqMappings = null;
for (int seqNo = getStartSeq(); seqNo < lastSeq; seqNo++, seqOffset++)
{
sequence = getAlignment().getSequenceAt(seqNo);
{
continue;
}
- List<AlignedCodonFrame> seqMappings = MappingUtils
- .findMappingsForSequence(sequence, mappings);
+ seqMappings = MappingUtils
+ .findMappingsForSequenceAndOthers(sequence, mappings,
+ getCodingComplement().getAlignment().getSequences());
if (!seqMappings.isEmpty())
{
break;
}
}
- if (sequence == null)
+ if (sequence == null || seqMappings == null || seqMappings.isEmpty())
{
/*
* No ungapped mapped sequence in middle column - do nothing
return 0;
}
MappingUtils.addSearchResults(sr, sequence,
- sequence.findPosition(middleColumn), mappings);
+ sequence.findPosition(middleColumn), seqMappings);
return seqOffset;
}
if (sg != null
&& (sgs = sg.getStartRes()) >= 0
&& sg.getStartRes() <= (sge = sg.getEndRes())
- && (colSel == null || colSel.getSelected() == null || colSel
- .getSelected().size() == 0))
+ && !this.hasSelectedColumns())
{
if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
{
}
}
+ /**
+ * hold status of current selection group - defined on alignment or not.
+ */
+ private boolean selectionIsDefinedGroup = false;
+ @Override
+ public boolean isSelectionDefinedGroup()
+ {
+ if (selectionGroup == null)
+ {
+ return false;
+ }
+ if (isSelectionGroupChanged(true))
+ {
+ selectionIsDefinedGroup = false;
+ List<SequenceGroup> gps = alignment.getGroups();
+ if (gps == null || gps.size() == 0)
+ {
+ selectionIsDefinedGroup = false;
+ }
+ else
+ {
+ selectionIsDefinedGroup = gps.contains(selectionGroup);
+ }
+ }
+ return selectionGroup.getContext() == alignment
+ || selectionIsDefinedGroup;
+ }
}