Package htsjdk.samtools.metrics

# 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:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`HISTO_HEADER`
`static final String`
`MAJOR_HEADER_PREFIX`
`static final String`
`METRIC_HEADER`
`static final String`
`MINOR_HEADER_PREFIX`
`static final String`
`SEPARATOR`

## Constructor Summary

Constructors
Constructor
Description
`MetricsFile()`

## Method Summary

Modifier and Type
Method
Description
`void`
`addAllMetrics(Iterable<BEAN> beanz)`
Add multiple metric beans at once.
`void`
`addHeader(Header h)`
Adds a header to the collection of metrics.
`void`
`addHistogram(Histogram<HKEY> histogram)`
Adds a histogram to the list of histograms in the metrics file.
`void`
`addMetric(BEAN bean)`
Adds a bean to the collection of metrics.
`boolean`
`areHeadersEqual(MetricsFile that)`
`boolean`
`areHistogramsEqual(MetricsFile that)`
`static boolean`
`areMetricsAndHistogramsEqual(File file1, File file2)`
Compare the metrics and histograms in two files, ignoring headers.
`boolean`
`areMetricsEqual(MetricsFile that)`
`static boolean`
`areMetricsEqual(File file1, File file2)`
Compare the metrics in two files, ignoring headers and histograms.
`boolean`
`equals(Object o)`
Checks that the headers, metrics and histogram are all equal.
`List<Histogram<HKEY>>`
`getAllHistograms()`
`List<Header>`
`getHeaders()`
Returns the list of headers.
`List<Header>`
`getHeaders(Class<? extends Header> type)`
Returns the list of headers with the specified type.
`Histogram<HKEY>`
`getHistogram()`
Returns the histogram contained in the metrics file if any.
`List<BEAN>`
`getMetrics()`
Returns the list of headers.
`Set<String>`
`getMetricsColumnLabels()`
`int`
`getNumHistograms()`
Returns the number of histograms added to the metrics file.
`int`
`hashCode()`
`void`
`read(Reader r)`
Reads the Metrics in from the given reader.
`static <T extends MetricBase>
List<T>`
`readBeans(File file)`
Convenience method to read all the Metric beans from a metrics file.
`static List<Header>`
`readHeaders(File file)`
Method to read the header from a metrics file.
`void`
`setHistogram(Histogram<HKEY> histogram)`
Sets the histogram contained in the metrics file.
`void`
`write(File f)`
Writes out the metrics file to the supplied file.
`void`
`write(Writer w)`
Writes out the metrics file to the supplied writer.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### MAJOR_HEADER_PREFIX

public static final String MAJOR_HEADER_PREFIX

See Also:
  - Constant Field Values

### MINOR_HEADER_PREFIX

public static final String MINOR_HEADER_PREFIX

See Also:
  - Constant Field Values

### SEPARATOR

public static final String SEPARATOR

See Also:
  - Constant Field Values

### HISTO_HEADER

public static final String HISTO_HEADER

See Also:
  - Constant Field Values

### METRIC_HEADER

public static final String METRIC_HEADER

See Also:
  - Constant Field Values

## 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.