Package htsjdk.tribble.example
Class CountRecords
- java.lang.Object
-
- htsjdk.tribble.example.CountRecords
-
public class CountRecords extends Object
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
Constructors Constructor Description CountRecords()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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
main(String[] args)
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
printUsage()
print usage informationstatic long
runWithIndex(File featureInput, FeatureCodec codec, int optimizeThreshold)
-
-
-
Method Detail
-
main
public static void main(String[] args)
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
public static long runWithIndex(File featureInput, FeatureCodec codec, int optimizeThreshold)
- Parameters:
featureInput
- File containing featurescodec
- Codec used to read the featuresoptimizeThreshold
- Threshold used to optimize the linear index- Returns:
- See Also:
LinearIndex.optimize(double)
-
printUsage
public static void printUsage()
print usage information
-
loadIndex
public static Index loadIndex(File featureFile, FeatureCodec codec)
- Parameters:
featureFile
- the feature filecodec
- the codec to decode features with- Returns:
- an index instance
-
createAndWriteNewIndex
public static Index createAndWriteNewIndex(File featureFile, File indexFile, FeatureCodec codec)
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
public static FeatureCodec getFeatureCodec(File featureFile)
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
-
-