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
@Override
public boolean equals(Object o)
{
- return (o != null && (o instanceof SequenceFeature)
- && equalsInterval((SequenceFeature) o));
+ return (o instanceof SequenceFeature
+ && equals((SequenceFeature) o, false));
}
/**
- * 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 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
*/
public boolean equals(SequenceFeature sf, boolean ignoreParent)
{
- 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"))));
}
/**