Package picard.util

Class AbstractInputParser

  • All Implemented Interfaces:
    htsjdk.samtools.util.CloseableIterator<String[]>, Closeable, AutoCloseable, Iterable<String[]>, Iterator<String[]>
    Direct Known Subclasses:
    BasicInputParser

    public abstract class AbstractInputParser
    extends htsjdk.samtools.util.AbstractIterator<String[]>
    implements Iterable<String[]>, htsjdk.samtools.util.CloseableIterator<String[]>
    Class for parsing text files where each line consists of fields separated by whitespace. Code is abstracted into this class so that we can optimize its performance over time. This class assumes that every line will have the same number of whitespace-separated "words" and that lines that start with "#" are comments and should be ignored. Classes that extend this parser can do so simply by implementing their own constructors and the readNextLine(), close(), and getFileName() methods.
    • Constructor Detail

      • AbstractInputParser

        public AbstractInputParser()
    • Method Detail

      • close

        public abstract void close()
        Closes this stream and releases any system resources associated with it.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface htsjdk.samtools.util.CloseableIterator<String[]>
      • readNextLine

        protected abstract byte[] readNextLine()
        Returns:
        the next line of text from the underlying stream(s) or null if there is no next line
      • getFileName

        public abstract String getFileName()
        Returns:
        the name(s) of the file(s) being parsed, or null if no name is available
      • advance

        protected String[] advance()
        Specified by:
        advance in class htsjdk.samtools.util.AbstractIterator<String[]>
      • calculateWordCount

        protected void calculateWordCount​(byte[] line)
        Calculates the number of delimiter-separated "words" in a line and sets the value of wordCount
        Parameters:
        line - representative line from the file
      • isComment

        protected boolean isComment​(byte[] line)
        Determines whether a given line is a comment
        Parameters:
        line - the line to evaluate
        Returns:
        true if the line is a comment (and should be ignored) otherwise false
      • isBlank

        protected boolean isBlank​(byte[] line)
        Determines whether a given line is a comment
        Parameters:
        line - the line to evaluate
        Returns:
        true if the line is a comment (and should be ignored) otherwise false
      • isDelimiter

        protected boolean isDelimiter​(byte b)
        Determines whether a given character is a delimiter
        Parameters:
        b - the character to evaluate
        Returns:
        true if b is a delimiter; otherwise false
      • getWordCount

        protected int getWordCount()
      • setWordCount

        protected void setWordCount​(int wordCount)
      • isTreatGroupedDelimitersAsOne

        protected boolean isTreatGroupedDelimitersAsOne()
      • setTreatGroupedDelimitersAsOne

        protected void setTreatGroupedDelimitersAsOne​(boolean treatGroupedDelimitersAsOne)
      • isSkipBlankLines

        protected boolean isSkipBlankLines()
      • setSkipBlankLines

        protected void setSkipBlankLines​(boolean skipBlankLines)