Class MetricsFile<BEAN extends MetricBase,HKEY extends Comparable>

java.lang.Object
htsjdk.samtools.metrics.MetricsFile<BEAN,HKEY>
All Implemented Interfaces:
Serializable

public class MetricsFile<BEAN extends MetricBase,HKEY extends Comparable> extends Object implements Serializable
Contains a set of metrics that can be written to a file and parsed back again. The set of metrics is composed of zero or more instances of a class, BEAN, that extends MetricBase (all instances must be of the same type) and may optionally include one or more histograms that share the same key set.
See Also:
  • Field Details

  • Constructor Details

    • MetricsFile

      public MetricsFile()
  • Method Details

    • addHeader

      public void addHeader(Header h)
      Adds a header to the collection of metrics.
    • getHeaders

      public List<Header> getHeaders()
      Returns the list of headers.
    • addMetric

      public void addMetric(BEAN bean)
      Adds a bean to the collection of metrics.
    • addAllMetrics

      public void addAllMetrics(Iterable<BEAN> beanz)
      Add multiple metric beans at once.
    • getMetrics

      public List<BEAN> getMetrics()
      Returns the list of headers.
    • getMetricsColumnLabels

      public Set<String> getMetricsColumnLabels()
    • getHistogram

      public Histogram<HKEY> getHistogram()
      Returns the histogram contained in the metrics file if any.
    • setHistogram

      public void setHistogram(Histogram<HKEY> histogram)
      Sets the histogram contained in the metrics file.
    • addHistogram

      public void addHistogram(Histogram<HKEY> histogram)
      Adds a histogram to the list of histograms in the metrics file.
    • getAllHistograms

      public List<Histogram<HKEY>> getAllHistograms()
    • getNumHistograms

      public int getNumHistograms()
      Returns the number of histograms added to the metrics file.
    • getHeaders

      public List<Header> getHeaders(Class<? extends Header> type)
      Returns the list of headers with the specified type.
    • write

      public void write(File f)
      Writes out the metrics file to the supplied file. The file is written out headers first, metrics second and histogram third.
      Parameters:
      f - a File into which to write the metrics
    • write

      public void write(Writer w)
      Writes out the metrics file to the supplied writer. The file is written out headers first, metrics second and histogram third.
      Parameters:
      w - a Writer into which to write the metrics
    • read

      public void read(Reader r)
      Reads the Metrics in from the given reader.
    • equals

      public boolean equals(Object o)
      Checks that the headers, metrics and histogram are all equal.
      Overrides:
      equals in class Object
    • areHeadersEqual

      public boolean areHeadersEqual(MetricsFile that)
    • areMetricsEqual

      public boolean areMetricsEqual(MetricsFile that)
    • areHistogramsEqual

      public boolean areHistogramsEqual(MetricsFile that)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • readBeans

      public static <T extends MetricBase> List<T> readBeans(File file)
      Convenience method to read all the Metric beans from a metrics file.
      Parameters:
      file - to be read.
      Returns:
      list of beans from the file.
    • readHeaders

      public static List<Header> readHeaders(File file)
      Method to read the header from a metrics file.
    • areMetricsEqual

      public static boolean areMetricsEqual(File file1, File file2)
      Compare the metrics in two files, ignoring headers and histograms.
    • areMetricsAndHistogramsEqual

      public static boolean areMetricsAndHistogramsEqual(File file1, File file2)
      Compare the metrics and histograms in two files, ignoring headers.