Package htsjdk.tribble.example
Class CountRecords
java.lang.Object
htsjdk.tribble.example.CountRecords
An example of how to index a feature file, and then count all the records in the file.
This is also useful for testing the feature reader
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Index
createAndWriteNewIndex
(File featureFile, File indexFile, FeatureCodec codec) creates a new index, given the feature file and the codecstatic FeatureCodec
getFeatureCodec
(File featureFile) Return aFeatureCodec
instance appropriate for the givenfeatureFile
.static Index
loadIndex
(File featureFile, FeatureCodec codec) static void
The main method of this class: 1) checks to see that the feature file exists 2) loads an index from disk, if one doesn't exist, it creates it and writes it to disk 3) creates a FeatureSource 4) iterates over the records, emitting a final tally for the number of features seenstatic void
print usage informationstatic long
runWithIndex
(File featureInput, FeatureCodec codec, int optimizeThreshold)
-
Constructor Details
-
CountRecords
public CountRecords()
-
-
Method Details
-
main
The main method of this class: 1) checks to see that the feature file exists 2) loads an index from disk, if one doesn't exist, it creates it and writes it to disk 3) creates a FeatureSource 4) iterates over the records, emitting a final tally for the number of features seen- Parameters:
args
- a single parameter, the file name to load
-
runWithIndex
- Parameters:
featureInput
- File containing featurescodec
- Codec used to read the featuresoptimizeThreshold
- Threshold used to optimize the linear index- Returns:
- See Also:
-
printUsage
public static void printUsage()print usage information -
loadIndex
- Parameters:
featureFile
- the feature filecodec
- the codec to decode features with- Returns:
- an index instance
-
createAndWriteNewIndex
creates a new index, given the feature file and the codec- Parameters:
featureFile
- the feature file (i.e. .vcf, .bed)indexFile
- the index file; the location we should be writing the index tocodec
- the codec to read features with- Returns:
- an index instance
-
getFeatureCodec
Return aFeatureCodec
instance appropriate for the givenfeatureFile
. Codec is generated based on file extension- Parameters:
featureFile
-- Returns:
- Throws:
IllegalArgumentException
- If a codec cannot be found
-