/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
+ * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
*/
private static String lastSortByFeatureScore;
+ private static boolean sortLengthAscending;
+
/**
* Sort by Percentage Identity w.r.t. s
*
public static void sortByPID(AlignmentI align, SequenceI s,
SequenceI[] tosort)
{
+ sortByPID(align,s,tosort,0,-1);
+ }
+ /**
+ * Sort by Percentage Identity w.r.t. s
+ *
+ * @param align
+ * AlignmentI
+ * @param s
+ * SequenceI
+ * @param tosort
+ * sequences from align that are to be sorted.
+ * @param start start column (0 for beginning
+ * @param end
+ */
+ public static void sortByPID(AlignmentI align, SequenceI s,
+ SequenceI[] tosort,int start, int end)
+ {
int nSeq = align.getHeight();
float[] scores = new float[nSeq];
sortIdAscending = !sortIdAscending;
}
+ /**
+ * Sorts by sequence length
+ *
+ * @param align
+ * The alignment object to sort
+ */
+ public static void sortByLength(AlignmentI align)
+ {
+ int nSeq = align.getHeight();
+
+ float[] length = new float[nSeq];
+ SequenceI[] seqs = new SequenceI[nSeq];
+
+ for (int i = 0; i < nSeq; i++)
+ {
+ seqs[i] = align.getSequenceAt(i);
+ length[i] = (float) (seqs[i].getEnd()-seqs[i].getStart());
+ }
+
+ QuickSort.sort(length, seqs);
+
+ if (sortLengthAscending)
+ {
+ setReverseOrder(align, seqs);
+ }
+ else
+ {
+ setOrder(align, seqs);
+ }
+
+ sortLengthAscending = !sortLengthAscending;
+ }
/**
* Sorts the alignment by size of group. <br>
||
// or ignore based on selection criteria
(featureLabels != null && !AlignmentSorter.containsIgnoreCase(sf[f].type, featureLabels))
- || (groupLabels != null
- && (sf[f].getFeatureGroup() == null
- || !AlignmentSorter.containsIgnoreCase(sf[f].getFeatureGroup(), groupLabels))))
+ || (groupLabels != null
+ // problem here: we cannot eliminate null feature group features
+ && (sf[f].getFeatureGroup() != null
+ && !AlignmentSorter.containsIgnoreCase(sf[f].getFeatureGroup(), groupLabels))))
{
// forget about this feature
sf[f] = null;