X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAlignmentSorter.java;h=f2b2222aba7f0c948bc9463b0e725a17ebb7f5fb;hb=586ade46bdcd05ff028a1cff82c3c527326d28ec;hp=af7db0af83daebba1f86816e3e5012e2e63d05b7;hpb=54f6fe32b978af0932428981a56c9960b0df44a7;p=jalview.git diff --git a/src/jalview/analysis/AlignmentSorter.java b/src/jalview/analysis/AlignmentSorter.java index af7db0a..f2b2222 100755 --- a/src/jalview/analysis/AlignmentSorter.java +++ b/src/jalview/analysis/AlignmentSorter.java @@ -113,6 +113,10 @@ public class AlignmentSorter implements ApplicationSingletonI private boolean sortLengthAscending; + private static boolean sortEValueAscending; + + private static boolean sortBitScoreAscending; + /** * Sorts sequences in the alignment by Percentage Identity with the given * reference sequence, sorting the highest identity to the top @@ -196,6 +200,90 @@ public class AlignmentSorter implements ApplicationSingletonI } /** + * Sorts by sequence evalue. Currently moves all sequences without an evalue to + * the top of the alignment. + * + * @param align + * The alignment object to sort + */ + public static void sortByEValue(AlignmentI align) + { + int nSeq = align.getHeight(); + + double[] evalue = new double[nSeq]; + SequenceI[] seqs = new SequenceI[nSeq]; + + for (int i = 0; i < nSeq; i++) + { + seqs[i] = align.getSequenceAt(i); + AlignmentAnnotation[] ann = seqs[i].getAnnotation("Search Scores"); + if (ann != null) + { + evalue[i] = ann[0].getEValue(); + } + else + { + evalue[i] = -1; + } + } + + QuickSort.sort(evalue, seqs); + + if (sortEValueAscending) + { + setReverseOrder(align, seqs); + } + else + { + setOrder(align, seqs); + } + + sortEValueAscending = !sortEValueAscending; + } + + /** + * Sorts by sequence bit score. Currently moves all sequences without a bit + * score to the top of the alignment + * + * @param align + * The alignment object to sort + */ + public static void sortByBitScore(AlignmentI align) + { + int nSeq = align.getHeight(); + + double[] score = new double[nSeq]; + SequenceI[] seqs = new SequenceI[nSeq]; + + for (int i = 0; i < nSeq; i++) + { + seqs[i] = align.getSequenceAt(i); + AlignmentAnnotation[] ann = seqs[i].getAnnotation("Search Scores"); + if (ann != null) + { + score[i] = ann[0].getEValue(); + } + else + { + score[i] = -1; + } + } + + QuickSort.sort(score, seqs); + + if (sortBitScoreAscending) + { + setReverseOrder(align, seqs); + } + else + { + setOrder(align, seqs); + } + + sortBitScoreAscending = !sortBitScoreAscending; + } + + /** * Sorts the alignment by size of group.
* Maintains the order of sequences in each group by order in given alignment * object.