Package picard.analysis
Class MergeableMetricBase
java.lang.Object
htsjdk.samtools.metrics.MetricBase
picard.analysis.MergeableMetricBase
- Direct Known Subclasses:
CollectArraysVariantCallingMetrics.ArraysVariantCallingSummaryMetrics
,CollectQualityYieldMetrics.QualityYieldMetrics
,CollectVariantCallingMetrics.VariantCallingSummaryMetrics
,DuplicationMetrics
,ErrorMetric
,ErrorSummaryMetrics
,IndependentReplicateMetric
,MendelianViolationMetrics
,WgsMetrics
public abstract class MergeableMetricBase
extends htsjdk.samtools.metrics.MetricBase
An extension of MetricBase that knows how to merge-by-adding fields that are appropriately annotated (implicit action will be taken
MergeByAdding
). It also provides an interface
for calculating derived fields calculateDerivedFields()
(and an annotation that informs that said fields are derived NoMergingIsDerived
). Finally, it also allows for an annotation
that suggests that a field will be used as an ID and thus merging will simply ensure that these fields are equal MergeByAssertEquals
. Other annotations are available,
though they all currently imply that no MergingIsManual
and NoMergingKeepsValue
.
MergeByAdding
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.
Every (non-static) field in this class MergeByAdding
,
MergeByAssertEquals
, NoMergingIsDerived
, MergingIsManual
, NoMergingKeepsValue
.
Static fields may be annotated, but not with MergeByAdding
, there will be no automatic modification of static fields
MergeByAdding
- When merging another metric into this one, the value of the field in the other class will be added to the value in this. This will happen automatically!
MergeByAssertEquals
- When merging another metric into this one, the code will assert that value of the field in the other class is equal to the value in this.
NoMergingIsDerived
- When merging another metric into this one, no action will be taken since the value of this field should be derived from the other field. This derivation should happen in the "calculateDerivedFields" method.
MergingIsManual
- When merging another metric into this one, the resulting value will be calculated "manually", i.e. by custom code in the merge method. The resulting value can depend on both this and other objects.
NoMergingKeepsValue
- When merging another metric into this one, the value of the field in this remains unchanged by design.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static @interface
Metrics whose values can be merged by adding.protected static @interface
Metrics whose values should be equal when merging.protected static @interface
Metrics that are merged manually in themerge(MergeableMetricBase)
()}.protected static @interface
Metrics that are not merged, but are subsequently derived from other metrics, for example bycalculateDerivedFields()
.protected static @interface
Metrics that are not merged. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 valuemerge
(Collection<? extends MergeableMetricBase> many) for a collection of MergeableMetricBase, merge them all into "this" one.merge
(MergeableMetricBase other) Merge another metric into this oneboolean
mergeIfCan
(MergeableMetricBase other) Merges another MergableMetricBase if possibleMethods inherited from class htsjdk.samtools.metrics.MetricBase
equals, hashCode, toString
-
Constructor Details
-
MergeableMetricBase
public MergeableMetricBase()
-
-
Method Details
-
canMerge
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
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
for a collection of MergeableMetricBase, merge them all into "this" one.- Parameters:
many
- a Collection of MergeableMetricBase
-
merge
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 derived classes should consider calling super.calculateDerivedFields() as well. Fields whose value will change due to this method should be annotated withNoMergingKeepsValue
.
-