htsjdk.samtools.util.Histogram.increment()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中htsjdk.samtools.util.Histogram.increment()方法的一些代码示例,展示了Histogram.increment()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Histogram.increment()方法的具体详情如下:
包路径:htsjdk.samtools.util.Histogram
类名称:Histogram
方法名:increment

Histogram.increment介绍

[英]Increments the value in the designated bin by 1.
[中]将指定箱子中的值增加1。

代码示例

代码示例来源:origin: broadinstitute/picard

/**
 * Increments a count for the truth/call state tuple.
 * @param truthAndCallStates
 */
public void increment(final TruthAndCallStates truthAndCallStates) {
  this.counter.increment(truthAndCallStates);
}

代码示例来源:origin: broadinstitute/picard

/**
 * Add an observation of a UMI to the metrics
 * @param observedUmi String containing the observed UMI
 * @param inferredUmi String containing the UMI inferred after error correcting the observed UMI
 */
public void addUmiObservation(String observedUmi, String inferredUmi) {
  observedUmis.increment(observedUmi);
  inferredUmis.increment(inferredUmi);
  observedUmiBases += observedUmi.length();
  totalObservedUmisWithoutNs++;
}

代码示例来源:origin: broadinstitute/picard

protected Histogram<Integer> getHistogram(final long[] array, final String binLabel, final String valueLabel) {
  final Histogram<Integer> histogram = new Histogram<>(binLabel, valueLabel);
  for (int i = 0; i < array.length; ++i) {
    histogram.increment(i, array[i]);
  }
  return histogram;
}

代码示例来源:origin: broadinstitute/picard

private Histogram<Integer> getDepthHistogramNonZero() {
  final Histogram<Integer> depthHistogram = new Histogram<>("coverage", "count_NON_ZERO_REGIONS");
  // do not include the zero-coverage bin
  for (int i = 1; i < highQualityDepthHistogramArray.length; ++i) {
    depthHistogram.increment(i, highQualityDepthHistogramArray[i]);
  }
  return depthHistogram;
}

代码示例来源:origin: com.github.broadinstitute/picard

private Histogram<Integer> getDepthHistogramNonZero() {
  final Histogram<Integer> depthHistogram = new Histogram<>("coverage", "count_NON_ZERO_REGIONS");
  // do not include the zero-coverage bin
  for (int i = 1; i < highQualityDepthHistogramArray.length; ++i) {
    depthHistogram.increment(i, highQualityDepthHistogramArray[i]);
  }
  return depthHistogram;
}

代码示例来源:origin: com.github.broadinstitute/picard

protected Histogram<Integer> getHistogram(final long[] array, final String binLabel, final String valueLabel) {
  final Histogram<Integer> histogram = new Histogram<>(binLabel, valueLabel);
  for (int i = 0; i < array.length; ++i) {
    histogram.increment(i, array[i]);
  }
  return histogram;
}

代码示例来源:origin: broadinstitute/picard

private Histogram<Integer> twoSiteDepthHistogram(final int depth1, final int count1, final int depth2, final int count2) {
  final Histogram<Integer> histogram = new Histogram<>();
  if (0 < depth1) histogram.increment(depth1, count1);
  if (0 < depth2) histogram.increment(depth2, count2);
  return histogram;
}

代码示例来源:origin: broadinstitute/picard

private Histogram<Integer> singleDepthHistogram(final int depth, final int count) {
  final Histogram<Integer> histogram = new Histogram<>();
  histogram.increment(depth, count);
  return histogram;
}
private Histogram<Integer> twoSiteDepthHistogram(final int depth1, final int count1, final int depth2, final int count2) {

代码示例来源:origin: org.seqdoop/htsjdk

/***
   * Mutable method that allows the addition of a Histogram into the current one.
   * @param addHistogram
   */
  public void addHistogram(final Histogram<K> addHistogram) {
    for (final K key : addHistogram.keySet()){
      this.increment(key, addHistogram.get(key).getValue());
    }
  }
}

代码示例来源:origin: samtools/htsjdk

/***
 * Mutable method that allows the addition of a Histogram into the current one.
 * @param addHistogram
 */
public void addHistogram(final Histogram<K> addHistogram) {
  for (final K key : addHistogram.keySet()){
    this.increment(key, addHistogram.get(key).getValue());
  }
}

代码示例来源:origin: samtools/htsjdk

@Test
public void testGeometricMean() {
  final int[] is = {4,4,4,4,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8};
  final Histogram<Integer> histo = new Histogram<>();
  for (final int i : is) histo.increment(i);
  Assert.assertTrue(abs(histo.getGeometricMean() - 6.216797) < 0.00001);
}

代码示例来源:origin: samtools/htsjdk

@Test
public void testGetMeanBinSize() {
  final int[] is = {4,4,5,5,5};
  final Histogram<Integer> histo = new Histogram<>();
  for (final int i : is) histo.increment(i);
  Assert.assertEquals(histo.getMeanBinSize(), (2+3)/2.0, 0.000001);
}

代码示例来源:origin: samtools/htsjdk

@Test
public void testSize() {
  final int[] is = {4,4,5,5,5};
  final Histogram<Integer> histo = new Histogram<>();
  for (final int i : is) histo.increment(i);
  Assert.assertEquals(histo.size(), 2); //2 unique values
}

代码示例来源:origin: samtools/htsjdk

@Test(dataProvider = "medianTestData")
public void testMedian(final int [] values, final double median) {
  final Histogram<Integer> histo = new Histogram<>();
  for (final int i : values) histo.increment(i);
  Assert.assertEquals(histo.getMedian(), median);
}

代码示例来源:origin: samtools/htsjdk

@Test
public void testGetSum() {
  final int[] is = {4,4,5,5,5};
  final Histogram<Integer> histo = new Histogram<>();
  for (final int i : is) histo.increment(i);
  Assert.assertEquals(histo.getSum(), (double)(2*4+3*5), 0.000001);
}

代码示例来源:origin: samtools/htsjdk

/** Gets the median absolute deviation of the distribution. */
public double getMedianAbsoluteDeviation() {
  final double median = getMedian();
  final Histogram<Double> deviations = new Histogram<>();
  for (final Bin<K> bin : values()) {
    final double dev = abs(bin.getIdValue() - median);
    deviations.increment(dev, bin.getValue());
  }
  return deviations.getMedian();
}

代码示例来源:origin: samtools/htsjdk

@Test
public void testComparator() {
  final int[] is = {4,4,5,5,5};
  final Histogram<Integer> histo1 = new Histogram<>();
  for (final int i : is) histo1.increment(i);
  Assert.assertNull(histo1.comparator());
  final Histogram<Integer> histo2 = new Histogram<>(Comparator.comparingInt(Integer::intValue));
  Comparator<Integer> comp = (Comparator<Integer>) histo2.comparator();
  Assert.assertNotNull(comp);
  Assert.assertEquals(comp.compare(4,5), -1);
}

代码示例来源:origin: samtools/htsjdk

@Test
public void testGetMedianBinSize() {
  final int[] is = {4,4,5,5,5,6,6,6,6};
  final Histogram<Integer> histo = new Histogram<>();
  Assert.assertEquals(histo.getMedianBinSize(), 0, 0.000001); //empty
  for (final int i : is) histo.increment(i);
  Assert.assertEquals(histo.getMedianBinSize(), 3, 0.000001); //three fives
}

代码示例来源:origin: samtools/htsjdk

@Test
public void testGetMedianBinSize_Even() {
  final int[] is = {4,4,5,5,5};
  final Histogram<Integer> histo = new Histogram<>();
  Assert.assertEquals(histo.getMedianBinSize(), 0, 0.000001); //empty
  for (final int i : is) histo.increment(i);
  Assert.assertEquals(histo.getMedianBinSize(), (2+3)/2.0, 0.000001); //even split
}

代码示例来源:origin: samtools/htsjdk

@Test
public void testLabelsAndComparator() {
  final String[] is = {"a", "B", "a"};
  final Histogram<String> histo = new Histogram<>("FOO", "BAR", String.CASE_INSENSITIVE_ORDER);
  for (final String i : is) histo.increment(i);
  Assert.assertEquals(histo.get("a").getValue(), 2.0);
  Assert.assertEquals(histo.get("B").getValue(), 1.0);
  Assert.assertEquals(histo.get("a").getId(), "a");
  Assert.assertEquals(histo.get("B").getId(), "B");
}

相关文章