picard.analysis

## Class MergeableMetricBase

- java.lang.Object
- - htsjdk.samtools.metrics.MetricBase
  - - picard.analysis.MergeableMetricBase

- Direct Known Subclasses:
    CollectWgsMetrics.WgsMetrics, DuplicationMetrics, ErrorSummaryMetrics, IndependentReplicateMetric, MendelianViolationMetrics

      public class MergeableMetricBase
      extends htsjdk.samtools.metrics.MetricBase

  An extension of MetricBase that knows how to merge-by-adding fields that are appropriately annotated. It also provides an interface for calculating derived fields (and an annotation that informs that said fields are derived). Finally, it also allows for an annotation that suggests that a field will be used as an ID and thus merging will simply require that these fields are equal. merge-by-adding is only enabled for the following types: int, Integer, float, Float, double, Double, short, Short, long, Long, byte, Byte. Overflow will be detected (for the short, and byte types) and an exception thrown.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static interface` | `MergeableMetricBase.MergeByAdding` Metrics whose values can be merged by adding.
    `protected static interface` | `MergeableMetricBase.MergeByAssertEquals` Metrics whose values should be equal when merging.
    `protected static interface` | `MergeableMetricBase.MergingIsManual` Metrics that are merged manually in the `merge(MergeableMetricBase)` ()}.
    `protected static interface` | `MergeableMetricBase.NoMergingIsDerived` Metrics that are not merged, but are subsequently derived from other metrics, for example by `calculateDerivedFields()`.
    `protected static interface` | `MergeableMetricBase.NoMergingKeepsValue` Metrics that are not merged.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MergeableMetricBase()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `calculateDerivedFields()` placeholder method that will calculate the derived fields from the other ones.
    `boolean` | `canMerge(MergeableMetricBase other)` checks if this instance can be merged with another Other must have all the fields that this instance has, and the fields that are annotated as MergeByAssertEquals must contain the same value
    `MergeableMetricBase` | `merge(Collection<? extends MergeableMetricBase> many)` for a collection of MergeableMetricBase, merge them all into "this" one.
    `MergeableMetricBase` | `merge(MergeableMetricBase other)` Merge another metric into this one
    `boolean` | `mergeIfCan(MergeableMetricBase other)` Merges another MergableMetricBase if possible

    - ### Methods inherited from class htsjdk.samtools.metrics.MetricBase

      `equals, hashCode, toString`

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

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

- - ### Constructor Detail

    - #### MergeableMetricBase

          public MergeableMetricBase()

  - ### Method Detail

    - #### canMerge

          public boolean canMerge(MergeableMetricBase other)

      checks if this instance can be merged with another Other must have all the fields that this instance has, and the fields that are annotated as MergeByAssertEquals must contain the same value
      Parameters:
        `other` - metric that will be merged into this one.
      Returns:
        true if the other metric can be merged into this one.

    - #### mergeIfCan

          public boolean mergeIfCan(MergeableMetricBase other)

      Merges another MergableMetricBase if possible
      Parameters:
        `other` - another MergableMetricBase instance to merge, must of the same class as this.
      Returns:
        true if the other metric can be merged into this one.

    - #### merge

          public MergeableMetricBase merge(Collection<? extends MergeableMetricBase> many)

      for a collection of MergeableMetricBase, merge them all into "this" one.
      Parameters:
        `many` - a Collection of MergeableMetricBase

    - #### merge

          public MergeableMetricBase merge(MergeableMetricBase other)

      Merge another metric into this one
      Parameters:
        `other` - metric to merge into this one.

    - #### calculateDerivedFields

          public void calculateDerivedFields()

      placeholder method that will calculate the derived fields from the other ones. classes that are derived from non-trivial base classes should consider calling super.calculateDerivedFields() as well.