git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
02c53ff
)
fix order/reverse order issue for sortByFeature
author
jprocter
<Jim Procter>
Wed, 14 Apr 2010 14:35:51 +0000
(14:35 +0000)
committer
jprocter
<Jim Procter>
Wed, 14 Apr 2010 14:35:51 +0000
(14:35 +0000)
src/jalview/analysis/AlignmentSorter.java
patch
|
blob
|
history
diff --git
a/src/jalview/analysis/AlignmentSorter.java
b/src/jalview/analysis/AlignmentSorter.java
index
bb55426
..
c4436eb
100755
(executable)
--- a/
src/jalview/analysis/AlignmentSorter.java
+++ b/
src/jalview/analysis/AlignmentSorter.java
@@
-40,6
+40,10
@@
import jalview.util.*;
*/
public class AlignmentSorter
{
*/
public class AlignmentSorter
{
+ /**
+ * todo: refactor searches to follow a basic pattern:
+ * (search property, last search state, current sort direction)
+ */
static boolean sortIdAscending = true;
static int lastGroupHash = 0;
static boolean sortIdAscending = true;
static int lastGroupHash = 0;
@@
-58,11
+62,12
@@
public class AlignmentSorter
* last Annotation Label used by sortByScore
*/
private static String lastSortByScore;
* last Annotation Label used by sortByScore
*/
private static String lastSortByScore;
-
+ private static boolean sortByScoreAscending = true;
/**
* compact representation of last arguments to SortByFeatureScore
*/
private static String lastSortByFeatureScore;
/**
* compact representation of last arguments to SortByFeatureScore
*/
private static String lastSortByFeatureScore;
+ private static boolean sortByFeatureScoreAscending = true;
private static boolean sortLengthAscending;
private static boolean sortLengthAscending;
@@
-361,7
+366,7
@@
public class AlignmentSorter
private static SequenceI[] vectorSubsetToArray(Vector tmp, Vector mask)
{
Vector seqs = new Vector();
private static SequenceI[] vectorSubsetToArray(Vector tmp, Vector mask)
{
Vector seqs = new Vector();
- int i;
+ int i,idx;
boolean[] tmask = new boolean[mask.size()];
for (i = 0; i < mask.size(); i++)
boolean[] tmask = new boolean[mask.size()];
for (i = 0; i < mask.size(); i++)
@@
-372,10
+377,10
@@
public class AlignmentSorter
for (i = 0; i < tmp.size(); i++)
{
Object sq = tmp.elementAt(i);
for (i = 0; i < tmp.size(); i++)
{
Object sq = tmp.elementAt(i);
-
- if (mask.contains(sq) && tmask[mask.indexOf(sq)])
+ idx = mask.indexOf(sq);
+ if (idx>-1 && tmask[idx])
{
{
- tmask[mask.indexOf(sq)] = false;
+ tmask[idx] = false;
seqs.addElement(sq);
}
}
seqs.addElement(sq);
}
}
@@
-719,7
+724,7
@@
public class AlignmentSorter
boolean ignoreScore=method!=FEATURE_SCORE;
StringBuffer scoreLabel = new StringBuffer();
scoreLabel.append(start+stop+method);
boolean ignoreScore=method!=FEATURE_SCORE;
StringBuffer scoreLabel = new StringBuffer();
scoreLabel.append(start+stop+method);
- // This doesn't work yet - we'd like to have a canonical ordering that can be preserved from call to call
+ // This doesn't quite work yet - we'd like to have a canonical ordering that can be preserved from call to call
for (int i=0;featureLabels!=null && i<featureLabels.length; i++)
{
scoreLabel.append(featureLabels[i]==null ? "null" : featureLabels[i]);
for (int i=0;featureLabels!=null && i<featureLabels.length; i++)
{
scoreLabel.append(featureLabels[i]==null ? "null" : featureLabels[i]);
@@
-851,10
+856,10
@@
public class AlignmentSorter
{
if (!hasScore[i])
{
{
if (!hasScore[i])
{
- scores[i] = (max + i);
+ scores[i] = (max + 1+i);
} else {
int nf=(feats[i]==null) ? 0 :((SequenceFeature[]) feats[i]).length;
} else {
int nf=(feats[i]==null) ? 0 :((SequenceFeature[]) feats[i]).length;
- System.err.println("Sorting on Score: seq "+seqs[i].getName()+ " Feats: "+nf+" Score : "+scores[i]);
+ // System.err.println("Sorting on Score: seq "+seqs[i].getName()+ " Feats: "+nf+" Score : "+scores[i]);
}
}
}
}
}
}
@@
-871,7
+876,7
@@
public class AlignmentSorter
{
double nf;
scores[i] = (0.05+fr*i)+(nf=((feats[i]==null) ? 0.0 :1.0*((SequenceFeature[]) feats[i]).length));
{
double nf;
scores[i] = (0.05+fr*i)+(nf=((feats[i]==null) ? 0.0 :1.0*((SequenceFeature[]) feats[i]).length));
- System.err.println("Sorting on Density: seq "+seqs[i].getName()+ " Feats: "+nf+" Score : "+scores[i]);
+ // System.err.println("Sorting on Density: seq "+seqs[i].getName()+ " Feats: "+nf+" Score : "+scores[i]);
}
jalview.util.QuickSort.sort(scores, seqs);
}
}
jalview.util.QuickSort.sort(scores, seqs);
}
@@
-881,12
+886,17
@@
public class AlignmentSorter
throw new Error("Not yet implemented.");
}
}
throw new Error("Not yet implemented.");
}
}
- if (lastSortByFeatureScore ==null || scoreLabel.equals(lastSortByFeatureScore))
+ if (lastSortByFeatureScore ==null || !scoreLabel.toString().equals(lastSortByFeatureScore))
{
{
+ sortByFeatureScoreAscending = true;
+ } else {
+ sortByFeatureScoreAscending = !sortByFeatureScoreAscending;
+ }
+ if (sortByFeatureScoreAscending) {
setOrder(alignment, seqs);
}
else
setOrder(alignment, seqs);
}
else
- {
+ {
setReverseOrder(alignment, seqs);
}
lastSortByFeatureScore = scoreLabel.toString();
setReverseOrder(alignment, seqs);
}
lastSortByFeatureScore = scoreLabel.toString();