2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.viewmodel.seqfeatures;
23 import jalview.api.AlignViewportI;
24 import jalview.api.FeatureColourI;
25 import jalview.api.FeaturesDisplayedI;
26 import jalview.datamodel.AlignedCodonFrame;
27 import jalview.datamodel.AlignmentI;
28 import jalview.datamodel.Mapping;
29 import jalview.datamodel.SearchResultMatchI;
30 import jalview.datamodel.SearchResults;
31 import jalview.datamodel.SearchResultsI;
32 import jalview.datamodel.SequenceFeature;
33 import jalview.datamodel.SequenceI;
34 import jalview.datamodel.features.FeatureMatcherSetI;
35 import jalview.datamodel.features.SequenceFeatures;
36 import jalview.renderer.seqfeatures.FeatureRenderer;
37 import jalview.schemes.FeatureColour;
38 import jalview.util.ColorUtils;
40 import java.awt.Color;
41 import java.beans.PropertyChangeListener;
42 import java.beans.PropertyChangeSupport;
43 import java.util.ArrayList;
44 import java.util.Arrays;
45 import java.util.HashMap;
46 import java.util.HashSet;
47 import java.util.Hashtable;
48 import java.util.Iterator;
49 import java.util.List;
52 import java.util.concurrent.ConcurrentHashMap;
54 public abstract class FeatureRendererModel
55 implements jalview.api.FeatureRenderer
58 * a data bean to hold one row of feature settings from the gui
60 public static class FeatureSettingsBean
62 public final String featureType;
64 public final FeatureColourI featureColour;
66 public final FeatureMatcherSetI filter;
68 public final Boolean show;
70 public FeatureSettingsBean(String type, FeatureColourI colour,
71 FeatureMatcherSetI theFilter, Boolean isShown)
74 featureColour = colour;
81 * global transparency for feature
83 protected float transparency = 1.0f;
86 * colour scheme for each feature type
88 protected Map<String, FeatureColourI> featureColours = new ConcurrentHashMap<>();
91 * visibility flag for each feature group
93 protected Map<String, Boolean> featureGroups = new ConcurrentHashMap<>();
96 * filters for each feature type
98 protected Map<String, FeatureMatcherSetI> featureFilters = new HashMap<>();
100 protected String[] renderOrder;
102 Map<String, Float> featureOrder = null;
104 protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(
107 protected AlignViewportI av;
110 public AlignViewportI getViewport()
115 public FeatureRendererSettings getSettings()
117 return new FeatureRendererSettings(this);
120 public void transferSettings(FeatureRendererSettings fr)
122 this.renderOrder = fr.renderOrder;
123 this.featureGroups = fr.featureGroups;
124 this.featureColours = fr.featureColours;
125 this.transparency = fr.transparency;
126 this.featureOrder = fr.featureOrder;
130 * update from another feature renderer
135 public void transferSettings(jalview.api.FeatureRenderer _fr)
137 FeatureRenderer fr = (FeatureRenderer) _fr;
138 FeatureRendererSettings frs = new FeatureRendererSettings(fr);
139 this.renderOrder = frs.renderOrder;
140 this.featureGroups = frs.featureGroups;
141 this.featureColours = frs.featureColours;
142 this.featureFilters = frs.featureFilters;
143 this.transparency = frs.transparency;
144 this.featureOrder = frs.featureOrder;
145 if (av != null && av != fr.getViewport())
147 // copy over the displayed feature settings
148 if (_fr.getFeaturesDisplayed() != null)
150 FeaturesDisplayedI fd = getFeaturesDisplayed();
153 setFeaturesDisplayedFrom(_fr.getFeaturesDisplayed());
160 for (String type : _fr.getFeaturesDisplayed()
161 .getVisibleFeatures())
171 public void setFeaturesDisplayedFrom(FeaturesDisplayedI featuresDisplayed)
173 av.setFeaturesDisplayed(new FeaturesDisplayed(featuresDisplayed));
177 public void setVisible(String featureType)
179 FeaturesDisplayedI fdi = av.getFeaturesDisplayed();
182 av.setFeaturesDisplayed(fdi = new FeaturesDisplayed());
184 if (!fdi.isRegistered(featureType))
186 pushFeatureType(Arrays.asList(new String[] { featureType }));
188 fdi.setVisible(featureType);
192 public void setAllVisible(List<String> featureTypes)
194 FeaturesDisplayedI fdi = av.getFeaturesDisplayed();
197 av.setFeaturesDisplayed(fdi = new FeaturesDisplayed());
199 List<String> nft = new ArrayList<>();
200 for (String featureType : featureTypes)
202 if (!fdi.isRegistered(featureType))
204 nft.add(featureType);
209 pushFeatureType(nft);
211 fdi.setAllVisible(featureTypes);
215 * push a set of new types onto the render order stack. Note - this is a
216 * direct mechanism rather than the one employed in updateRenderOrder
220 private void pushFeatureType(List<String> types)
223 int ts = types.size();
224 String neworder[] = new String[(renderOrder == null ? 0
225 : renderOrder.length) + ts];
226 types.toArray(neworder);
227 if (renderOrder != null)
229 System.arraycopy(neworder, 0, neworder, renderOrder.length, ts);
230 System.arraycopy(renderOrder, 0, neworder, 0, renderOrder.length);
232 renderOrder = neworder;
235 protected Map<String, float[][]> minmax = new Hashtable<>();
237 public Map<String, float[][]> getMinMax()
243 * normalise a score against the max/min bounds for the feature type.
245 * @param sequenceFeature
246 * @return byte[] { signed, normalised signed (-127 to 127) or unsigned
249 protected final byte[] normaliseScore(SequenceFeature sequenceFeature)
251 float[] mm = minmax.get(sequenceFeature.type)[0];
252 final byte[] r = new byte[] { 0, (byte) 255 };
255 if (r[0] != 0 || mm[0] < 0.0)
258 r[1] = (byte) ((int) 128.0
259 + 127.0 * (sequenceFeature.score / mm[1]));
263 r[1] = (byte) ((int) 255.0 * (sequenceFeature.score / mm[1]));
269 boolean newFeatureAdded = false;
271 boolean findingFeatures = false;
273 protected boolean updateFeatures()
275 if (av.getFeaturesDisplayed() == null || renderOrder == null
279 if (av.getFeaturesDisplayed().getVisibleFeatureCount() < 1)
284 // TODO: decide if we should check for the visible feature count first
289 * search the alignment for all new features, give them a colour and display
290 * them. Then fires a PropertyChangeEvent on the changeSupport object.
293 protected void findAllFeatures()
295 synchronized (firing)
297 if (firing.equals(Boolean.FALSE))
299 firing = Boolean.TRUE;
300 findAllFeatures(true); // add all new features as visible
301 changeSupport.firePropertyChange("changeSupport", null, null);
302 firing = Boolean.FALSE;
308 public List<SequenceFeature> findFeaturesAtColumn(SequenceI sequence, int column)
311 * include features at the position provided their feature type is
312 * displayed, and feature group is null or marked for display
314 List<SequenceFeature> result = new ArrayList<>();
315 if (!av.areFeaturesDisplayed() || getFeaturesDisplayed() == null)
320 Set<String> visibleFeatures = getFeaturesDisplayed()
321 .getVisibleFeatures();
322 String[] visibleTypes = visibleFeatures
323 .toArray(new String[visibleFeatures.size()]);
324 List<SequenceFeature> features = sequence.findFeatures(column, column,
328 * include features unless they are hidden (have no colour), based on
329 * feature group visibility, or a filter or colour threshold
331 for (SequenceFeature sf : features)
333 if (getColour(sf) != null)
342 * Searches alignment for all features and updates colours
344 * @param newMadeVisible
345 * if true newly added feature types will be rendered immediately
346 * TODO: check to see if this method should actually be proxied so
347 * repaint events can be propagated by the renderer code
350 public synchronized void findAllFeatures(boolean newMadeVisible)
352 newFeatureAdded = false;
356 newFeatureAdded = true;
360 findingFeatures = true;
361 if (av.getFeaturesDisplayed() == null)
363 av.setFeaturesDisplayed(new FeaturesDisplayed());
365 FeaturesDisplayedI featuresDisplayed = av.getFeaturesDisplayed();
367 Set<String> oldfeatures = new HashSet<>();
368 if (renderOrder != null)
370 for (int i = 0; i < renderOrder.length; i++)
372 if (renderOrder[i] != null)
374 oldfeatures.add(renderOrder[i]);
379 AlignmentI alignment = av.getAlignment();
380 List<String> allfeatures = new ArrayList<>();
382 for (int i = 0; i < alignment.getHeight(); i++)
384 SequenceI asq = alignment.getSequenceAt(i);
385 for (String group : asq.getFeatures().getFeatureGroups(true))
387 boolean groupDisplayed = true;
390 if (featureGroups.containsKey(group))
392 groupDisplayed = featureGroups.get(group);
396 groupDisplayed = newMadeVisible;
397 featureGroups.put(group, groupDisplayed);
402 Set<String> types = asq.getFeatures().getFeatureTypesForGroups(
404 for (String type : types)
406 if (!allfeatures.contains(type)) // or use HashSet and no test?
408 allfeatures.add(type);
410 updateMinMax(asq, type, true); // todo: for all features?
416 // uncomment to add new features in alphebetical order (but JAL-2575)
417 // Collections.sort(allfeatures, String.CASE_INSENSITIVE_ORDER);
420 for (String type : allfeatures)
422 if (!oldfeatures.contains(type))
424 featuresDisplayed.setVisible(type);
430 updateRenderOrder(allfeatures);
431 findingFeatures = false;
435 * Updates the global (alignment) min and max values for a feature type from
436 * the score for a sequence, if the score is not NaN. Values are stored
437 * separately for positional and non-positional features.
443 protected void updateMinMax(SequenceI seq, String featureType,
446 float min = seq.getFeatures().getMinimumScore(featureType, positional);
447 if (Float.isNaN(min))
452 float max = seq.getFeatures().getMaximumScore(featureType, positional);
456 * { {positionalMin, positionalMax}, {nonPositionalMin, nonPositionalMax} }
460 minmax = new Hashtable<>();
462 synchronized (minmax)
464 float[][] mm = minmax.get(featureType);
465 int index = positional ? 0 : 1;
468 mm = new float[][] { null, null };
469 minmax.put(featureType, mm);
471 if (mm[index] == null)
473 mm[index] = new float[] { min, max };
477 mm[index][0] = Math.min(mm[index][0], min);
478 mm[index][1] = Math.max(mm[index][1], max);
482 protected Boolean firing = Boolean.FALSE;
485 * replaces the current renderOrder with the unordered features in
486 * allfeatures. The ordering of any types in both renderOrder and allfeatures
487 * is preserved, and all new feature types are rendered on top of the existing
488 * types, in the order given by getOrder or the order given in allFeatures.
489 * Note. this operates directly on the featureOrder hash for efficiency. TODO:
490 * eliminate the float storage for computing/recalling the persistent ordering
491 * New Cability: updates min/max for colourscheme range if its dynamic
495 private void updateRenderOrder(List<String> allFeatures)
497 List<String> allfeatures = new ArrayList<>(allFeatures);
498 String[] oldRender = renderOrder;
499 renderOrder = new String[allfeatures.size()];
500 boolean initOrders = (featureOrder == null);
502 if (oldRender != null && oldRender.length > 0)
504 for (int j = 0; j < oldRender.length; j++)
506 if (oldRender[j] != null)
510 setOrder(oldRender[j],
511 (1 - (1 + (float) j) / oldRender.length));
513 if (allfeatures.contains(oldRender[j]))
515 renderOrder[opos++] = oldRender[j]; // existing features always
516 // appear below new features
517 allfeatures.remove(oldRender[j]);
520 float[][] mmrange = minmax.get(oldRender[j]);
523 FeatureColourI fc = featureColours.get(oldRender[j]);
524 if (fc != null && !fc.isSimpleColour() && fc.isAutoScaled()
525 && !fc.isColourByAttribute())
527 fc.updateBounds(mmrange[0][0], mmrange[0][1]);
535 if (allfeatures.size() == 0)
537 // no new features - leave order unchanged.
540 int i = allfeatures.size() - 1;
542 boolean sort = false;
543 String[] newf = new String[allfeatures.size()];
544 float[] sortOrder = new float[allfeatures.size()];
545 for (String newfeat : allfeatures)
550 // update from new features minmax if necessary
551 float[][] mmrange = minmax.get(newf[i]);
554 FeatureColourI fc = featureColours.get(newf[i]);
555 if (fc != null && !fc.isSimpleColour() && fc.isAutoScaled()
556 && !fc.isColourByAttribute())
558 fc.updateBounds(mmrange[0][0], mmrange[0][1]);
562 if (initOrders || !featureOrder.containsKey(newf[i]))
564 int denom = initOrders ? allfeatures.size() : featureOrder.size();
565 // new unordered feature - compute persistent ordering at head of
566 // existing features.
567 setOrder(newf[i], i / (float) denom);
569 // set order from newly found feature from persisted ordering.
570 sortOrder[i] = 2 - featureOrder.get(newf[i]).floatValue();
573 // only sort if we need to
574 sort = sort || sortOrder[i] > sortOrder[i + 1];
578 if (iSize > 1 && sort)
580 jalview.util.QuickSort.sort(sortOrder, newf);
583 System.arraycopy(newf, 0, renderOrder, opos, newf.length);
587 * get a feature style object for the given type string. Creates a
588 * java.awt.Color for a featureType with no existing colourscheme.
594 public FeatureColourI getFeatureStyle(String featureType)
596 FeatureColourI fc = featureColours.get(featureType);
599 Color col = ColorUtils.createColourFromName(featureType);
600 fc = new FeatureColour(col);
601 featureColours.put(featureType, fc);
607 public Color getColour(SequenceFeature feature)
609 FeatureColourI fc = getFeatureStyle(feature.getType());
610 return getColor(feature, fc);
614 * Answers true if the feature type is currently selected to be displayed,
620 protected boolean showFeatureOfType(String type)
622 return type == null ? false : (av.getFeaturesDisplayed() == null ? true
623 : av.getFeaturesDisplayed().isVisible(type));
627 public void setColour(String featureType, FeatureColourI col)
629 featureColours.put(featureType, col);
633 public void setTransparency(float value)
635 transparency = value;
639 public float getTransparency()
645 * analogous to colour - store a normalized ordering for all feature types in
646 * this rendering context.
649 * Feature type string
651 * normalized priority - 0 means always appears on top, 1 means
654 public float setOrder(String type, float position)
656 if (featureOrder == null)
658 featureOrder = new Hashtable<>();
660 featureOrder.put(type, new Float(position));
665 * get the global priority (0 (top) to 1 (bottom))
668 * @return [0,1] or -1 for a type without a priority
670 public float getOrder(String type)
672 if (featureOrder != null)
674 if (featureOrder.containsKey(type))
676 return featureOrder.get(type).floatValue();
683 public Map<String, FeatureColourI> getFeatureColours()
685 return featureColours;
689 * Replace current ordering with new ordering
692 * an array of { Type, Colour, Filter, Boolean }
693 * @return true if any visible features have been reordered, else false
695 public boolean setFeaturePriority(FeatureSettingsBean[] data)
697 return setFeaturePriority(data, true);
701 * Sets the priority order for features, with the highest priority (displayed on
702 * top) at the start of the data array
705 * an array of { Type, Colour, Filter, Boolean }
707 * when true current featureDisplay list will be cleared
708 * @return true if any visible features have been reordered or recoloured, else
709 * false (i.e. no need to repaint)
711 public boolean setFeaturePriority(FeatureSettingsBean[] data,
715 * note visible feature ordering and colours before update
717 List<String> visibleFeatures = getDisplayedFeatureTypes();
718 Map<String, FeatureColourI> visibleColours = new HashMap<>(
719 getFeatureColours());
721 FeaturesDisplayedI av_featuresdisplayed = null;
724 if ((av_featuresdisplayed = av.getFeaturesDisplayed()) != null)
726 av.getFeaturesDisplayed().clear();
730 av.setFeaturesDisplayed(
731 av_featuresdisplayed = new FeaturesDisplayed());
736 av_featuresdisplayed = av.getFeaturesDisplayed();
742 // The feature table will display high priority
743 // features at the top, but these are the ones
744 // we need to render last, so invert the data
745 renderOrder = new String[data.length];
749 for (int i = 0; i < data.length; i++)
751 String type = data[i].featureType;
752 setColour(type, data[i].featureColour);
755 av_featuresdisplayed.setVisible(type);
758 renderOrder[data.length - i - 1] = type;
763 * get the new visible ordering and return true if it has changed
764 * order or any colour has changed
766 List<String> reorderedVisibleFeatures = getDisplayedFeatureTypes();
767 if (!visibleFeatures.equals(reorderedVisibleFeatures))
770 * the list of ordered visible features has changed
776 * return true if any feature colour has changed
778 for (String feature : visibleFeatures)
780 if (visibleColours.get(feature) != getFeatureStyle(feature))
790 * @see java.beans.PropertyChangeSupport#addPropertyChangeListener(java.beans.PropertyChangeListener)
792 public void addPropertyChangeListener(PropertyChangeListener listener)
794 changeSupport.addPropertyChangeListener(listener);
799 * @see java.beans.PropertyChangeSupport#removePropertyChangeListener(java.beans.PropertyChangeListener)
801 public void removePropertyChangeListener(PropertyChangeListener listener)
803 changeSupport.removePropertyChangeListener(listener);
806 public Set<String> getAllFeatureColours()
808 return featureColours.keySet();
811 public void clearRenderOrder()
816 public boolean hasRenderOrder()
818 return renderOrder != null;
822 * Returns feature types in ordering of rendering, where last means on top
824 public List<String> getRenderOrder()
826 if (renderOrder == null)
828 return Arrays.asList(new String[] {});
830 return Arrays.asList(renderOrder);
833 public int getFeatureGroupsSize()
835 return featureGroups != null ? 0 : featureGroups.size();
839 public List<String> getFeatureGroups()
841 // conflict between applet and desktop - featureGroups returns the map in
842 // the desktop featureRenderer
843 return (featureGroups == null) ? Arrays.asList(new String[0])
844 : Arrays.asList(featureGroups.keySet().toArray(new String[0]));
847 public boolean checkGroupVisibility(String group,
848 boolean newGroupsVisible)
850 if (featureGroups == null)
852 // then an exception happens next..
854 if (featureGroups.containsKey(group))
856 return featureGroups.get(group).booleanValue();
858 if (newGroupsVisible)
860 featureGroups.put(group, new Boolean(true));
867 * get visible or invisible groups
870 * true to return visible groups, false to return hidden ones.
871 * @return list of groups
874 public List<String> getGroups(boolean visible)
876 if (featureGroups != null)
878 List<String> gp = new ArrayList<>();
880 for (String grp : featureGroups.keySet())
882 Boolean state = featureGroups.get(grp);
883 if (state.booleanValue() == visible)
894 public void setGroupVisibility(String group, boolean visible)
896 featureGroups.put(group, new Boolean(visible));
900 public void setGroupVisibility(List<String> toset, boolean visible)
902 if (toset != null && toset.size() > 0 && featureGroups != null)
904 boolean rdrw = false;
905 for (String gst : toset)
907 Boolean st = featureGroups.get(gst);
908 featureGroups.put(gst, new Boolean(visible));
911 rdrw = rdrw || (visible != st.booleanValue());
916 // set local flag indicating redraw needed ?
922 public Map<String, FeatureColourI> getDisplayedFeatureCols()
924 Map<String, FeatureColourI> fcols = new Hashtable<>();
925 if (getViewport().getFeaturesDisplayed() == null)
929 Set<String> features = getViewport().getFeaturesDisplayed()
930 .getVisibleFeatures();
931 for (String feature : features)
933 fcols.put(feature, getFeatureStyle(feature));
939 public FeaturesDisplayedI getFeaturesDisplayed()
941 return av.getFeaturesDisplayed();
945 * Returns a (possibly empty) list of visible feature types, in render order
949 public List<String> getDisplayedFeatureTypes()
951 List<String> typ = getRenderOrder();
952 List<String> displayed = new ArrayList<>();
953 FeaturesDisplayedI feature_disp = av.getFeaturesDisplayed();
954 if (feature_disp != null)
956 synchronized (feature_disp)
958 for (String type : typ)
960 if (feature_disp.isVisible(type))
971 public List<String> getDisplayedFeatureGroups()
973 List<String> _gps = new ArrayList<>();
974 for (String gp : getFeatureGroups())
976 if (checkGroupVisibility(gp, false))
985 * Answers true if the feature belongs to a feature group which is not
986 * currently displayed, else false
988 * @param sequenceFeature
991 public boolean featureGroupNotShown(final SequenceFeature sequenceFeature)
993 return featureGroups != null
994 && sequenceFeature.featureGroup != null
995 && sequenceFeature.featureGroup.length() != 0
996 && featureGroups.containsKey(sequenceFeature.featureGroup)
997 && !featureGroups.get(sequenceFeature.featureGroup)
1005 public List<SequenceFeature> findFeaturesAtResidue(SequenceI sequence,
1006 int fromResNo, int toResNo)
1008 List<SequenceFeature> result = new ArrayList<>();
1009 if (!av.areFeaturesDisplayed() || getFeaturesDisplayed() == null)
1015 * include features at the position provided their feature type is
1016 * displayed, and feature group is null or the empty string
1017 * or marked for display
1019 Set<String> visibleFeatures = getFeaturesDisplayed()
1020 .getVisibleFeatures();
1021 String[] visibleTypes = visibleFeatures
1022 .toArray(new String[visibleFeatures.size()]);
1023 List<SequenceFeature> features = sequence.getFeatures().findFeatures(
1024 fromResNo, toResNo, visibleTypes);
1026 for (SequenceFeature sf : features)
1028 if (!featureGroupNotShown(sf) && getColour(sf) != null)
1037 * Removes from the list of features any that duplicate the location of a
1038 * feature of the same type. Should be used only for features of the same,
1039 * simple, feature colour (which normally implies the same feature type). Does
1040 * not check visibility settings for feature type or feature group. No
1041 * filtering is done if transparency, or any feature filters, are in force.
1045 public void filterFeaturesForDisplay(List<SequenceFeature> features)
1048 * don't remove 'redundant' features if
1049 * - transparency is applied (feature count affects depth of feature colour)
1050 * - filters are applied (not all features may be displayable)
1052 if (features.isEmpty() || transparency != 1f
1053 || !featureFilters.isEmpty())
1058 SequenceFeatures.sortFeatures(features, true);
1059 SequenceFeature lastFeature = null;
1061 Iterator<SequenceFeature> it = features.iterator();
1062 while (it.hasNext())
1064 SequenceFeature sf = it.next();
1067 * a feature is redundant for rendering purposes if it has the
1068 * same extent as another (so would just redraw the same colour);
1069 * (checking type and isContactFeature as a fail-safe here, although
1070 * currently they are guaranteed to match in this context)
1072 if (lastFeature != null && sf.getBegin() == lastFeature.getBegin()
1073 && sf.getEnd() == lastFeature.getEnd()
1074 && sf.isContactFeature() == lastFeature.isContactFeature()
1075 && sf.getType().equals(lastFeature.getType()))
1084 public Map<String, FeatureMatcherSetI> getFeatureFilters()
1086 return featureFilters;
1090 public void setFeatureFilters(Map<String, FeatureMatcherSetI> filters)
1092 featureFilters = filters;
1096 public FeatureMatcherSetI getFeatureFilter(String featureType)
1098 return featureFilters.get(featureType);
1102 public void setFeatureFilter(String featureType, FeatureMatcherSetI filter)
1104 if (filter == null || filter.isEmpty())
1106 featureFilters.remove(featureType);
1110 featureFilters.put(featureType, filter);
1115 * Answers the colour for the feature, or null if the feature is excluded by
1116 * feature group visibility, by filters, or by colour threshold settings. This
1117 * method does not take feature visibility into account.
1123 public Color getColor(SequenceFeature sf, FeatureColourI fc)
1126 * is the feature group displayed?
1128 if (featureGroupNotShown(sf))
1134 * does the feature pass filters?
1136 if (!featureMatchesFilters(sf))
1141 return fc.getColor(sf);
1145 * Answers true if there no are filters defined for the feature type, or this
1146 * feature matches the filters. Answers false if the feature fails to match
1152 protected boolean featureMatchesFilters(SequenceFeature sf)
1154 FeatureMatcherSetI filter = featureFilters.get(sf.getType());
1155 return filter == null ? true : filter.matches(sf);
1159 * Answers a (possibly empty) list of features in this alignment at a position
1160 * (or range) which is mappable from the given sequence residue position in a
1167 public List<SequenceFeature> findComplementFeaturesAtResidue(SequenceI sequence, int pos)
1169 SequenceI ds = sequence.getDatasetSequence();
1170 List<SequenceFeature> result = new ArrayList<>();
1171 List<AlignedCodonFrame> mappings = this.av.getAlignment()
1172 .getCodonFrame(sequence);
1175 * todo: direct lookup of CDS for peptide and vice-versa; for now,
1176 * have to search through an unordered list of mappings for a candidate
1178 for (AlignedCodonFrame acf : mappings)
1180 Mapping mapping = acf.getMappingForSequence(sequence, true);
1181 if (mapping == null || mapping.getMap().getFromRatio() == mapping
1182 .getMap().getToRatio())
1184 continue; // we are only looking for 3:1 or 1:3 mappings
1186 SearchResultsI sr = new SearchResults();
1187 acf.markMappedRegion(ds, pos, sr);
1188 for (SearchResultMatchI match : sr.getResults())
1190 int fromRes = match.getStart();
1191 int toRes = match.getEnd();
1192 List<SequenceFeature> fs = findFeaturesAtResidue(
1193 match.getSequence(), fromRes, toRes);
1194 for (SequenceFeature sf : fs)
1196 if (!result.contains(sf))