Package htsjdk.tribble.bed
Class BEDCodec
- java.lang.Object
-
- htsjdk.tribble.AbstractFeatureCodec<T,LineIterator>
-
- htsjdk.tribble.AsciiFeatureCodec<BEDFeature>
-
- 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
Nested Classes Modifier and Type Class Description static class
BEDCodec.StartOffset
Indicate whether co-ordinates or 0-based or 1-based.
-
Field Summary
Fields Modifier and Type Field Description static String
BED_EXTENSION
Default extension for BED files.
-
Constructor Summary
Constructors Constructor Description BEDCodec()
CallsBEDCodec(StartOffset)
with an argument ofStartOffset.ONE
BEDCodec(BEDCodec.StartOffset startOffset)
BED format is 0-based, but Tribble is 1-based.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canDecode(String path)
This function returns true iff the File potentialInput can be parsed by this codec.BEDFeature
decode(String line)
BEDFeature
decode(String[] tokens)
BEDFeature
decodeLoc(String line)
int
getStartOffset()
TabixFormat
getTabixFormat()
Define the tabix format for the feature, used for indexing.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.protected boolean
readHeaderLine(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
-
Methods inherited from interface htsjdk.tribble.FeatureCodec
getPathToDataFile
-
-
-
-
Field Detail
-
BED_EXTENSION
public static final String BED_EXTENSION
Default extension for BED files.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BEDCodec
public BEDCodec()
CallsBEDCodec(StartOffset)
with an argument ofStartOffset.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(String line)
-
decode
public BEDFeature decode(String line)
- Specified by:
decode
in classAsciiFeatureCodec<BEDFeature>
- See Also:
AsciiFeatureCodec.decode(htsjdk.tribble.readers.LineIterator)
-
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 classAsciiFeatureCodec<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 onlyAsciiFeatureCodec
could read tabix files as defined inAbstractFeatureReader.getFeatureReader(String, String, FeatureCodec, boolean, java.util.function.Function, java.util.function.Function)
- Returns:
- the format to use with tabix
-
-