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 Details

    • CountRecords

      public CountRecords()
  • Method Details

    • 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 features
      codec - Codec used to read the features
      optimizeThreshold - Threshold used to optimize the linear index
      Returns:
      See Also:
    • printUsage

      public static void printUsage()
      print usage information
    • loadIndex

      public static Index loadIndex(File featureFile, FeatureCodec codec)
      Parameters:
      featureFile - the feature file
      codec - 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 to
      codec - the codec to read features with
      Returns:
      an index instance
    • getFeatureCodec

      public static FeatureCodec getFeatureCodec(File featureFile)
      Return a FeatureCodec instance appropriate for the given featureFile. Codec is generated based on file extension
      Parameters:
      featureFile -
      Returns:
      Throws:
      IllegalArgumentException - If a codec cannot be found