public void addChromosomeCount(String chromosome, int count) { impl.getChromosomeStats().compute(chromosome, (key, chromosomeStats) -> { if (chromosomeStats == null) { return new ChromosomeStats(count, 0F); } else { chromosomeStats.setCount(chromosomeStats.getCount() + count); return chromosomeStats; } }); }
public void setChromosomeCount(String chromosome, int count) { impl.getChromosomeStats().compute(chromosome, (key, chromosomeStats) -> { if (chromosomeStats == null) { return new ChromosomeStats(count, 0F); } else { chromosomeStats.setCount(count); return chromosomeStats; } }); }
@Override public synchronized void post() { float meanQuality = (float) (qualSum / qualCount); stats.setMeanQuality(meanQuality); //Var = SumSq / n - mean * mean stats.setStdDevQuality((float) Math.sqrt(qualSumSq / qualCount - meanQuality * meanQuality)); stats.setTiTvRatio(transitionsCount, transversionsCount); Map<String, Integer> chrLengthMap = header.getComplexLines() .stream() .filter(line -> line.getKey().equalsIgnoreCase("contig")) .collect(Collectors.toMap(line -> Region.normalizeChromosome(line.getId()), line -> { String length = line.getGenericFields().get("length"); if (StringUtils.isNumeric(length)) { return Integer.parseInt(length); } else { return -1; } })); stats.getChromosomeStats().forEach((chr, stats) -> { Integer length = chrLengthMap.get(chr); if (length != null && length > 0) { stats.setDensity(stats.getCount() / (float) length); } }); }
@Override public ChromosomeStats build() { try { ChromosomeStats record = new ChromosomeStats(); record.count = fieldSetFlags()[0] ? this.count : (java.lang.Integer) defaultValue(fields()[0]); record.density = fieldSetFlags()[1] ? this.density : (java.lang.Float) defaultValue(fields()[1]); return record; } catch (Exception e) { throw new org.apache.avro.AvroRuntimeException(e); } } }
private int getChromosomeCount(String chromosome) { ChromosomeStats chromosomeStats = impl.getChromosomeStats().get(chromosome); return chromosomeStats == null ? 0 : chromosomeStats.getCount(); }
public VariantSetStats convertStats(org.opencb.biodata.models.variant.avro.legacy.VariantGlobalStats legacyStats) { return new VariantSetStats(org.opencb.biodata.models.variant.metadata.VariantSetStats.newBuilder() .setNumVariants(legacyStats.getNumRecords()) .setMeanQuality(legacyStats.getMeanQuality().floatValue()) .setNumPass(legacyStats.getPassCount()) .setNumSamples(legacyStats.getSamplesCount()) .setTiTvRatio(legacyStats.getTransitionsCount() / (float) legacyStats.getTransversionsCount()) .setVariantTypeCounts(legacyStats.getVariantTypeCounts()) .setConsequenceTypesCounts(legacyStats.getConsequenceTypesCount()) .setStdDevQuality(0) .setChromosomeStats(legacyStats.getChromosomeCounts().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, entry -> new ChromosomeStats(entry.getValue(), 0F)))).build()); }
public Map<String, Integer> getChromosomeCounts() { return impl.getChromosomeStats().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, o -> o.getValue().getCount())); }