diff --git a/.vscode/launch.json b/.vscode/launch.json index 6aa53df..8e867fd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -23,8 +23,7 @@ "-o", "./tmp/bob.json", "-m", - "BasicStatistics", - "NCountsAtPosition" + "MeanQualityDistribution" ], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/Modules/BasicStatistics.cs b/Modules/BasicStatistics.cs index 8761a0c..81f57e4 100644 --- a/Modules/BasicStatistics.cs +++ b/Modules/BasicStatistics.cs @@ -4,6 +4,8 @@ namespace Ovation.FasterQC.Net { public class BasicStatistics : IQcModule { + private const byte ILLUMINA_BASE_ADJUSTMENT = 33; + private ulong sequenceCount; private int minimumReadLength = int.MaxValue; @@ -87,7 +89,7 @@ public void Reset() nCount, xCount, - minimumQuality, + minimumQuality = Math.Min(minimumQuality - ILLUMINA_BASE_ADJUSTMENT, 0), gcContent = Math.Round((double)(cCount + gCount) / (double)totalBases * 100.0, 3), diff --git a/Modules/MeanQualityDistribution.cs b/Modules/MeanQualityDistribution.cs index ee4f9b5..e4a0358 100644 --- a/Modules/MeanQualityDistribution.cs +++ b/Modules/MeanQualityDistribution.cs @@ -12,9 +12,9 @@ public class MeanQualityDistribution : IQcModule // position and fix it when someone asks private readonly ulong[] qualityScores = new ulong[128]; - private byte lowestScore = byte.MaxValue; + private uint lowestMean = uint.MaxValue; - private byte highestScore = byte.MinValue; + private uint highestMean = uint.MinValue; public string Name => "meanQualityDistribution"; @@ -28,9 +28,9 @@ public object Data { return new { - lowestScore = lowestScore - ILLUMINA_BASE_ADJUSTMENT, - highestScore = highestScore - ILLUMINA_BASE_ADJUSTMENT, - distribution = qualityScores.Skip(lowestScore).Take(highestScore - lowestScore + 1) + lowestMean = lowestMean - ILLUMINA_BASE_ADJUSTMENT, + highestMean = highestMean - ILLUMINA_BASE_ADJUSTMENT, + distribution = qualityScores.Skip((int)lowestMean).Take((int)(highestMean - lowestMean + 1)) }; } } @@ -43,16 +43,17 @@ public void ProcessSequence(Sequence sequence) var count = 0; var qual = sequence.Quality; - for (var q = 0; q < sequenceLength; q++) + for (var i = 0; i < sequenceLength; i++) { - lowestScore = Math.Min(lowestScore, qual[q]); - highestScore = Math.Max(highestScore, qual[q]); - - sum += qual[q]; + sum += qual[i]; count++; } - var mean = sum / count; + var mean = (uint)(sum / count); + + lowestMean = Math.Min(lowestMean, mean); + highestMean = Math.Max(highestMean, mean); + qualityScores[mean]++; } @@ -63,8 +64,8 @@ public void Reset() qualityScores[p] = 0; } - lowestScore = byte.MaxValue; - highestScore = byte.MinValue; + lowestMean = uint.MaxValue; + highestMean = uint.MinValue; } } } \ No newline at end of file