[Biojava-dev] Problem with ranks

george waldon gwaldon at geneinfinity.org
Tue Sep 12 00:38:41 UTC 2006


Hi,

I am having difficulties to use ranking with some objects found in SimpleRichSequence. There are 6 objects contained in SimpleRichSequence which are found within collections, namely SimpleComment, SimpleRankedCrossRef, SimpleRankedDocRef, SimpleNote, SimpleBioEntryRelationShip, and SimpleRichFeature. Each of them is associated with a TreeSet and uses to some extend ranking for comparison.

Ranks are never described but the name suggests that they are positive integer, in consecutive order and not identical for similar objects within the same sequence. Here are some questions:

- Can rank be negative? We would assume not but this is never checked.
- If rank cannot be negative, where do they start, 0, 1? SimpleBioEntryRelationShip suggests that they start at 1 with 0 reserved for absence of ranking.
- Are we expecting ranks to be in consecutive order (or in reasonable consecutive order) or values like 1000, 2000, etc. are possible or even expected?
- Can we have duplicate ranks? We would assume not but SimpleRichFeature javadoc indicates that equal ranks are *acceptable*.

SimpleBioEntryRelationship getRank method returns an Integer object, all the other objects return an integer number. Any reason for this?

Moreover 3 of these objects do not have a setRank method: SimpleComment, SimpleRankedCrossRef and SimpleRankedDocRef. How do I insert a comment in the middle of other comments, how do I change the order of these objects without creating new ones?

All these objects have an ordering consistent with equality except SimpleRichFeature. SimpleRichFeature are sorted by rank only. Its compareTo method also never returns 0. A consequence is that removeFeature in ThinRichSequence never works because TreeSet uses compareTo for testing equality.

All compareTo methods use rank first except SimpleRankedDocRef which does not use rank at all (but is ranked as its name indicates).

A few objects are nearly identical when they are equal but not all. SimpleNote compares by rank then by term but not by value. SimpleNotes of same rank and term but different values are nevertheless equal. SimpleRankedDocRef can be equal and have different locations – I can understand this. 

We need a clear definition of what ranks are, what the ordering they imply is intended for and how to deal with duplicate ranks? Maybe we could have an interface that encapsulates the concept of ranking, e.g. interface Ranked, methods setRank() and getRank()) and all these information grouped in the javadoc. It seems easier to derive exceptions from a common pattern that the opposite. Maybe we also need separate comparators when they are not consistent with equal. 

Thanks,
George









More information about the biojava-dev mailing list