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; }
void add(ReadGroupStats stats) { mLengthDist.add(stats.mLengthDist); mFragmentSizeDist.add(stats.mFragmentSizeDist); mGapSizeDist.add(stats.mGapSizeDist); mMaxAlignment = Math.max(mMaxAlignment, stats.mMaxAlignment); mProper += stats.mProper; mDiscordant += stats.mDiscordant; mUnmated += stats.mUnmated; if (detectOverflow()) { throw new NoTalkbackSlimException( "Overflow detected in read group statistics calculation for read group: " + id()); } }
void calculate() { if (mLengthDist != null) { mMeanLength = mLengthDist.count() > 1 ? mLengthDist.mean() : 0; mFragmentStdDev = mFragmentSizeDist.count() > 1 ? mFragmentSizeDist.stdDev() + TINY : 0; mFragmentMean = mFragmentSizeDist.count() > 1 ? mFragmentSizeDist.mean() : 0; mGapStdDev = mGapSizeDist.count() > 1 ? mGapSizeDist.stdDev() + TINY : 0; mGapMean = mGapSizeDist.count() > 1 ? mGapSizeDist.mean() : 0; mProperRate = (double) (mProper + 1) / mTotalReference / 2.0 + TINY; mDiscordantRate = (double) (mDiscordant + 1) / mTotalReference / 2.0 + TINY; mUnmatedRate = (double) (mUnmated + 1) / mTotalReference / 2.0 + TINY; mProperRandomRate = mDiscordantRate * mUnmatedRate; // TODO we think this should be better: // mProperRandomRate = mDiscordantRate * (2 * mGapStdDev / mTotalReference); mAlignmentStartIgnored = (int) (mMeanLength * mAlignmentStartIgnoredFraction / 100); } }
boolean detectOverflow() { return mProper < 0 || mDiscordant < 0 || mUnmatedRate < 0 || mLengthDist.count() < 0; }
void addGapSize(int value) { mGapSizeDist.add(value); }
void addFragmentSize(int value) { mFragmentSizeDist.add(value); }
void addLength(int readlen) { mLengthDist.add(readlen); }