@Override public String toString() { final StringBuilder sb = new StringBuilder(); final int[] assignment = new int[mStrains]; int currentIndex = 0; int last = -1; while (currentIndex > 0 || last <= max(assignment, currentIndex)) { assignment[currentIndex++] = last + 1; while (currentIndex < assignment.length) { assignment[currentIndex++] = 0; } int countIndex = 0; for (int i = 0; i < mStride.length; i++) { countIndex += assignment[i] * mStride[i]; } sb.append(Arrays.toString(assignment)); sb.append(" = "); sb.append(mCounts[countIndex]); sb.append("\t"); sb.append(Utils.realFormat((double) mCounts[countIndex] / mTotal, 6)); sb.append(StringUtils.LS); last = assignment[--currentIndex]; while (last == max(assignment, currentIndex) + 1 && currentIndex > 0) { last = assignment[--currentIndex]; } } return sb.toString(); }
public void test() throws IOException { final ImplementHashFunction hf = getHashFunction(); hf.integrity(0, 0, 0); hf.hashStep((byte) 0); hf.integrity(0, 0, 1); hf.hashStep((byte) 1); hf.integrity(0, 1, 2); hf.hashStep((byte) 2); hf.integrity(1, 2, 3); hf.hashStep((byte) 3); hf.integrity(3, 5, 4); assertEquals("ImplementHashFunction read length=36 window size=18", hf.toString()); assertEquals( "00000000:00000000:00000000:00000000:00000000:00000000:00000000:00000011", Utils.toBitsSep(hf.mValuesF0)); assertEquals( "00000000:00000000:00000000:00000000:00000000:00000000:00000000:00000101", Utils.toBitsSep(hf.mValuesF1)); hf.reset(); hf.integrity(0, 0, 0); }
String countsString() { return mReadGroup + "\t" + mTotalReference + "\t" + mLengthDist.count() + "\t" + Utils.realFormat(mLengthDist.sum()) + "\t" + Utils.realFormat(mLengthDist.sumSq()) + "\t" + mFragmentSizeDist.count() + "\t" + Utils.realFormat(mFragmentSizeDist.sum()) + "\t" + Utils.realFormat(mFragmentSizeDist.sumSq()) + "\t" + mGapSizeDist.count() + "\t" + Utils.realFormat(mGapSizeDist.sum()) + "\t" + Utils.realFormat(mGapSizeDist.sumSq()) + "\t" + mMaxAlignment + "\t" + mProper + "\t" + mDiscordant + "\t" + mUnmated; }
@Override public String toString() { return id() + "\t" + Utils.realFormat(meanLength(), 5) + "\t" + Utils.realFormat(fragmentMean(), 5) + "\t" + Utils.realFormat(fragmentStdDev(), 5) + "\t" + Utils.realFormat(gapMean(), 5) + "\t" + Utils.realFormat(gapStdDev(), 5) + "\t" + Utils.realFormat(maxAlignment(), 5) + "\t" + Utils.realFormat(properRate(), 6) + "\t" + Utils.realFormat(properRandomRate(), 6) + "\t" + Utils.realFormat(discordantRate(), 6) + "\t" + Utils.realFormat(unmatedRate(), 6); }
/** * @param calibrator the mapping calibration stats to use when computing coverage * @param defaultSequenceLengths map of sequence names to sequence length, used if not already set * in the calibrator * @param readGroupToSampleId read group to sample id * @param restriction a region restriction, may be null */ public CalibratedPerSequenceExpectedCoverage( Calibrator calibrator, Map<String, Integer> defaultSequenceLengths, Map<String, String> readGroupToSampleId, RegionRestriction restriction) { mSequenceSampleCoverages = new HashMap<>(); mSumCoverages = new HashMap<>(); mSamples = Collections.unmodifiableSet(new HashSet<>(readGroupToSampleId.values())); final Map<String, Integer> sequenceLengths = calibrator.hasLengths() ? calibrator.getSequenceLengths() : defaultSequenceLengths; if (calibrator.getCovariateIndex(CovariateEnum.SEQUENCE) == -1) { // No per sequence separation in calibration data, calculate per-genome coverage // level long length = 0; for (final Map.Entry<String, Integer> entry : sequenceLengths.entrySet()) { length += entry.getValue(); } final Map<String, HashMap<String, CalibrationStats>> local = new HashMap<>(); findIndividualGlobalCoverage(calibrator, readGroupToSampleId, local); double currentMax = 0; double currentSum = 0; for (Map.Entry<String, HashMap<String, CalibrationStats>> e : local.entrySet()) { final HashMap<String, CalibrationStats> map = e.getValue(); if (map.containsKey(DUMMY_SEQ)) { final double currentCov = (length == 0) ? 0 : (double) map.get(DUMMY_SEQ).getTotalLength() / length; final String sampleName = e.getKey(); Diagnostic.userLog( "Average coverage for sample " + sampleName + " is " + Utils.realFormat(currentCov, 2)); for (final Map.Entry<String, Integer> entry : sequenceLengths.entrySet()) { final String seqName = entry.getKey(); Map<String, Double> samples = mSequenceSampleCoverages.get(seqName); if (samples == null) { samples = new HashMap<>(); mSequenceSampleCoverages.put(seqName, samples); } samples.put(sampleName, currentCov); } currentSum += currentCov; if (currentCov > currentMax) { currentMax = currentCov; } } } Diagnostic.userLog("Average combined coverage is " + Utils.realFormat(currentSum, 2)); for (final Map.Entry<String, Integer> entry : sequenceLengths.entrySet()) { final String seqName = entry.getKey(); mSumCoverages.put(seqName, currentSum); } } else { // Per-sequence separation is in calibration data, calculate per-sequence coverage // level final Map<String, HashMap<String, CalibrationStats>> local = new HashMap<>(); findIndividualPerSequenceCoverage( calibrator, sequenceLengths, readGroupToSampleId, local, restriction); for (final Map.Entry<String, Integer> entry : sequenceLengths.entrySet()) { final String seqName = entry.getKey(); if (restriction != null && !seqName.equals(restriction.getSequenceName())) { continue; } final int seqLength = entry.getValue(); double currentMax = 0; double currentSum = 0; for (Map.Entry<String, HashMap<String, CalibrationStats>> e : local.entrySet()) { final HashMap<String, CalibrationStats> map = e.getValue(); if (map.containsKey(seqName)) { final double currentCov = (seqLength == 0) ? 0 : (double) map.get(seqName).getTotalLength() / seqLength; final String sampleName = e.getKey(); Diagnostic.userLog( "Average coverage across sequence " + seqName + " for sample " + sampleName + " is " + Utils.realFormat(currentCov, 2)); Map<String, Double> samples = mSequenceSampleCoverages.get(seqName); if (samples == null) { samples = new HashMap<>(); mSequenceSampleCoverages.put(seqName, samples); } samples.put(sampleName, currentCov); currentSum += currentCov; if (currentCov > currentMax) { currentMax = currentCov; } } } Diagnostic.userLog( "Average combined coverage for sequence " + seqName + " is " + Utils.realFormat(currentSum, 2)); mSumCoverages.put(seqName, currentSum); } } }