本文整理了Java中htsjdk.samtools.util.Histogram.keySet()
方法的一些代码示例,展示了Histogram.keySet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Histogram.keySet()
方法的具体详情如下:
包路径:htsjdk.samtools.util.Histogram
类名称:Histogram
方法名:keySet
[英]Returns the set of keys for this histogram.
[中]
代码示例来源:origin: com.github.samtools/htsjdk
/***
* Immutable method that divides the current Histogram by an input Histogram and generates a new one
* Throws an exception if the bins don't match up exactly
* @param divisorHistogram
* @return
* @throws IllegalArgumentException if the keySet of this histogram is not equal to the keySet of the given divisorHistogram
*/
public Histogram<K> divideByHistogram(final Histogram<K> divisorHistogram) {
final Histogram<K> output = new Histogram<K>();
if (!this.keySet().equals(divisorHistogram.keySet())) throw new IllegalArgumentException("Attempting to divide Histograms with non-identical bins");
for (final K key : this.keySet()){
final Bin<K> dividend = this.get(key);
final Bin<K> divisor = divisorHistogram.get(key);
output.increment(key, dividend.getValue()/divisor.getValue());
}
return output;
}
代码示例来源:origin: samtools/htsjdk
/***
* Immutable method that divides the current Histogram by an input Histogram and generates a new one
* Throws an exception if the bins don't match up exactly
* @param divisorHistogram
* @return
* @throws IllegalArgumentException if the keySet of this histogram is not equal to the keySet of the given divisorHistogram
*/
public Histogram<K> divideByHistogram(final Histogram<K> divisorHistogram) {
final Histogram<K> output = new Histogram<K>();
if (!this.keySet().equals(divisorHistogram.keySet())) throw new IllegalArgumentException("Attempting to divide Histograms with non-identical bins");
for (final K key : this.keySet()){
final Bin<K> dividend = this.get(key);
final Bin<K> divisor = divisorHistogram.get(key);
output.increment(key, dividend.getValue()/divisor.getValue());
}
return output;
}
代码示例来源:origin: org.seqdoop/htsjdk
/***
* Immutable method that divides the current Histogram by an input Histogram and generates a new one
* Throws an exception if the bins don't match up exactly
* @param divisorHistogram
* @return
* @throws IllegalArgumentException
*/
public Histogram<K> divideByHistogram(final Histogram<K> divisorHistogram) throws IllegalArgumentException{
Histogram<K> output = new Histogram<K>();
if (!this.keySet().equals(divisorHistogram.keySet())) throw new IllegalArgumentException("Attempting to divide Histograms with non-identical bins");
for (final K key : this.keySet()){
Bin dividend = this.get(key);
Bin divisor = divisorHistogram.get(key);
output.increment(key, dividend.getValue()/divisor.getValue());
}
return output;
}
代码示例来源: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
if (histo != null) keys.addAll(histo.keySet());
out.append(HISTO_HEADER + nonEmptyHistograms.get(0).keySet().iterator().next().getClass().getName());
out.newLine();
代码示例来源:origin: com.github.samtools/htsjdk
if (histo != null) keys.addAll(histo.keySet());
out.append(HISTO_HEADER + nonEmptyHistograms.get(0).keySet().iterator().next().getClass().getName());
out.newLine();
代码示例来源:origin: org.seqdoop/htsjdk
if (histo != null) keys.addAll(histo.keySet());
out.append(HISTO_HEADER + nonEmptyHistograms.get(0).keySet().iterator().next().getClass().getName());
out.newLine();
代码示例来源: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 testGetKeySet() {
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.keySet(), new HashSet<>(Arrays.asList(4,5)));
}
代码示例来源:origin: com.github.broadinstitute/picard
private List<RrbsCpgDetailMetrics> buildDetailMetrics() {
final List<RrbsCpgDetailMetrics> detailMetrics = new ArrayList<RrbsCpgDetailMetrics>();
for (final CpgLocation key : cpgTotal.keySet()) {
final RrbsCpgDetailMetrics cpgMetric = new RrbsCpgDetailMetrics();
cpgMetric.SAMPLE = sample;
cpgMetric.READ_GROUP = readGroup;
cpgMetric.LIBRARY = library;
cpgMetric.SEQUENCE_NAME = key.getSequence();
cpgMetric.POSITION = key.getPosition();
cpgMetric.TOTAL_SITES = (int)cpgTotal.get(key).getValue();
cpgMetric.CONVERTED_SITES = cpgConverted.containsKey(key) ? (int)cpgConverted.get(key).getValue() : 0;
cpgMetric.PCT_CONVERTED = cpgMetric.CONVERTED_SITES == 0 ? 0 : cpgMetric.CONVERTED_SITES / (double)cpgMetric.TOTAL_SITES;
detailMetrics.add(cpgMetric);
}
return detailMetrics;
}
}
代码示例来源:origin: samtools/htsjdk
final Object keys[] = keySet().toArray();
for (Object binId : keys) {
if (!binsToKeep.contains(binId)) {
代码示例来源:origin: com.github.samtools/htsjdk
final Object keys[] = keySet().toArray();
for (Object binId : keys) {
if (!binsToKeep.contains(binId)) {
代码示例来源:origin: broadinstitute/picard
private List<RrbsCpgDetailMetrics> buildDetailMetrics() {
final List<RrbsCpgDetailMetrics> detailMetrics = new ArrayList<RrbsCpgDetailMetrics>();
for (final CpgLocation key : cpgTotal.keySet()) {
final RrbsCpgDetailMetrics cpgMetric = new RrbsCpgDetailMetrics();
cpgMetric.SAMPLE = sample;
cpgMetric.READ_GROUP = readGroup;
cpgMetric.LIBRARY = library;
cpgMetric.SEQUENCE_NAME = key.getSequence();
cpgMetric.POSITION = key.getPosition();
cpgMetric.TOTAL_SITES = (int)cpgTotal.get(key).getValue();
cpgMetric.CONVERTED_SITES = cpgConverted.containsKey(key) ? (int)cpgConverted.get(key).getValue() : 0;
cpgMetric.PCT_CONVERTED = cpgMetric.CONVERTED_SITES == 0 ? 0 : cpgMetric.CONVERTED_SITES / (double)cpgMetric.TOTAL_SITES;
detailMetrics.add(cpgMetric);
}
return detailMetrics;
}
}
代码示例来源:origin: org.seqdoop/htsjdk
final Object keys[] = keySet().toArray();
for (Object binId : keys) {
if (!binsToKeep.contains((K)binId)) {
代码示例来源:origin: PapenfussLab/gridss
public void addMetricsToFile(final MetricsFile<GcMetrics,Integer> file) {
final GcMetrics metrics = new GcMetrics();
metrics.SAMPLE = this.sample;
metrics.LIBRARY = this.library;
metrics.READ_GROUP = this.readGroup;
double totalGc = 0;
int totalReads = 0;
for (Integer gcBin : histogram.keySet()) {
int count = (int)histogram.get(gcBin).getValue();
totalReads += count;
totalGc += gcBin * count;
}
metrics.MEAN_GC_CONTENT = totalGc;
metrics.READ_COUNT = totalReads;
file.addHistogram(histogram);
file.addMetric(metrics);
}
}
代码示例来源:origin: broadinstitute/picard
@Override
public void test() throws IOException {
final MetricsFile<DuplicationMetrics, Double> metricsOutput = testMetrics();
// Check contents of set size bin against expected values
if (!expectedSetSizeMap.isEmpty()) {
boolean checked = false;
for (final Histogram<Double> histo : metricsOutput.getAllHistograms()) {
final String label = histo.getValueLabel();
for (final Double bin : histo.keySet()) {
final String binStr = String.valueOf(bin);
final List<String> labelBinStr = Arrays.asList(label, binStr);
if (expectedSetSizeMap.containsKey(labelBinStr)) {
checked = true;
Histogram.Bin<Double> binValue = histo.get(bin);
final double actual = binValue.getValue();
final double expected = expectedSetSizeMap.get(labelBinStr);
Assert.assertEquals(actual, expected);
}
}
}
if (!checked) {
Assert.fail("Could not not find matching entry for expectedSetSizeMap in metrics.");
}
}
}
代码示例来源:origin: PapenfussLab/gridss
public static InsertSizeDistribution create(Histogram<Integer> insertSizeHistogram) {
if (insertSizeHistogram == null) return null;
int[] insertSize = new int[insertSizeHistogram.size()];
double[] count = new double[insertSizeHistogram.size()];
double total = insertSizeHistogram.getSumOfValues();
int i = 0;
Set<Integer> keys = insertSizeHistogram.keySet();
for (Integer key : keys) {
insertSize[i] = key;
count[i] = insertSizeHistogram.get(key).getValue();
i++;
}
return new InsertSizeDistribution(insertSize, count, (long)total);
}
public InsertSizeDistribution(int[] singletons, double[] readCounts) {
代码示例来源:origin: PapenfussLab/gridss
public void addMetricsToFile(final MetricsFile<MapqMetrics,Integer> file) {
final MapqMetrics metrics = new MapqMetrics();
metrics.SAMPLE = this.sample;
metrics.LIBRARY = this.library;
metrics.READ_GROUP = this.readGroup;
metrics.MAPPED_READS = (long) histogram.getCount();
metrics.MIN_MAPQ = SAMRecord.UNKNOWN_MAPPING_QUALITY;
metrics.MAX_MAPQ = 0;
for (int key : histogram.keySet()) {
if (key != SAMRecord.UNKNOWN_MAPPING_QUALITY) {
if (histogram.get(key).getValue() > 0) {
metrics.MIN_MAPQ = Math.min(metrics.MIN_MAPQ, key);
metrics.MAX_MAPQ = Math.max(metrics.MAX_MAPQ, key);
}
}
}
if (histogram.get(SAMRecord.NO_MAPPING_QUALITY) != null) {
metrics.ZERO_MAPQ = (long) histogram.get(SAMRecord.NO_MAPPING_QUALITY).getValue();
}
if (histogram.get(SAMRecord.UNKNOWN_MAPPING_QUALITY) != null) {
metrics.UNKNOWN_MAPQ = (long) histogram.get(SAMRecord.UNKNOWN_MAPPING_QUALITY).getValue();
}
file.addHistogram(histogram);
file.addMetric(metrics);
}
}
代码示例来源:origin: broadinstitute/picard
for (final Integer bin : duplicationHisto.keySet()) {
final double duplicateGroups = duplicationHisto.get(bin).getValue();
final double opticalDuplicates = opticalHisto.get(bin) == null ? 0 : opticalHisto.get(bin).getValue();
内容来源于网络,如有侵权,请联系作者删除!