org.biojava.bio.seq
Class CircularView

java.lang.Object
  extended by org.biojava.utils.Unchangeable
      extended by org.biojava.bio.seq.impl.ViewSequence
          extended by org.biojava.bio.seq.CircularView
All Implemented Interfaces:
Serializable, Annotatable, FeatureHolder, RealizingFeatureHolder, Sequence, SymbolList, Changeable

public class CircularView
extends ViewSequence

A circular view onto another Sequence object. The class allows for reinterpretation of locations and indices onto the sequence to allow for overlapping of the origin. The origin is assumed to be the first symbol. Future versions may support changing the origin.

In biojavax RichSequences intrinsicly know about circularity. No view is required. We strongly recommend using RichSequence if possible.

Since:
1.1
Version:
1.2
Author:
Mark Schreiber
See Also:
RichSequence, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.biojava.bio.seq.FeatureHolder
FeatureHolder.EmptyFeatureHolder
 
Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
Annotatable.AnnotationForwarder
 
Nested classes/interfaces inherited from interface org.biojava.bio.seq.FeatureHolder
FeatureHolder.EmptyFeatureHolder
 
Field Summary
 
Fields inherited from interface org.biojava.bio.symbol.SymbolList
EDIT, EMPTY_LIST
 
Fields inherited from interface org.biojava.bio.seq.FeatureHolder
EMPTY_FEATURE_HOLDER, FEATURES, SCHEMA
 
Fields inherited from interface org.biojava.bio.Annotatable
ANNOTATION
 
Fields inherited from interface org.biojava.bio.seq.FeatureHolder
EMPTY_FEATURE_HOLDER, FEATURES, SCHEMA
 
Constructor Summary
CircularView(Sequence seq)
           
CircularView(Sequence seq, FeatureRealizer fr)
           
 
Method Summary
 Feature createFeature(Feature.Template template)
          Over rides ViewSequence to allow the use of locations that have coordinates outside of the sequence length (which are needed to describe locations that overlap the origin of a circular sequence).
 SymbolList subList(int start, int end)
           Over rides ViewSequence.
 String subStr(int start, int end)
           Over rides ViewSequence.
 Symbol symbolAt(int index)
           Over rides ViewSequence.
 
Methods inherited from class org.biojava.bio.seq.impl.ViewSequence
containsFeature, countFeatures, edit, features, filter, filter, getAddedFeatures, getAlphabet, getAnnotation, getName, getSchema, getURN, iterator, length, realizeFeature, removeFeature, seqString, toList
 
Methods inherited from class org.biojava.utils.Unchangeable
addChangeListener, addChangeListener, addForwarder, getForwarders, getListeners, isUnchanging, removeChangeListener, removeChangeListener, removeForwarder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 

Constructor Detail

CircularView

public CircularView(Sequence seq,
                    FeatureRealizer fr)

CircularView

public CircularView(Sequence seq)
Method Detail

symbolAt

public Symbol symbolAt(int index)

Over rides ViewSequence. Allows any integer index, positive or negative to return a symbol via the equation val = (val % length); Note that base zero is the base immediately before base 1 which is of course the last base of the sequence.

Specified by:
symbolAt in interface SymbolList
Overrides:
symbolAt in class ViewSequence
Parameters:
index - the index of the Symbol requested.
Returns:
the Symbol specified by the index.

subStr

public String subStr(int start,
                     int end)

Over rides ViewSequence. Allows any integer index, positive or negative to return a symbol via the equation val = (val % length);

Will return a linear String which can, if nescessary, span the origin.

Specified by:
subStr in interface SymbolList
Overrides:
subStr in class ViewSequence
Parameters:
start - the index of the fist base
end - the index of the last base
Returns:
a String representation of the tokenized Symbols

createFeature

public Feature createFeature(Feature.Template template)
                      throws ChangeVetoException,
                             BioException
Over rides ViewSequence to allow the use of locations that have coordinates outside of the sequence length (which are needed to describe locations that overlap the origin of a circular sequence).

Specified by:
createFeature in interface FeatureHolder
Overrides:
createFeature in class ViewSequence
Parameters:
template - the template of the feature to be created.
Returns:
the feature created you can use the template of the returned feature to create another of the same type.
Throws:
BioException - if a non circular location is added that exceeds the 'boundaries' of the sequence.
ChangeVetoException - if the sequence is locked.
Since:
1.2

subList

public SymbolList subList(int start,
                          int end)

Over rides ViewSequence. Allows any integer index, positive or negative to return a symbol via the equation index = ((index -1) % length)+1

Will return a linear SymbolList which can ,if nescessary, span the origin.

Specified by:
subList in interface SymbolList
Overrides:
subList in class ViewSequence
Parameters:
start - the first base of the sublist
end - the last base of the sublist
Returns:
a SymbolList containing the Symbols from start to end inclusive