X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequenceFeature.java;h=30e0929e7f4d7573fd481e54da13608fa8666018;hb=b74cdec4b07000bee431a7cca86a948f44d3ffbe;hp=bf2408c79e2ec7d4ff1ff9888861bbe86019a582;hpb=3d4ead4880755ec949de0300c232544ba965e60d;p=jalview.git diff --git a/src/jalview/datamodel/SequenceFeature.java b/src/jalview/datamodel/SequenceFeature.java index bf2408c..30e0929 100755 --- a/src/jalview/datamodel/SequenceFeature.java +++ b/src/jalview/datamodel/SequenceFeature.java @@ -35,6 +35,8 @@ import java.util.SortedMap; import java.util.TreeMap; import java.util.Vector; +import intervalstore.api.IntervalI; + /** * A class that models a single contiguous feature on a sequence. If flag * 'contactFeature' is true, the start and end positions are interpreted instead @@ -99,11 +101,6 @@ public class SequenceFeature implements FeatureLocationI */ private String source; - // for Overview sort: - public int index; - - public SequenceFeature containedBy; - /** * Constructs a duplicate feature. Note: Uses makes a shallow copy of the * otherDetails map, so the new and original SequenceFeature may reference the @@ -222,10 +219,20 @@ public class SequenceFeature implements FeatureLocationI @Override public boolean equals(Object o) { - return equals(o, false); + return (o != null && (o instanceof SequenceFeature) + && equalsInterval((SequenceFeature) o)); } /** + * Having determined that this is in fact a SequenceFeature, now check it for + * equivalence. Overridden in CrossRef; used by IntervalStore (possibly). + */ + @Override + public boolean equalsInterval(IntervalI sf) + { + return sf != null && equals((SequenceFeature) sf, false); + } + /** * Overloaded method allows the equality test to optionally ignore the * 'Parent' attribute of a feature. This supports avoiding adding many * superficially duplicate 'exon' or CDS features to genomic or protein @@ -235,47 +242,19 @@ public class SequenceFeature implements FeatureLocationI * @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")))); } /** @@ -741,6 +720,8 @@ public class SequenceFeature implements FeatureLocationI { source = theSource; } + + } class SFSortByEnd implements Comparator