public void ComputePercentiles_Nominal()
        {
            var repeatNumbers = new[] { 10, 15, 20, 100, 200 };
            var alleleCounts  = new[] { 550, 34, 78, 30, 45 };

            double[] expectedPercentiles =
            {
                0, 550 * 100.0 / 737, (550 + 34) * 100.0 / 737, (550 + 34 + 78) * 100.0 / 737,
                (550 + 34 + 78 + 30) * 100.0 / 737
            };

            double[] observedResults = PercentileUtilities.ComputePercentiles(repeatNumbers.Length, alleleCounts);
            Assert.Equal(expectedPercentiles, observedResults);
        }
        private static (ushort RefIndex, Interval <RepeatExpansionPhenotype> Interval) GetPhenotype(string line, IDictionary <string, IChromosome> refNameToChromosome)
        {
            string[] cols = line.OptimizedSplit('\t');
            if (cols.Length < MinNumberOfColumns)
            {
                throw new InvalidDataException($"Expected at least {MinNumberOfColumns} columns in the STR data file, but found only {cols.Length}.");
            }

            string chromosomeString = cols[ChromIndex];
            int    start            = int.Parse(cols[StartIndex]);
            int    end       = int.Parse(cols[EndIndex]);
            string phenotype = cols[PhenotypeIndex];
            string omimId    = cols[OmimIndex];

            int[]      repeatNumbers        = cols[RepeatNumbersIndex].Split(',').Select(int.Parse).ToArray();
            int[]      alleleCounts         = cols[AlleleCountsIndex].Split(',').Select(int.Parse).ToArray();
            string[]   classifications      = cols[CategoriesIndex].Split(',').ToArray();
            Interval[] classificationRanges = cols[CategoryRangesIndex].Split(',').Select(GetInterval).ToArray();

            if (repeatNumbers.Length != alleleCounts.Length)
            {
                throw new InvalidDataException($"Inconsistent number of repeat numbers ({repeatNumbers.Length}) vs. allele counts ({alleleCounts.Length})");
            }
            if (classifications.Length != classificationRanges.Length)
            {
                throw new InvalidDataException($"Inconsistent number of values of classifications ({classifications.Length}) vs. classification ranges ({classificationRanges.Length})");
            }

            var chromosome         = ReferenceNameUtilities.GetChromosome(refNameToChromosome, chromosomeString);
            var chromosomeInterval = new ChromosomeInterval(chromosome, start, end);

            double[] percentiles = PercentileUtilities.ComputePercentiles(repeatNumbers.Length, alleleCounts);

            var rePhenotype = new RepeatExpansionPhenotype(chromosomeInterval, phenotype, omimId, repeatNumbers, percentiles, classifications, classificationRanges);

            return(chromosome.Index, new Interval <RepeatExpansionPhenotype>(start, end, rePhenotype));
        }
        public void GetPercentile_RepeatNumberOutOfRange_NegativeIndex()
        {
            double observedResult = PercentileUtilities.GetPercentile(20, _values, _percentiles);

            Assert.Equal(100, observedResult);
        }
        public void GetPercentile_RepeatNumberInRange_PositiveIndex()
        {
            double observedResult = PercentileUtilities.GetPercentile(14, _values, _percentiles);

            Assert.Equal(99.5, observedResult);
        }