boolean markColumnsContainingFeatures(boolean invert,
boolean extendCurrent, boolean clearColumns, String featureType);
+ /**
+ * sort the alignment or current selection by average score over the given set of features
+ * @param typ list of feature names or null to use currently displayed features
+ */
+ void sortAlignmentByFeatureScore(String[] typ);
+
+ /**
+ * sort the alignment or current selection by distribution of the given set of features
+ * @param typ list of feature names or null to use currently displayed features
+ */
+ void sortAlignmentByFeatureDensity(String[] typ);
+
}
package jalview.controller;
import java.awt.Color;
+import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
+import jalview.analysis.AlignmentSorter;
import jalview.api.AlignViewControllerGuiI;
import jalview.api.AlignViewControllerI;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
+import jalview.api.FeatureRenderer;
+import jalview.commands.OrderCommand;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AnnotatedCollectionI;
import jalview.datamodel.ColumnSelection;
return false;
}
}
+
+ @Override
+ public void sortAlignmentByFeatureDensity(String[] typ)
+ {
+ sortBy(typ, "Sort by Density", AlignmentSorter.FEATURE_DENSITY);
+ }
+
+ protected void sortBy(String[] typ, String methodText, final String method)
+ {
+ FeatureRenderer fr = alignPanel.getFeatureRenderer();
+ if (typ == null)
+ {
+ typ = fr==null ? null : fr.getDisplayedFeatureTypes();
+ }
+ String gps[] = null;
+ gps = fr==null ? null : fr.getDisplayedFeatureGroups();
+ if (typ != null)
+ {
+ ArrayList types = new ArrayList();
+ for (int i = 0; i < typ.length; i++)
+ {
+ if (typ[i] != null)
+ {
+ types.add(typ[i]);
+ }
+ typ = new String[types.size()];
+ types.toArray(typ);
+ }
+ }
+ if (gps != null)
+ {
+ ArrayList grps = new ArrayList();
+
+ for (int i = 0; i < gps.length; i++)
+ {
+ if (gps[i] != null)
+ {
+ grps.add(gps[i]);
+ }
+ }
+ gps = new String[grps.size()];
+ grps.toArray(gps);
+ }
+ AlignmentI al = viewport.getAlignment();
+
+ int start, stop;
+ SequenceGroup sg = viewport.getSelectionGroup();
+ if (sg != null)
+ {
+ start = sg.getStartRes();
+ stop = sg.getEndRes();
+ }
+ else
+ {
+ start = 0;
+ stop = al.getWidth();
+ }
+ SequenceI[] oldOrder = al.getSequencesArray();
+ AlignmentSorter.sortByFeature(typ, gps, start, stop, al, method);
+ avcg.addHistoryItem(new OrderCommand(methodText, oldOrder, viewport
+ .getAlignment()));
+ alignPanel.paintAlignment(true);
+
+ }
+
+ @Override
+ public void sortAlignmentByFeatureScore(String[] typ)
+ {
+ sortBy(typ, "Sort by Feature Score", AlignmentSorter.FEATURE_SCORE);
+ }
}