de.jstacs.data.sequences.annotation
Class SplitSequenceAnnotationParser

java.lang.Object
  extended by de.jstacs.data.sequences.annotation.SplitSequenceAnnotationParser
All Implemented Interfaces:
SequenceAnnotationParser
Direct Known Subclasses:
MotifAnnotationParser, ReferenceSequenceAnnotationParser

public class SplitSequenceAnnotationParser
extends Object
implements SequenceAnnotationParser

This class implements a simple SequenceAnnotationParser which simply splits the comments by specific delimiters.

Author:
Jens Keilwagen

Field Summary
protected  LinkedList<SequenceAnnotation> annot
          The internal list of current SequenceAnnotations.
protected  String annotationDelimiter
          The delimiter between different annotations
protected  String keyValueDelimiter
          The delimiter between key and value
 
Constructor Summary
SplitSequenceAnnotationParser()
          Creates a new SplitSequenceAnnotationParser with specific delimiters, i.e., key value delimiter "=" and annotation delimiter ";".
SplitSequenceAnnotationParser(String keyValueDelimiter, String annotationDelimiter)
          Creates a new SplitSequenceAnnotationParser with user-specified delimiters.
 
Method Summary
protected  void add(String type, String identifier)
          This method actually adds a SequenceAnnotation to the internal list.
 void addToAnnotation(String unparsed)
          This method adds the unparsed String in some way to the SequenceAnnotation.
 void clearAnnotation()
          This method reset the current SequenceAnnotation.
 SequenceAnnotation[] getCurrentAnnotation()
          This method returns the current SequenceAnnotation.
 String parseAnnotationToComment(char commentChar, SequenceAnnotation... annotations)
          This method returns a String representation of the given SequenceAnnotations that can be used as comment line in a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keyValueDelimiter

protected String keyValueDelimiter
The delimiter between key and value


annotationDelimiter

protected String annotationDelimiter
The delimiter between different annotations


annot

protected LinkedList<SequenceAnnotation> annot
The internal list of current SequenceAnnotations.

Constructor Detail

SplitSequenceAnnotationParser

public SplitSequenceAnnotationParser()
Creates a new SplitSequenceAnnotationParser with specific delimiters, i.e., key value delimiter "=" and annotation delimiter ";".

See Also:
SplitSequenceAnnotationParser(String, String)

SplitSequenceAnnotationParser

public SplitSequenceAnnotationParser(String keyValueDelimiter,
                                     String annotationDelimiter)
Creates a new SplitSequenceAnnotationParser with user-specified delimiters.

Parameters:
keyValueDelimiter - the delimiter between key and corresponding value
annotationDelimiter - the delimiter between different SequenceAnnotations
Throws:
IllegalArgumentException - if the delimiters are identical
Method Detail

addToAnnotation

public void addToAnnotation(String unparsed)
Description copied from interface: SequenceAnnotationParser
This method adds the unparsed String in some way to the SequenceAnnotation.

Specified by:
addToAnnotation in interface SequenceAnnotationParser
Parameters:
unparsed - the String containing the annotation

add

protected void add(String type,
                   String identifier)
This method actually adds a SequenceAnnotation to the internal list.

Parameters:
type - the type of the SequenceAnnotation
identifier - the identifier of the SequenceAnnotation

clearAnnotation

public void clearAnnotation()
Description copied from interface: SequenceAnnotationParser
This method reset the current SequenceAnnotation.

Specified by:
clearAnnotation in interface SequenceAnnotationParser

getCurrentAnnotation

public SequenceAnnotation[] getCurrentAnnotation()
Description copied from interface: SequenceAnnotationParser
This method returns the current SequenceAnnotation.

Specified by:
getCurrentAnnotation in interface SequenceAnnotationParser
Returns:
the current SequenceAnnotation

parseAnnotationToComment

public String parseAnnotationToComment(char commentChar,
                                       SequenceAnnotation... annotations)
Description copied from interface: SequenceAnnotationParser
This method returns a String representation of the given SequenceAnnotations that can be used as comment line in a file.
Normally, the method should do the opposite of SequenceAnnotationParser.addToAnnotation(String).

Specified by:
parseAnnotationToComment in interface SequenceAnnotationParser
Parameters:
commentChar - the char at the beginning of comment lines
annotations - the SequenceAnnotations to be parsed
Returns:
a String representing the given SequenceAnnotations
See Also:
DataSet.save(java.io.OutputStream, char, SequenceAnnotationParser)