From 198a4921d78d176afc0cb709bdbcb4627afd1e8b Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 16 Nov 2007 11:30:01 +0000 Subject: [PATCH] todo for sortbyPID operating on current selection rather than all alignment --- src/jalview/analysis/AlignmentSorter.java | 12 +++++++++--- src/jalview/appletgui/AlignFrame.java | 2 +- src/jalview/gui/AlignFrame.java | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/jalview/analysis/AlignmentSorter.java b/src/jalview/analysis/AlignmentSorter.java index cde4b4f..a3493f7 100755 --- a/src/jalview/analysis/AlignmentSorter.java +++ b/src/jalview/analysis/AlignmentSorter.java @@ -25,7 +25,12 @@ import jalview.util.*; /** * Routines for manipulating the order of a multiple sequence alignment - * TODO: this class retains some global states concerning sort-order which should be made attributes for the caller's alignment visualization. + * TODO: this class retains some global states concerning sort-order which should be made attributes for the caller's alignment visualization. + * TODO: refactor to allow a subset of selected sequences to be sorted within the context of a whole alignment. + * Sort method template is: SequenceI[] tobesorted, [ input data mapping to each tobesorted element to use ], Alignment context of tobesorted that are to be re-ordered, boolean sortinplace, [special data - ie seuqence to be sorted w.r.t.]) + * sortinplace implies that the sorted vector resulting from applying the operation to tobesorted should be mapped back to the original positions in alignment. + * Otherwise, normal behaviour is to re order alignment so that tobesorted is sorted and grouped together starting from the first tobesorted position in the alignment. + * e.g. (a,tb2,b,tb1,c,tb3 becomes a,tb1,tb2,tb3,b,c) */ public class AlignmentSorter { @@ -39,12 +44,13 @@ public class AlignmentSorter private static String lastSortByScore; /** - * Sort by Percentage Identity + * Sort by Percentage Identity w.r.t. s * * @param align AlignmentI * @param s SequenceI + * @param tosort sequences from align that are to be sorted. */ - public static void sortByPID(AlignmentI align, SequenceI s) + public static void sortByPID(AlignmentI align, SequenceI s, SequenceI[] tosort) { int nSeq = align.getHeight(); diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 5b6a8a5..5620a3e 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -2106,7 +2106,7 @@ public class AlignFrame { SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); AlignmentSorter.sortByPID(viewport.getAlignment(), - viewport.getAlignment().getSequenceAt(0)); + viewport.getAlignment().getSequenceAt(0), null); addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, viewport.alignment)); alignPanel.paintAlignment(true); diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 289ffbc..1c488fe 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -2866,7 +2866,7 @@ public class AlignFrame { SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray(); AlignmentSorter.sortByPID(viewport.getAlignment(), - viewport.getAlignment().getSequenceAt(0)); + viewport.getAlignment().getSequenceAt(0), null); addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder, viewport.alignment)); alignPanel.paintAlignment(true); @@ -3129,7 +3129,7 @@ public class AlignFrame public void actionPerformed(ActionEvent e) { SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray(); - AlignmentSorter.sortByAnnotationScore(scoreLabel, viewport.getAlignment()); + AlignmentSorter.sortByAnnotationScore(scoreLabel, viewport.getAlignment());//,viewport.getSelectionGroup()); addHistoryItem(new OrderCommand("Sort by "+scoreLabel, oldOrder, viewport.alignment)); alignPanel.paintAlignment(true); } -- 1.7.10.2