0 or 1 based ranges ? (was: [Biococoa-dev] Annotation)

Charles PARNOT charles.parnot at stanford.edu
Tue Feb 22 23:05:24 EST 2005

At 7:58 PM -0500 2/22/05, Koen van der Drift wrote:
>On Feb 22, 2005, at 1:32 PM, Alexander Griekspoor wrote:
>>>>- do we use 1 or 0 based ranges? For the first 10 bases, do I create a range {0,10} or {1,10}. I think it would be nicest to use NSRanges, we can compensate in the accessors if necessary I guess...
>>>The issue of 0 vs 1 is  a problem with cDNAs and the transcription or translation starting point, or is it a more widely used convention? One problem with the +1 convention is the absence of 0, IIRC. The positions goes -2, -1, +1, +2, right?
>>Yes, guess so, but those are relative positions, so 0 in that case is the base itself.
>>>Anyway, that's a tough question. IMO, we should use a 0 based range to stick to the Cocoa conventions. In the Cocoa NSRange convention, the first character of a string is anyway not at position 0 or 1, but in between the two!
>>Yep, I would like to have it 0 based as well.... The ranges the findSubsequence methods use are also 0-based right? Guess, that's settled then... Correct me if I'm wrong but I believe BioJava's sequences are 1-based, but Koen might know better.
>Ha, I missed this in all the messages from today, and already replied on Alex's original question in a separate email. Yes, I think BioJava uses a 1-based sequence. But I don't think Java have nice build-in array's, so they had to write them theirselves. As I said, internally we can use the 0-based code. However, imagine a find sequence dialog window. That should accept and return values that are 1-based. Should that be the responsibility of the developer, or should it be BioCocoa's? I would say the latter, but if we decide on going 0-based all the way, then we have to document that very well.

Maybe we should have some methods that explicitely give the choice to the user of the framework? The convention for ranges is so well established that it is going to be confusing for us and for some users. So we could have methods like 'subsequenceWithRange:' and 'subsequenceWithSequenceRange:'.... the naming is not very good, uh?

Actually, maybe we could create a new struct to handle 1-based ranges, something like BCSequenceRange??


Help science go fast forward:

Charles Parnot
charles.parnot at stanford.edu

Room  B157 in Beckman Center
279, Campus Drive
Stanford University
Stanford, CA 94305 (USA)

Tel +1 650 725 7754
Fax +1 650 725 8021

More information about the Biococoa-dev mailing list