本文整理了Java中htsjdk.samtools.util.Histogram.isEmpty()
方法的一些代码示例,展示了Histogram.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Histogram.isEmpty()
方法的具体详情如下:
包路径:htsjdk.samtools.util.Histogram
类名称:Histogram
方法名:isEmpty
[英]Returns true if this histogram has no data in in, false otherwise.
[中]
代码示例来源:origin: broadinstitute/picard
public boolean areHistogramsEmpty() {
return (highQualityDepthHistogram.isEmpty() || highQualityDepthHistogramNonZero.isEmpty());
}
}
代码示例来源:origin: com.github.broadinstitute/picard
public boolean areHistogramsEmpty() {
return (highQualityDepthHistogram.isEmpty() || highQualityDepthHistogramNonZero.isEmpty());
}
}
代码示例来源:origin: com.github.samtools/htsjdk
/**
* Outputs validation error details to out.
*
* @param samReader records to validate
* @param reference if null, NM tag validation is skipped
* processing will stop after this threshold has been reached
* @return boolean true if there are no validation errors, otherwise false
*/
public boolean validateSamFileVerbose(final SamReader samReader, final ReferenceSequenceFile reference) {
init(reference, samReader.getFileHeader());
try {
validateSamFile(samReader, out);
} catch (MaxOutputExceededException e) {
out.println("Maximum output of [" + maxVerboseOutput + "] errors reached.");
}
final boolean result = errorsByType.isEmpty();
cleanup();
return result;
}
代码示例来源:origin: org.seqdoop/htsjdk
/**
* Outputs validation error details to out.
*
* @param samReader records to validate
* @param reference if null, NM tag validation is skipped
* processing will stop after this threshold has been reached
* @return boolean true if there are no validation errors, otherwise false
*/
public boolean validateSamFileVerbose(final SAMFileReader samReader, final ReferenceSequenceFile reference) {
init(reference, samReader.getFileHeader());
try {
validateSamFile(samReader, out);
} catch (MaxOutputExceededException e) {
out.println("Maximum output of [" + maxVerboseOutput + "] errors reached.");
}
boolean result = errorsByType.isEmpty();
cleanup();
return result;
}
代码示例来源:origin: samtools/htsjdk
/**
* Outputs validation error details to out.
*
* @param samReader records to validate
* @param reference if null, NM tag validation is skipped
* processing will stop after this threshold has been reached
* @return boolean true if there are no validation errors, otherwise false
*/
public boolean validateSamFileVerbose(final SamReader samReader, final ReferenceSequenceFile reference) {
init(reference, samReader.getFileHeader());
try {
validateSamFile(samReader, out);
} catch (MaxOutputExceededException e) {
out.println("Maximum output of [" + maxVerboseOutput + "] errors reached.");
}
final boolean result = errorsByType.isEmpty();
cleanup();
return result;
}
代码示例来源:origin: broadinstitute/picard
if (!oqHisto.isEmpty()) metrics.addHistogram(oqHisto);
metrics.write(OUTPUT);
if (qHisto.isEmpty() && oqHisto.isEmpty()) {
log.warn("No valid bases found in input file. No plot will be produced.");
代码示例来源:origin: broadinstitute/picard
@Override
protected void finish() {
collector.finish();
final MetricsFile<RnaSeqMetrics, Integer> file = getMetricsFile();
collector.addAllLevelsToFile(file);
file.write(OUTPUT);
boolean atLeastOneHistogram = false;
for (final Histogram<Integer> histo : file.getAllHistograms()) {
atLeastOneHistogram = atLeastOneHistogram || !histo.isEmpty();
}
// Generate the coverage by position plot
if (CHART_OUTPUT != null && atLeastOneHistogram) {
final int rResult = RExecutor.executeFromClasspath("picard/analysis/rnaSeqCoverage.R",
OUTPUT.getAbsolutePath(),
CHART_OUTPUT.getAbsolutePath(),
INPUT.getName(),
this.plotSubtitle);
if (rResult != 0) {
throw new PicardException("Problem invoking R to generate plot.");
}
}
}
代码示例来源:origin: com.github.broadinstitute/picard
@Override
protected void finish() {
collector.finish();
final MetricsFile<RnaSeqMetrics, Integer> file = getMetricsFile();
collector.addAllLevelsToFile(file);
file.write(OUTPUT);
boolean atLeastOneHistogram = false;
for (final Histogram<Integer> histo : file.getAllHistograms()) {
atLeastOneHistogram = atLeastOneHistogram || !histo.isEmpty();
}
// Generate the coverage by position plot
if (CHART_OUTPUT != null && atLeastOneHistogram) {
final int rResult = RExecutor.executeFromClasspath("picard/analysis/rnaSeqCoverage.R",
OUTPUT.getAbsolutePath(),
CHART_OUTPUT.getAbsolutePath(),
INPUT.getName(),
this.plotSubtitle);
if (rResult != 0) {
throw new PicardException("Problem invoking R to generate plot.");
}
}
}
代码示例来源:origin: com.github.samtools/htsjdk
if (isEmpty()) {
return;
代码示例来源:origin: samtools/htsjdk
@Test
public void testValidSamFile() throws Exception {
final SamReader samReader = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT).open(new File(TEST_DATA_DIR, "valid.sam"));
final Histogram<String> results = executeValidation(samReader, null, IndexValidationStringency.EXHAUSTIVE);
Assert.assertTrue(results.isEmpty());
}
代码示例来源:origin: samtools/htsjdk
@Test
public void testValidCRAMFileWithoutSeqDict() throws Exception {
final File reference = new File(TEST_DATA_DIR, "nm_tag_validation.fa");
final SamReader samReader = SamReaderFactory
.makeDefault()
.validationStringency(ValidationStringency.SILENT)
.referenceSequence(reference)
.open(new File(TEST_DATA_DIR, "nm_tag_validation.cram"));
final Histogram<String> results = executeValidation(samReader,
new FastaSequenceFile(reference, true),
IndexValidationStringency.EXHAUSTIVE);
Assert.assertTrue(!results.isEmpty());
}
代码示例来源: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: org.seqdoop/htsjdk
private void validateSamFile(final SAMFileReader samReader, final PrintWriter out) {
try {
samReader.setValidationStringency(ValidationStringency.SILENT);
validateHeader(samReader.getFileHeader());
orderChecker = new SAMSortOrderChecker(samReader.getFileHeader().getSortOrder());
validateSamRecordsAndQualityFormat(samReader, samReader.getFileHeader());
validateUnmatchedPairs();
if (validateIndex) {
try {
BamIndexValidator.exhaustivelyTestIndex(samReader);
} catch (Exception e) {
addError(new SAMValidationError(Type.INVALID_INDEX_FILE_POINTER, e.getMessage(), null));
}
}
if (errorsByType.isEmpty()) {
out.println("No errors found");
}
} finally {
out.flush();
}
}
代码示例来源: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: com.github.samtools/htsjdk
private void validateSamFile(final SamReader samReader, final PrintWriter out) {
try {
validateHeader(samReader.getFileHeader());
orderChecker = new SAMSortOrderChecker(samReader.getFileHeader().getSortOrder());
validateSamRecordsAndQualityFormat(samReader, samReader.getFileHeader());
validateUnmatchedPairs();
if (indexValidationStringency != IndexValidationStringency.NONE) {
try {
if (indexValidationStringency == IndexValidationStringency.LESS_EXHAUSTIVE) {
BamIndexValidator.lessExhaustivelyTestIndex(samReader);
} else {
BamIndexValidator.exhaustivelyTestIndex(samReader);
}
} catch (Exception e) {
addError(new SAMValidationError(Type.INVALID_INDEX_FILE_POINTER, e.getMessage(), null));
}
}
if (errorsByType.isEmpty()) {
out.println("No errors found");
}
} finally {
out.flush();
}
}
代码示例来源:origin: samtools/htsjdk
private void validateSamFile(final SamReader samReader, final PrintWriter out) {
try {
validateHeader(samReader.getFileHeader());
orderChecker = new SAMSortOrderChecker(samReader.getFileHeader().getSortOrder());
validateSamRecordsAndQualityFormat(samReader, samReader.getFileHeader());
validateUnmatchedPairs();
if (indexValidationStringency != IndexValidationStringency.NONE) {
try {
if (indexValidationStringency == IndexValidationStringency.LESS_EXHAUSTIVE) {
BamIndexValidator.lessExhaustivelyTestIndex(samReader);
} else {
BamIndexValidator.exhaustivelyTestIndex(samReader);
}
} catch (Exception e) {
addError(new SAMValidationError(Type.INVALID_INDEX_FILE_POINTER, e.getMessage(), null));
}
}
if (errorsByType.isEmpty()) {
out.println("No errors found");
}
} finally {
out.flush();
}
}
代码示例来源:origin: samtools/htsjdk
@Test
public void testAddHistogram() {
final int[] is1 = {4,4,5,5,5};
final Histogram<Integer> histo1 = new Histogram<>();
Assert.assertTrue(histo1.isEmpty());
for (final int i : is1) histo1.increment(i);
Assert.assertFalse(histo1.isEmpty());
final int[] is2 = {5,5, 6,6,6,6};
final Histogram<Integer> histo2 = new Histogram<>();
for (final int i : is2) histo2.increment(i);
Assert.assertEquals(histo1.get(4).getValue(), 2.0);
Assert.assertEquals(histo1.get(5).getValue(), 3.0);
Assert.assertEquals(histo1.get(6), null);
histo1.addHistogram(histo2);
Assert.assertEquals(histo1.get(4).getValue(), 2.0);
Assert.assertEquals(histo1.get(5).getValue(), 5.0);
Assert.assertEquals(histo1.get(6).getValue(), 4.0);
}
代码示例来源:origin: com.github.samtools/htsjdk
/**
* Outputs validation summary report to out.
*
* @param samReader records to validate
* @param reference if null, NM tag validation is skipped
* @return boolean true if there are no validation errors, otherwise false
*/
public boolean validateSamFileSummary(final SamReader samReader, final ReferenceSequenceFile reference) {
init(reference, samReader.getFileHeader());
validateSamFile(samReader, out);
boolean result = errorsByType.isEmpty();
if (errorsByType.getCount() > 0) {
// Convert to a histogram with String IDs so that WARNING: or ERROR: can be prepended to the error type.
final Histogram<String> errorsAndWarningsByType = new Histogram<>("Error Type", "Count");
for (final Histogram.Bin<Type> bin : errorsByType.values()) {
errorsAndWarningsByType.increment(bin.getId().getHistogramString(), bin.getValue());
}
final MetricsFile<ValidationMetrics, String> metricsFile = new MetricsFile<>();
errorsByType.setBinLabel("Error Type");
errorsByType.setValueLabel("Count");
metricsFile.setHistogram(errorsAndWarningsByType);
metricsFile.write(out);
}
cleanup();
return result;
}
代码示例来源:origin: samtools/htsjdk
/**
* Outputs validation summary report to out.
*
* @param samReader records to validate
* @param reference if null, NM tag validation is skipped
* @return boolean true if there are no validation errors, otherwise false
*/
public boolean validateSamFileSummary(final SamReader samReader, final ReferenceSequenceFile reference) {
init(reference, samReader.getFileHeader());
validateSamFile(samReader, out);
boolean result = errorsByType.isEmpty();
if (errorsByType.getCount() > 0) {
// Convert to a histogram with String IDs so that WARNING: or ERROR: can be prepended to the error type.
final Histogram<String> errorsAndWarningsByType = new Histogram<>("Error Type", "Count");
for (final Histogram.Bin<Type> bin : errorsByType.values()) {
errorsAndWarningsByType.increment(bin.getId().getHistogramString(), bin.getValue());
}
final MetricsFile<ValidationMetrics, String> metricsFile = new MetricsFile<>();
errorsByType.setBinLabel("Error Type");
errorsByType.setValueLabel("Count");
metricsFile.setHistogram(errorsAndWarningsByType);
metricsFile.write(out);
}
cleanup();
return result;
}
代码示例来源:origin: org.seqdoop/htsjdk
/**
* Outputs validation summary report to out.
*
* @param samReader records to validate
* @param reference if null, NM tag validation is skipped
* @return boolean true if there are no validation errors, otherwise false
*/
public boolean validateSamFileSummary(final SAMFileReader samReader, final ReferenceSequenceFile reference) {
init(reference, samReader.getFileHeader());
validateSamFile(samReader, out);
boolean result = errorsByType.isEmpty();
if (errorsByType.getCount() > 0) {
// Convert to a histogram with String IDs so that WARNING: or ERROR: can be prepended to the error type.
final Histogram<String> errorsAndWarningsByType = new Histogram<String>("Error Type", "Count");
for (final Histogram<SAMValidationError.Type>.Bin bin : errorsByType.values()) {
errorsAndWarningsByType.increment(bin.getId().getHistogramString(), bin.getValue());
}
final MetricsFile<ValidationMetrics, String> metricsFile = new MetricsFile<ValidationMetrics, String>();
errorsByType.setBinLabel("Error Type");
errorsByType.setValueLabel("Count");
metricsFile.setHistogram(errorsAndWarningsByType);
metricsFile.write(out);
}
cleanup();
return result;
}
内容来源于网络,如有侵权,请联系作者删除!