Search in sources :

Example 1 with VisibleForTesting

use of com.google.cloud.dataflow.sdk.repackaged.com.google.common.annotations.VisibleForTesting in project gatk-protected by broadinstitute.

the class PreAdapterOrientationScorer method countOrientationBiasMetricsOverContext.

/**
     * Gets PreAdapterQ collapsed over contexts.
     *
     * rows {PRO, CON} x cols {ref, alt}
     * @param metrics metrics usually read from a picard preadapter detail file.
     * @return mapping to score all orientation bias artifact modes to a PreAdapterQ score.  This score can be used as a bam-file level score for level of artifacts.
     */
@VisibleForTesting
static Map<Transition, RealMatrix> countOrientationBiasMetricsOverContext(final List<SequencingArtifactMetrics.PreAdapterDetailMetrics> metrics) {
    Utils.nonNull(metrics, "Input metrics cannot be null");
    // Artifact mode to a matrix
    final Map<Transition, RealMatrix> result = new HashMap<>();
    // Collapse over context
    for (SequencingArtifactMetrics.PreAdapterDetailMetrics metric : metrics) {
        final Transition key = Transition.transitionOf(metric.REF_BASE, metric.ALT_BASE);
        result.putIfAbsent(key, new Array2DRowRealMatrix(2, 2));
        final RealMatrix preAdapterCountMatrix = result.get(key);
        preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.PRO, PreAdapterOrientationScorer.ALT, metric.PRO_ALT_BASES);
        preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.CON, PreAdapterOrientationScorer.ALT, metric.CON_ALT_BASES);
        preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.PRO, PreAdapterOrientationScorer.REF, metric.PRO_REF_BASES);
        preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.CON, PreAdapterOrientationScorer.REF, metric.CON_REF_BASES);
    }
    return result;
}
Also used : Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) RealMatrix(org.apache.commons.math3.linear.RealMatrix) Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) HashMap(java.util.HashMap) Transition(org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition) SequencingArtifactMetrics(org.broadinstitute.hellbender.tools.picard.analysis.artifacts.SequencingArtifactMetrics) VisibleForTesting(com.google.cloud.dataflow.sdk.repackaged.com.google.common.annotations.VisibleForTesting)

Example 2 with VisibleForTesting

use of com.google.cloud.dataflow.sdk.repackaged.com.google.common.annotations.VisibleForTesting in project gatk by broadinstitute.

the class PreAdapterOrientationScorer method countOrientationBiasMetricsOverContext.

/**
     * Gets PreAdapterQ collapsed over contexts.
     *
     * rows {PRO, CON} x cols {ref, alt}
     * @param metrics metrics usually read from a picard preadapter detail file.
     * @return mapping to score all orientation bias artifact modes to a PreAdapterQ score.  This score can be used as a bam-file level score for level of artifacts.
     */
@VisibleForTesting
static Map<Transition, RealMatrix> countOrientationBiasMetricsOverContext(final List<SequencingArtifactMetrics.PreAdapterDetailMetrics> metrics) {
    Utils.nonNull(metrics, "Input metrics cannot be null");
    // Artifact mode to a matrix
    final Map<Transition, RealMatrix> result = new HashMap<>();
    // Collapse over context
    for (SequencingArtifactMetrics.PreAdapterDetailMetrics metric : metrics) {
        final Transition key = Transition.transitionOf(metric.REF_BASE, metric.ALT_BASE);
        result.putIfAbsent(key, new Array2DRowRealMatrix(2, 2));
        final RealMatrix preAdapterCountMatrix = result.get(key);
        preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.PRO, PreAdapterOrientationScorer.ALT, metric.PRO_ALT_BASES);
        preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.CON, PreAdapterOrientationScorer.ALT, metric.CON_ALT_BASES);
        preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.PRO, PreAdapterOrientationScorer.REF, metric.PRO_REF_BASES);
        preAdapterCountMatrix.addToEntry(PreAdapterOrientationScorer.CON, PreAdapterOrientationScorer.REF, metric.CON_REF_BASES);
    }
    return result;
}
Also used : Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) RealMatrix(org.apache.commons.math3.linear.RealMatrix) Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) HashMap(java.util.HashMap) Transition(org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition) SequencingArtifactMetrics(org.broadinstitute.hellbender.tools.picard.analysis.artifacts.SequencingArtifactMetrics) VisibleForTesting(com.google.cloud.dataflow.sdk.repackaged.com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.cloud.dataflow.sdk.repackaged.com.google.common.annotations.VisibleForTesting)2 HashMap (java.util.HashMap)2 Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)2 RealMatrix (org.apache.commons.math3.linear.RealMatrix)2 SequencingArtifactMetrics (org.broadinstitute.hellbender.tools.picard.analysis.artifacts.SequencingArtifactMetrics)2 Transition (org.broadinstitute.hellbender.tools.picard.analysis.artifacts.Transition)2