本文整理了Java中htsjdk.samtools.util.Histogram.get()
方法的一些代码示例,展示了Histogram.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Histogram.get()
方法的具体详情如下:
包路径:htsjdk.samtools.util.Histogram
类名称:Histogram
方法名:get
[英]Retrieves the bin associated with the given key.
[中]检索与给定密钥关联的bin。
代码示例来源:origin: broadinstitute/picard
/**
* Returns the count defined by the truth state set and call state set.
*/
public long getCount(final TruthAndCallStates truthAndCallStates) {
final Histogram.Bin<TruthAndCallStates> bin = this.counter.get(truthAndCallStates);
return (bin == null ? 0L : (long) bin.getValue());
}
代码示例来源:origin: com.github.broadinstitute/picard
public static double[] normalizeHistogram(final Histogram<Integer> histogram) {
if (histogram == null) throw new PicardException("Histogram is null and cannot be normalized");
final double histogramSumOfValues = histogram.getSumOfValues();
final double[] normalizedHistogram = new double[histogram.size()];
for (int i = 0; i < histogram.size(); i++) {
if (histogram.get(i) != null) {
normalizedHistogram[i] = histogram.get(i).getValue() / histogramSumOfValues;
}
}
return normalizedHistogram;
}
代码示例来源:origin: com.github.broadinstitute/picard
/**
* Returns the count defined by the truth state set and call state set.
*/
public long getCount(final TruthAndCallStates truthAndCallStates) {
final Histogram.Bin<TruthAndCallStates> bin = this.counter.get(truthAndCallStates);
return (bin == null ? 0L : (long) bin.getValue());
}
代码示例来源:origin: broadinstitute/picard
public static double[] normalizeHistogram(final Histogram<Integer> histogram) {
if (histogram == null) throw new PicardException("Histogram is null and cannot be normalized");
final double histogramSumOfValues = histogram.getSumOfValues();
final double[] normalizedHistogram = new double[histogram.size()];
for (int i = 0; i < histogram.size(); i++) {
if (histogram.get(i) != null) {
normalizedHistogram[i] = histogram.get(i).getValue() / histogramSumOfValues;
}
}
return normalizedHistogram;
}
代码示例来源:origin: org.seqdoop/htsjdk
/** Increments the value in the designated bin by the supplied increment. */
public void increment(final K id, final double increment) {
Bin bin = get(id);
if (bin == null) {
bin = new Bin(id);
put(id, bin);
}
bin.value += increment;
mean = null;
}
代码示例来源:origin: com.github.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 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");
}
代码示例来源:origin: samtools/htsjdk
@Test(dataProvider = "testMateCigarScenarios")
public void testMateCigarScenarios(final String scenario, final String inputFile, final SAMValidationError.Type expectedError)
throws Exception {
final SamReader reader = SamReaderFactory.makeDefault().open(new File(TEST_DATA_DIR, inputFile));
final Histogram<String> results = executeValidation(reader, null, IndexValidationStringency.EXHAUSTIVE);
Assert.assertNotNull(results.get(expectedError.getHistogramString()), scenario);
Assert.assertEquals(results.get(expectedError.getHistogramString()).getValue(), 1.0, scenario);
}
代码示例来源:origin: samtools/htsjdk
@Test
public void testHeaderValidation() throws Exception {
final SamReader samReader = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT)
.open(new File(TEST_DATA_DIR, "buggyHeader.sam"));
final File referenceFile = new File(TEST_DATA_DIR, "../hg19mini.fasta");
final ReferenceSequenceFile reference = new FastaSequenceFile(referenceFile, false);
final Histogram<String> results = executeValidation(samReader, reference, IndexValidationStringency.EXHAUSTIVE);
Assert.assertEquals(results.get(SAMValidationError.Type.UNRECOGNIZED_HEADER_TYPE.getHistogramString()).getValue(), 3.0);
Assert.assertEquals(results.get(SAMValidationError.Type.HEADER_TAG_MULTIPLY_DEFINED.getHistogramString()).getValue(), 1.0);
Assert.assertEquals(results.get(SAMValidationError.Type.MISMATCH_FILE_SEQ_DICT.getHistogramString()).getValue(), 1.0);
}
代码示例来源:origin: samtools/htsjdk
@Test(dataProvider = "validateBamFileTerminationData")
public void validateBamFileTerminationTest(final File file, final SAMValidationError.Type errorType, final int numWarnings, final int numErrors) throws IOException {
final SamFileValidator samFileValidator = new SamFileValidator(new PrintWriter(System.out), 8000);
samFileValidator.validateBamFileTermination(file);
Assert.assertEquals(samFileValidator.getErrorsByType().get(errorType).getValue(), 1.0);
Assert.assertEquals(samFileValidator.getNumWarnings(), numWarnings);
Assert.assertEquals(samFileValidator.getNumErrors(), numErrors);
}
代码示例来源:origin: samtools/htsjdk
@Test(enabled = false, description = "File is actually valid for Standard quality scores so this test fails with an NPE.")
public void testQualityFormatValidation() throws Exception {
final SamReader samReader = SamReaderFactory.makeDefault().open(new File("./src/test/resources/htsjdk/samtools/util/QualityEncodingDetectorTest/illumina-as-standard.bam"));
final Histogram<String> results = executeValidation(samReader, null, IndexValidationStringency.EXHAUSTIVE);
final Histogram.Bin<String> bin = results.get(SAMValidationError.Type.INVALID_QUALITY_FORMAT.getHistogramString());
final double value = bin.getValue();
Assert.assertEquals(value, 1.0);
}
代码示例来源:origin: samtools/htsjdk
@Test(dataProvider = "missingMateTestCases")
public void testMissingMate(final SAMFileHeader.SortOrder sortOrder) throws IOException {
final SAMRecordSetBuilder samBuilder = new SAMRecordSetBuilder(true, sortOrder);
samBuilder.addPair(String.valueOf(1), 1, 1, 101);
final Iterator<SAMRecord> records = samBuilder.iterator();
records.next();
records.remove();
final Histogram<String> results = executeValidation(samBuilder.getSamReader(), null, IndexValidationStringency.EXHAUSTIVE);
Assert.assertEquals(results.get(SAMValidationError.Type.MATE_NOT_FOUND.getHistogramString()).getValue(), 1.0);
}
代码示例来源:origin: samtools/htsjdk
@Test(dataProvider = "testQualitiesNotStored")
public void testNotStoredQualitiesFields(final String inputFile, final double expectedValue) throws IOException {
try (final SamReader reader = SamReaderFactory.makeDefault().open((new File(TEST_DATA_DIR, inputFile)))) {
final Histogram<String> results = executeValidation(reader, null, IndexValidationStringency.EXHAUSTIVE);
Assert.assertEquals(results.get(SAMValidationError.Type.QUALITY_NOT_STORED.getHistogramString()).getValue(), expectedValue);
}
}
代码示例来源:origin: samtools/htsjdk
@Test
public void testDuplicateRGIDs() throws Exception {
final SamReader samReader = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT)
.open((new File(TEST_DATA_DIR, "duplicate_rg.sam")));
final Histogram<String> results = executeValidation(samReader, null, IndexValidationStringency.EXHAUSTIVE);
Assert.assertEquals(results.get(SAMValidationError.Type.DUPLICATE_READ_GROUP_ID.getHistogramString()).getValue(), 1.0);
}
代码示例来源:origin: samtools/htsjdk
@Test
public void testIndexFileValidation() throws Exception {
final SamReader samReader = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT)
.enable(SamReaderFactory.Option.CACHE_FILE_BASED_INDEXES).open((new File(TEST_DATA_DIR, "bad_index.bam")));
Histogram<String> results = executeValidation(samReader, null, IndexValidationStringency.EXHAUSTIVE);
Assert.assertEquals(results.get(SAMValidationError.Type.INVALID_INDEX_FILE_POINTER.getHistogramString()).getValue(), 1.0);
results = executeValidation(samReader, null, IndexValidationStringency.LESS_EXHAUSTIVE);
Assert.assertEquals(results.get(SAMValidationError.Type.INVALID_INDEX_FILE_POINTER.getHistogramString()).getValue(), 1.0);
}
代码示例来源:origin: samtools/htsjdk
@Test
public void duplicateReadsOutOfOrder() throws Exception {
final SamReader samReader = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT).open(new File(TEST_DATA_DIR, "duplicated_reads_out_of_order.sam"));
final Histogram<String> results = executeValidation(samReader, null, IndexValidationStringency.EXHAUSTIVE);
Assert.assertFalse(results.isEmpty());
Assert.assertEquals(results.get(SAMValidationError.Type.MATES_ARE_SAME_END.getHistogramString()).getValue(), 2.0);
}
代码示例来源:origin: samtools/htsjdk
@Test
public void testPlatformInvalid() throws Exception {
final SamReader samReader = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT)
.open((new File(TEST_DATA_DIR, "invalid_platform_unit.sam")));
final Histogram<String> results = executeValidation(samReader, null, IndexValidationStringency.EXHAUSTIVE);
Assert.assertEquals(results.get(SAMValidationError.Type.INVALID_PLATFORM_VALUE.getHistogramString()).getValue(), 1.0);
}
代码示例来源:origin: samtools/htsjdk
@Test(enabled = false)
public void duplicateReads() throws Exception {
final SamReader samReader = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT).open(new File(TEST_DATA_DIR, "duplicated_reads.sam"));
final Histogram<String> results = executeValidation(samReader, null, IndexValidationStringency.EXHAUSTIVE);
Assert.assertFalse(results.isEmpty());
Assert.assertEquals(results.get(SAMValidationError.Type.MATES_ARE_SAME_END.getHistogramString()).getValue(), 2.0);
}
代码示例来源:origin: samtools/htsjdk
@Test
public void testHeaderVersionValidation() throws Exception {
final String header = "@HD VN:Hi,Mom! SO:queryname";
final InputStream strm = new ByteArrayInputStream(StringUtil.stringToBytes(header));
final SamReader samReader = SamReaderFactory.makeDefault().open(SamInputResource.of(strm));
final Histogram<String> results = executeValidation(samReader, null, IndexValidationStringency.EXHAUSTIVE);
Assert.assertEquals(results.get(SAMValidationError.Type.INVALID_VERSION_NUMBER.getHistogramString()).getValue(), 1.0);
}
代码示例来源:origin: samtools/htsjdk
@Test
public void testCigarNoSeqValidation() throws Exception {
final SAMRecordSetBuilder samBuilder = new SAMRecordSetBuilder();
samBuilder.addFrag("name", 0, 1, false);
samBuilder.iterator().next().setReadBases(SAMRecord.NULL_SEQUENCE);
samBuilder.iterator().next().setBaseQualities(SAMRecord.NULL_SEQUENCE);
final Histogram<String> results = executeValidation(samBuilder.getSamReader(), null, IndexValidationStringency.EXHAUSTIVE);
Assert.assertNull(results.get(SAMValidationError.Type.MISMATCH_CIGAR_SEQ_LENGTH .getHistogramString()));
}
内容来源于网络,如有侵权,请联系作者删除!