[Biojava-l] circular sequences

Matthew Pocock mrp@sanger.ac.uk
Fri, 26 Jan 2001 12:05:58 +0000


Thomas Down wrote:

> On Fri, Jan 26, 2001 at 03:44:24PM +1300, Mark Schreiber wrote:
> 
>> Hi,
>> 
>> I am working on something that requires a circular seqeunce
>> implementation, Has this been done??
>> 
>> If not I think I could probably subclass SimpleSequence and redefine the
>> SubList and SubStr methods. Would others find this useful??
> 
> 
> Well, there's no problem doing a CircularSymbolList which overrides
> subList and subStr (I'd be tempted to write a class which gives
> a circularized view onto any underlying SymbolList, rather than
> subclassing a specific implementation).  Point to debate: should
> symbolAt(1001) for a 1000-symbol circular sequence return the
> value of symbolAt(1), or is this an error?

> 
> Circular Sequence objects are slightly more of a pain, since I
> might want a Feature running from, say, 900 - 100.  Not sure
> what the best way to handle this is -- it's not a case recognized
> by out current Location objects.
> 

The circular-view option gets my vote. I think it is prety much as 
simple as saying ((indx-1) % length) + 1 in apropreate places. Could we 
make the circular view a Sequence implementor, and leave all SybmolLists 
linear? We can automagicaly handle the Location issue during the process 
of instantiating a Feature.Template as a Feature instance. I think the 
Location objects will need wrapping in a CircularLocation object that 
knows the sequence length, and makes the wrapped location appear to 
repeat for ever - e.g. If we have a Range 20..30 and a sequence length 
100 then CircularLocation wraps this and makes it behave as if it 
contains 20+n100..30+n100 (n is any integer, positive or negative).

Anybody keen to write this code?


> I'm not sure what the best way round this would be...
> 
> Thomas.
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l@biojava.org
> http://biojava.org/mailman/listinfo/biojava-l