Package org.biojava.bio.seq.io
Class SequenceBuilderBase
- java.lang.Object
-
- org.biojava.bio.seq.io.SequenceBuilderBase
-
- All Implemented Interfaces:
SeqIOListener
,SequenceBuilder
- Direct Known Subclasses:
SequenceDBSequenceBuilder
,SimpleAssemblyBuilder
,SimpleSequenceBuilder
,SmartSequenceBuilder
public abstract class SequenceBuilderBase extends Object implements SequenceBuilder
Basic SequenceBuilder implementation which accumulates all notified information. Subclass this to implement specific Sequence implementations. More functionality is offered by theSimpleRichSequenceBuilder
.- Version:
- 1.2 [newio proposal]
- Author:
- Thomas Down, David Huen (modified SimpleSequence to make this)
-
-
Field Summary
Fields Modifier and Type Field Description protected Annotation
annotation
static Object
ERROR_FEATURES_PROPERTY
protected String
name
protected Sequence
seq
protected String
uri
-
Constructor Summary
Constructors Constructor Description SequenceBuilderBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addFeatureProperty(Object key, Object value)
Add an annotation-bundle entry to the feature.protected void
addProperty(Annotation ann, Object key, Object value)
void
addSequenceProperty(Object key, Object value)
Add an annotation-bundle entry to the sequence.abstract void
addSymbols(Alphabet alpha, Symbol[] syms, int pos, int len)
Notify the listener of symbol data.void
endFeature()
Mark the end of data associated with one specific feature.void
endSequence()
Notify the listener that processing of the sequence is complete.Sequence
makeSequence()
Return the Sequence object which has been constructed by this builder.void
setName(String name)
Notify the listener that the current sequence is generally known by a particular name.void
setURI(String uri)
Notify the listener of a URI identifying the current sequence.void
startFeature(Feature.Template templ)
Notify the listener that a new feature object is starting.void
startSequence()
Start the processing of a sequence.
-
-
-
Field Detail
-
ERROR_FEATURES_PROPERTY
public static Object ERROR_FEATURES_PROPERTY
-
annotation
protected Annotation annotation
-
-
Constructor Detail
-
SequenceBuilderBase
public SequenceBuilderBase()
-
-
Method Detail
-
startSequence
public void startSequence()
Description copied from interface:SeqIOListener
Start the processing of a sequence. This method exists primarily to enforce the life-cycles of SeqIOListener objects.- Specified by:
startSequence
in interfaceSeqIOListener
-
endSequence
public void endSequence()
Description copied from interface:SeqIOListener
Notify the listener that processing of the sequence is complete.- Specified by:
endSequence
in interfaceSeqIOListener
-
setName
public void setName(String name)
Description copied from interface:SeqIOListener
Notify the listener that the current sequence is generally known by a particular name.- Specified by:
setName
in interfaceSeqIOListener
- Parameters:
name
- the String that should be returned by getName for the sequence being parsed
-
setURI
public void setURI(String uri)
Description copied from interface:SeqIOListener
Notify the listener of a URI identifying the current sequence.- Specified by:
setURI
in interfaceSeqIOListener
-
addSymbols
public abstract void addSymbols(Alphabet alpha, Symbol[] syms, int pos, int len) throws IllegalAlphabetException
Description copied from interface:SeqIOListener
Notify the listener of symbol data. All symbols passed to this method are guarenteed to be contained within the specified alphabet. Generally all calls to a given Listener should have the same alphabet -- if not, the listener implementation is likely to throw an exception- Specified by:
addSymbols
in interfaceSeqIOListener
- Parameters:
alpha
- The alphabet of the symbol datasyms
- An array containing symbolspos
- The start offset of valid data within the arraylen
- The number of valid symbols in the array- Throws:
IllegalAlphabetException
- if we can't cope with this alphabet.
-
addSequenceProperty
public void addSequenceProperty(Object key, Object value)
Add an annotation-bundle entry to the sequence. If the annotation key isn't currently defined, the value is added directly. Otherwise:- If the current value implements the Collection interface, the new value is added to that collection.
- Otherwise, the current value is replaced by a List object containing the old value then the new value in that order.
- Specified by:
addSequenceProperty
in interfaceSeqIOListener
-
startFeature
public void startFeature(Feature.Template templ)
Description copied from interface:SeqIOListener
Notify the listener that a new feature object is starting. Every call to startFeature should have a corresponding call to endFeature. If the listener is concerned with a hierarchy of features, it should maintain a stack of `open' features.- Specified by:
startFeature
in interfaceSeqIOListener
-
addFeatureProperty
public void addFeatureProperty(Object key, Object value) throws ParseException
Add an annotation-bundle entry to the feature. If the annotation key isn't currently defined, the value is added directly. Otherwise:- If the current value implements the Collection interface, the new value is added to that collection.
- Otherwise, the current value is replaced by a List object containing the old value then the new value in that order.
- Specified by:
addFeatureProperty
in interfaceSeqIOListener
- Throws:
ParseException
-
endFeature
public void endFeature()
Description copied from interface:SeqIOListener
Mark the end of data associated with one specific feature.- Specified by:
endFeature
in interfaceSeqIOListener
-
makeSequence
public Sequence makeSequence() throws BioException
Description copied from interface:SequenceBuilder
Return the Sequence object which has been constructed by this builder. This method is only expected to succeed after the endSequence() notifier has been called.- Specified by:
makeSequence
in interfaceSequenceBuilder
- Throws:
BioException
-
addProperty
protected void addProperty(Annotation ann, Object key, Object value)
-
-