htsjdk.tribble.bed
Class BEDCodec

java.lang.Object
  extended by htsjdk.tribble.AbstractFeatureCodec<T,LineIterator>
      extended by htsjdk.tribble.AsciiFeatureCodec<BEDFeature>
          extended by htsjdk.tribble.bed.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


Nested Class Summary
static class BEDCodec.StartOffset
          Indicate whether co-ordinates or 0-based or 1-based.
 
Constructor Summary
BEDCodec()
          Calls BEDCodec(StartOffset) with an argument of StartOffset.ONE
BEDCodec(BEDCodec.StartOffset startOffset)
          BED format is 0-based, but Tribble is 1-based.
 
Method Summary
 boolean canDecode(java.lang.String path)
          This function returns true iff the File potentialInput can be parsed by this codec.
 BEDFeature decode(java.lang.String line)
           
 BEDFeature decode(java.lang.String[] tokens)
           
 BEDFeature decodeLoc(java.lang.String line)
           
 int getStartOffset()
           
 java.lang.Object readActualHeader(LineIterator reader)
          Read and return the header, or null if there is no header.
protected  boolean readHeaderLine(java.lang.String line)
           
 
Methods inherited from class htsjdk.tribble.AsciiFeatureCodec
close, decode, isDone, makeIndexableSourceFromStream, makeSourceFromStream, readHeader
 
Methods inherited from class htsjdk.tribble.AbstractFeatureCodec
decodeLoc, getFeatureType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

decodeLoc

public BEDFeature decodeLoc(java.lang.String line)

decode

public BEDFeature decode(java.lang.String line)
Specified by:
decode in class AsciiFeatureCodec<BEDFeature>
See Also:
AsciiFeatureCodec#decode(htsjdk.tribble.readers.LineIterator)}

readActualHeader

public java.lang.Object readActualHeader(LineIterator reader)
Description copied from class: AsciiFeatureCodec
Read and return the header, or null if there is no header.

Specified by:
readActualHeader in class AsciiFeatureCodec<BEDFeature>
Returns:
the actual header data in the file, or null if none is available

decode

public BEDFeature decode(java.lang.String[] tokens)

readHeaderLine

protected boolean readHeaderLine(java.lang.String line)

canDecode

public boolean canDecode(java.lang.String path)
Description copied from interface: FeatureCodec
This function returns true iff the File potentialInput can be parsed by this codec.

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.

Specified by:
canDecode in interface FeatureCodec<BEDFeature,LineIterator>
Overrides:
canDecode in class AbstractFeatureCodec<BEDFeature,LineIterator>
Parameters:
path - the file to test for parsability with this codec
Returns:
true if potentialInput can be parsed, false otherwise

getStartOffset

public int getStartOffset()