import jalview.datamodel.features.FeatureSources;
import jalview.util.StringUtils;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@Override
public boolean equals(Object o)
{
- return equals(o, false);
+ return (o instanceof SequenceFeature
+ && equals((SequenceFeature) o, false));
}
/**
* @param ignoreParent
* @return
*/
- public boolean equals(Object o, boolean ignoreParent)
+ public boolean equals(SequenceFeature sf, boolean ignoreParent)
{
- if (o == null || !(o instanceof SequenceFeature))
- {
- return false;
- }
-
- SequenceFeature sf = (SequenceFeature) o;
- boolean sameScore = Float.isNaN(score) ? Float.isNaN(sf.score)
- : score == sf.score;
- if (begin != sf.begin || end != sf.end || !sameScore)
- {
- return false;
- }
-
- if (getStrand() != sf.getStrand())
- {
- return false;
- }
-
- if (!(type + description + featureGroup + getPhase()).equals(
- sf.type + sf.description + sf.featureGroup + sf.getPhase()))
- {
- return false;
- }
- if (!equalAttribute(getValue("ID"), sf.getValue("ID")))
- {
- return false;
- }
- if (!equalAttribute(getValue("Name"), sf.getValue("Name")))
- {
- return false;
- }
- if (!ignoreParent)
- {
- if (!equalAttribute(getValue("Parent"), sf.getValue("Parent")))
- {
- return false;
- }
- }
- return true;
+ return (begin == sf.begin && end == sf.end
+ && getStrand() == sf.getStrand()
+ && (Float.isNaN(score) ? Float.isNaN(sf.score)
+ : score == sf.score)
+ && (type + description + featureGroup + getPhase())
+ .equals(sf.type + sf.description + sf.featureGroup
+ + sf.getPhase())
+ && equalAttribute(getValue("ID"), sf.getValue("ID"))
+ && equalAttribute(getValue("Name"), sf.getValue("Name"))
+ && (ignoreParent || equalAttribute(getValue("Parent"),
+ sf.getValue("Parent"))));
}
/**
{
source = theSource;
}
+
+
+}
+
+class SFSortByEnd implements Comparator<SequenceFeature>
+{
+ @Override
+ public int compare(SequenceFeature a, SequenceFeature b)
+ {
+ return a.getEnd() - b.getEnd();
+ }
+}
+
+class SFSortByBegin implements Comparator<SequenceFeature>
+{
+ @Override
+ public int compare(SequenceFeature a, SequenceFeature b)
+ {
+ return a.getBegin() - b.getBegin();
+ }
}