Class BEDCodec

All Implemented Interfaces:
FeatureCodec<BEDFeature,LineIterator>

public class BEDCodec extends AsciiFeatureCodec<BEDFeature>
Codec for parsing BED file, as described by UCSC See https://genome.ucsc.edu/FAQ/FAQformat.html#format1
  • Field Details

  • Constructor Details

    • BEDCodec

      public BEDCodec()
      Calls BEDCodec(StartOffset) with an argument of StartOffset.ONE
    • BEDCodec

      public BEDCodec(BEDCodec.StartOffset startOffset)
      BED format is 0-based, but Tribble is 1-based. Set desired start position at either ZERO or ONE
  • Method Details

    • decodeLoc

      public BEDFeature decodeLoc(String line)
    • decode

      public BEDFeature decode(String line)
      Specified by:
      decode in class AsciiFeatureCodec<BEDFeature>
      See Also:
    • readActualHeader

      public Object readActualHeader(LineIterator lineIterator)
      The BED codec doesn't retain the actual header, but we need to parse through it and advance to the beginning of the first feature. This is especially true if we're indexing, since we want to underlying stream offset to be established correctly, but is also the case for when we're simply iterating to satisfy a feature query (otherwise the feature reader can terminate prematurely if the header is large).
      Specified by:
      readActualHeader in class AsciiFeatureCodec<BEDFeature>
      Parameters:
      lineIterator -
      Returns:
      Always null. The BEDCodec currently doesn't model or preserve the BED header.
    • decode

      public BEDFeature decode(String[] tokens)
    • readHeaderLine

      protected boolean readHeaderLine(String line)
    • canDecode

      public boolean canDecode(String path)
      Description copied from interface: FeatureCodec

      This function returns true iff the File potentialInput can be parsed by this codec. Note that checking the file's extension is a perfectly acceptable implementation of this method and file contents only rarely need to be checked.

      There is an assumption that there's never a situation where two different Codecs return true for the same file. If this occurs, the recommendation would be to error out.

      Note this function must never throw an error. All errors should be trapped and false returned.
      Parameters:
      path - the file to test for parsability with this codec
      Returns:
      true if potentialInput can be parsed, false otherwise
    • getStartOffset

      public int getStartOffset()
    • getTabixFormat

      public TabixFormat getTabixFormat()
      Description copied from interface: FeatureCodec
      Define the tabix format for the feature, used for indexing. Default implementation throws an exception. Note that only AsciiFeatureCodec could read tabix files as defined in AbstractFeatureReader.getFeatureReader(String, String, FeatureCodec, boolean, java.util.function.Function, java.util.function.Function)
      Returns:
      the format to use with tabix