SequenceI prot = mapping.findAlignedSequence(dnaSeq, protein);
if (prot != null)
{
- Mapping seqMap = mapping.getMappingForSequence(dnaSeq);
+ Mapping seqMap = mapping.getMappingForSequence(dnaSeq, false);
addCodonPositions(dnaSeq, prot, protein.getGapCharacter(), seqMap,
alignedCodons);
unmappedProtein.remove(prot);
protected Map<SeqCigar, Set<String>> findFeatureTypesAtColumn(
SeqCigar[] seqs, int columnPosition)
{
- Map<SeqCigar, Set<String>> sfap = new HashMap<SeqCigar, Set<String>>();
+ Map<SeqCigar, Set<String>> sfap = new HashMap<>();
for (SeqCigar seq : seqs)
{
int spos = seq.findPosition(columnPosition);
/*
* position is not a gap
*/
- Set<String> types = new HashSet<String>();
+ Set<String> types = new HashSet<>();
List<SequenceFeature> sfs = fr.findFeaturesAtResidue(
- seq.getRefSeq(), spos);
+ seq.getRefSeq(), spos, spos);
for (SequenceFeature sf : sfs)
{
types.add(sf.getType());
List<SequenceFeature> findFeaturesAtColumn(SequenceI sequence, int column);
/**
- * Returns features at the specified residue position on the given sequence.
+ * Returns features at the specified residue positions on the given sequence.
* Non-positional features are not included.
*
* @param sequence
- * @param resNo
- * residue position (start..)
+ * @param fromResNo
+ * @param toResNo
* @return
*/
- List<SequenceFeature> findFeaturesAtResidue(SequenceI sequence, int resNo);
+ List<SequenceFeature> findFeaturesAtResidue(SequenceI sequence,
+ int fromResNo, int toResNo);
/**
* get current displayed types, in ordering of rendering (on top last)
*/
public AlignedCodonFrame()
{
- mappings = new ArrayList<SequenceToSequenceMapping>();
+ mappings = new ArrayList<>();
}
/**
{
// TODO return a list instead?
// return dnaSeqs;
- List<SequenceI> seqs = new ArrayList<SequenceI>();
+ List<SequenceI> seqs = new ArrayList<>();
for (SequenceToSequenceMapping ssm : mappings)
{
seqs.add(ssm.fromSeq);
public SequenceI[] getAaSeqs()
{
// TODO not used - remove?
- List<SequenceI> seqs = new ArrayList<SequenceI>();
+ List<SequenceI> seqs = new ArrayList<>();
for (SequenceToSequenceMapping ssm : mappings)
{
seqs.add(ssm.mapping.to);
public MapList[] getdnaToProt()
{
- List<MapList> maps = new ArrayList<MapList>();
+ List<MapList> maps = new ArrayList<>();
for (SequenceToSequenceMapping ssm : mappings)
{
maps.add(ssm.mapping.map);
public Mapping[] getProtMappings()
{
- List<Mapping> maps = new ArrayList<Mapping>();
+ List<Mapping> maps = new ArrayList<>();
for (SequenceToSequenceMapping ssm : mappings)
{
maps.add(ssm.mapping);
* @param seq
* @return
*/
- public Mapping getMappingForSequence(SequenceI seq)
+ public Mapping getMappingForSequence(SequenceI seq, boolean cdsOnly)
{
SequenceI seqDs = seq.getDatasetSequence();
seqDs = seqDs != null ? seqDs : seq;
{
if (ssm.fromSeq == seqDs || ssm.mapping.to == seqDs)
{
- return ssm.mapping;
+ if (!cdsOnly || ssm.fromSeq.getName().startsWith("CDS")
+ || ssm.mapping.to.getName().startsWith("CDS"))
+ {
+ return ssm.mapping;
+ }
}
}
return null;
{
MapList ml = null;
SequenceI dnaSeq = null;
- List<char[]> result = new ArrayList<char[]>();
+ List<char[]> result = new ArrayList<>();
for (SequenceToSequenceMapping ssm : mappings)
{
*/
public List<Mapping> getMappingsFromSequence(SequenceI seq)
{
- List<Mapping> result = new ArrayList<Mapping>();
- List<SequenceI> related = new ArrayList<SequenceI>();
+ List<Mapping> result = new ArrayList<>();
+ List<SequenceI> related = new ArrayList<>();
SequenceI seqDs = seq.getDatasetSequence();
seqDs = seqDs != null ? seqDs : seq;
import jalview.util.MapList;
import jalview.util.MappingUtils;
import jalview.util.MessageManager;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import jalview.ws.SequenceFetcher;
import java.util.ArrayList;
.isShowSequenceFeatures();
newFrame.setShowSeqFeatures(showSequenceFeatures);
copyThis.setShowSeqFeatures(showSequenceFeatures);
- FeatureRenderer myFeatureStyling = alignFrame.alignPanel
+ FeatureRendererModel myFeatureStyling = alignFrame.alignPanel
.getSeqPanel().seqCanvas.getFeatureRenderer();
/*
* copy feature rendering settings to split frame
*/
- FeatureRenderer fr1 = newFrame.alignPanel.getSeqPanel().seqCanvas
+ FeatureRendererModel fr1 = newFrame.alignPanel.getSeqPanel().seqCanvas
.getFeatureRenderer();
fr1.transferSettings(myFeatureStyling);
fr1.findAllFeatures(true);
- FeatureRenderer fr2 = copyThis.alignPanel.getSeqPanel().seqCanvas
+ FeatureRendererModel fr2 = copyThis.alignPanel.getSeqPanel().seqCanvas
.getFeatureRenderer();
fr2.transferSettings(myFeatureStyling);
fr2.findAllFeatures(true);
package jalview.gui;
import jalview.api.FeatureColourI;
-import jalview.datamodel.AlignedCodonFrame;
-import jalview.datamodel.Mapping;
-import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceFeature;
{
Arrays.sort(renderOrder, order);
}
-
- /**
- * Answers a (possibly empty) list of features in this alignment at a position
- * (or range) which is mappable from the given sequence residue position in a
- * mapped alignment.
- *
- * @param sequence
- * @param pos
- * @return
- */
- public List<SequenceFeature> findComplementFeaturesAtResidue(
- SequenceI sequence, int pos)
- {
- SequenceI ds = sequence.getDatasetSequence();
- List<SequenceFeature> result = new ArrayList<>();
- List<AlignedCodonFrame> mappings = this.av.getAlignment()
- .getCodonFrame(sequence);
- for (AlignedCodonFrame acf : mappings)
- {
- Mapping mapping = acf.getMappingForSequence(sequence);
- if (mapping.getMap().getFromRatio() == mapping.getMap().getToRatio())
- {
- continue; // we are only looking for 3:1 or 1:3 mappings
- }
- SearchResultsI sr = new SearchResults();
- acf.markMappedRegion(ds, pos, sr);
- for (SearchResultMatchI match : sr.getResults())
- {
- for (int i = match.getStart(); i <= match.getEnd(); i++)
- {
- List<SequenceFeature> fs = findFeaturesAtResidue(
- match.getSequence(), i);
- for (SequenceFeature sf : fs)
- {
- if (!result.contains(sf))
- {
- result.addAll(fs);
- }
- }
- }
- }
- }
-
- return result;
- }
}
import jalview.viewmodel.AlignmentViewport;
import jalview.viewmodel.PCAModel;
import jalview.viewmodel.ViewportRanges;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import jalview.viewmodel.seqfeatures.FeatureRendererSettings;
import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
import jalview.ws.jws2.Jws2Discoverer;
{
jalview.schemabinding.version2.FeatureSettings fs = new jalview.schemabinding.version2.FeatureSettings();
- FeatureRenderer fr = ap.getSeqPanel().seqCanvas
+ FeatureRendererModel fr = ap.getSeqPanel().seqCanvas
.getFeatureRenderer();
String[] renderOrder = fr.getRenderOrder().toArray(new String[0]);
// recover feature settings
if (jms.getFeatureSettings() != null)
{
- FeatureRenderer fr = af.alignPanel.getSeqPanel().seqCanvas
+ FeatureRendererModel fr = af.alignPanel.getSeqPanel().seqCanvas
.getFeatureRenderer();
FeaturesDisplayed fdi;
af.viewport.setFeaturesDisplayed(fdi = new FeaturesDisplayed());
import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
import jalview.io.DataSourceType;
import jalview.structure.StructureSelectionManager;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import javax.swing.SwingUtilities;
}
@Override
- public FeatureRenderer getFeatureRenderer(AlignmentViewPanel alignment)
+ public FeatureRendererModel getFeatureRenderer(AlignmentViewPanel alignment)
{
AlignmentPanel ap = (alignment == null) ? cvf.getAlignmentPanel()
: (AlignmentPanel) alignment;
import jalview.renderer.OverviewRenderer;
import jalview.renderer.OverviewResColourFinder;
import jalview.viewmodel.OverviewDimensions;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import java.awt.Color;
import java.awt.Dimension;
* the renderer to transfer feature colouring from
*/
public void draw(boolean showSequenceFeatures, boolean showAnnotation,
- FeatureRenderer transferRenderer)
+ FeatureRendererModel transferRenderer)
{
miniMe = null;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import java.awt.BorderLayout;
import java.awt.Color;
AlignViewportI complement = ap.getAlignViewport()
.getCodingComplement();
AlignFrame af = Desktop.getAlignFrameFor(complement);
- FeatureRenderer fr2 = af.getFeatureRenderer();
+ FeatureRendererModel fr2 = af.getFeatureRenderer();
features = fr2.findComplementFeaturesAtResidue(sequence, pos);
seqARep.appendFeatures(tooltipText, pos, features, fr2);
}
import jalview.gui.AppVarna;
import jalview.gui.ChimeraViewFrame;
import jalview.gui.Desktop;
-import jalview.gui.FeatureRenderer;
import jalview.gui.Jalview2XML_V1;
import jalview.gui.JvOptionPane;
import jalview.gui.OOMWarning;
import jalview.viewmodel.AlignmentViewport;
import jalview.viewmodel.PCAModel;
import jalview.viewmodel.ViewportRanges;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import jalview.viewmodel.seqfeatures.FeatureRendererSettings;
import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
import jalview.ws.jws2.Jws2Discoverer;
{
FeatureSettings fs = new FeatureSettings();
- FeatureRenderer fr = ap.getSeqPanel().seqCanvas
+ FeatureRendererModel fr = ap.getSeqPanel().seqCanvas
.getFeatureRenderer();
String[] renderOrder = fr.getRenderOrder().toArray(new String[0]);
// recover feature settings
if (jm.getFeatureSettings() != null)
{
- FeatureRenderer fr = af.alignPanel.getSeqPanel().seqCanvas
+ FeatureRendererModel fr = af.alignPanel.getSeqPanel().seqCanvas
.getFeatureRenderer();
FeaturesDisplayed fdi;
viewport.setFeaturesDisplayed(fdi = new FeaturesDisplayed());
*/
package jalview.renderer.seqfeatures;
+import jalview.api.AlignViewportI;
import jalview.api.FeatureRenderer;
import jalview.api.FeaturesDisplayedI;
import jalview.datamodel.SequenceI;
*/
boolean noFeaturesDisplayed()
{
- if (featureRenderer == null
- || !featureRenderer.getViewport().isShowSequenceFeatures())
+ AlignViewportI av = featureRenderer.getViewport();
+ if (av.isShowComplementFeatures())
+ {
+ return false;
+ }
+ if (featureRenderer == null || !av.isShowSequenceFeatures())
{
return true;
}
import jalview.datamodel.Range;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
import jalview.util.Comparison;
import jalview.viewmodel.seqfeatures.FeatureRendererModel;
updateFeatures();
/*
+ * show complement features on top (if configured to show them)
+ */
+ if (av.isShowComplementFeatures())
+ {
+ AlignViewportI complement = av.getCodingComplement();
+ AlignFrame af = Desktop.getAlignFrameFor(complement);
+ FeatureRendererModel fr2 = af.getFeatureRenderer();
+ List<SequenceFeature> features = fr2.findComplementFeaturesAtResidue(
+ seq, seq.findPosition(column));
+ // todo: ensure ordered by feature render order
+ for (SequenceFeature sf : features)
+ {
+ if (!fr2.featureGroupNotShown(sf))
+ {
+ Color col = fr2.getColour(sf);
+ if (col != null)
+ {
+ return col;
+ }
+ }
+ }
+ }
+
+ /*
* inspect features in reverse renderOrder (the last in the array is
* displayed on top) until we find one that is rendered at the position
*/
import jalview.api.AlignViewportI;
import jalview.api.FeatureColourI;
import jalview.api.FeaturesDisplayedI;
+import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Mapping;
+import jalview.datamodel.SearchResultMatchI;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.datamodel.features.FeatureMatcherSetI;
* @param sequenceFeature
* @return
*/
- protected boolean featureGroupNotShown(final SequenceFeature sequenceFeature)
+ public boolean featureGroupNotShown(final SequenceFeature sequenceFeature)
{
return featureGroups != null
&& sequenceFeature.featureGroup != null
*/
@Override
public List<SequenceFeature> findFeaturesAtResidue(SequenceI sequence,
- int resNo)
+ int fromResNo, int toResNo)
{
List<SequenceFeature> result = new ArrayList<>();
if (!av.areFeaturesDisplayed() || getFeaturesDisplayed() == null)
String[] visibleTypes = visibleFeatures
.toArray(new String[visibleFeatures.size()]);
List<SequenceFeature> features = sequence.getFeatures().findFeatures(
- resNo, resNo, visibleTypes);
+ fromResNo, toResNo, visibleTypes);
for (SequenceFeature sf : features)
{
return filter == null ? true : filter.matches(sf);
}
+ /**
+ * Answers a (possibly empty) list of features in this alignment at a position
+ * (or range) which is mappable from the given sequence residue position in a
+ * mapped alignment.
+ *
+ * @param sequence
+ * @param pos
+ * @return
+ */
+ public List<SequenceFeature> findComplementFeaturesAtResidue(SequenceI sequence, int pos)
+ {
+ SequenceI ds = sequence.getDatasetSequence();
+ List<SequenceFeature> result = new ArrayList<>();
+ List<AlignedCodonFrame> mappings = this.av.getAlignment()
+ .getCodonFrame(sequence);
+
+ /*
+ * todo: direct lookup of CDS for peptide and vice-versa; for now,
+ * have to search through an unordered list of mappings for a candidate
+ */
+ for (AlignedCodonFrame acf : mappings)
+ {
+ Mapping mapping = acf.getMappingForSequence(sequence, true);
+ if (mapping == null || mapping.getMap().getFromRatio() == mapping
+ .getMap().getToRatio())
+ {
+ continue; // we are only looking for 3:1 or 1:3 mappings
+ }
+ SearchResultsI sr = new SearchResults();
+ acf.markMappedRegion(ds, pos, sr);
+ for (SearchResultMatchI match : sr.getResults())
+ {
+ int fromRes = match.getStart();
+ int toRes = match.getEnd();
+ List<SequenceFeature> fs = findFeaturesAtResidue(
+ match.getSequence(), fromRes, toRes);
+ for (SequenceFeature sf : fs)
+ {
+ if (!result.contains(sf))
+ {
+ result.add(sf);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
}
import jalview.io.FileLoader;
import jalview.schemes.FeatureColour;
import jalview.util.matcher.Condition;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import java.awt.Color;
import java.io.File;
/*
* set colour schemes for features
*/
- FeatureRenderer fr = af.getFeatureRenderer();
+ FeatureRendererModel fr = af.getFeatureRenderer();
// type1: red
fr.setColour("type1", new FeatureColour(Color.red));
import jalview.gui.AlignmentPanel;
import jalview.gui.CalculationChooser;
import jalview.gui.Desktop;
-import jalview.gui.FeatureRenderer;
import jalview.gui.Jalview2XML;
import jalview.gui.JvOptionPane;
import jalview.gui.PCAPanel;
import jalview.util.matcher.Condition;
import jalview.viewmodel.AlignmentViewport;
import jalview.viewmodel.PCAModel;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import java.awt.Color;
import java.io.File;
/*
* set colour schemes for features
*/
- FeatureRenderer fr = af.getFeatureRenderer();
+ FeatureRendererModel fr = af.getFeatureRenderer();
fr.findAllFeatures(true);
// type1: red
import jalview.gui.AlignViewport;
import jalview.gui.AlignmentPanel;
import jalview.gui.Desktop;
-import jalview.gui.FeatureRenderer;
import jalview.gui.JvOptionPane;
import jalview.gui.PCAPanel;
import jalview.gui.PopupMenu;
import jalview.structure.StructureImportSettings;
import jalview.util.matcher.Condition;
import jalview.viewmodel.AlignmentViewport;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import java.awt.Color;
import java.io.File;
/*
* set colour schemes for features
*/
- FeatureRenderer fr = af.getFeatureRenderer();
+ FeatureRendererModel fr = af.getFeatureRenderer();
fr.findAllFeatures(true);
// type1: red
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.AlignViewport;
-import jalview.gui.FeatureRenderer;
import jalview.io.DataSourceType;
import jalview.io.FileLoader;
import jalview.schemes.FeatureColour;
+import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean;
import java.awt.Color;
private AlignFrame af;
- private FeatureRenderer fr;
+ private FeatureRendererModel fr;
@BeforeTest(alwaysRun = true)
public void setUp()