예제 #1
0
        private static VariantInfo GetVariantInfo(PositionSet positionSet, AlleleBlock alleleBlock)
        {
            var positions    = positionSet.SimplePositions;
            int startIndex   = alleleBlock.PositionIndex;
            int numPositions = alleleBlock.AlleleIndexes.Length;
            int numSamples   = positionSet.NumSamples;

            string qual = GetStringWithMinValueOrDot(Enumerable.Range(startIndex, numPositions)
                                                     .Select(x => positions[x].VcfFields[VcfCommon.QualIndex]));
            var filters = Enumerable.Range(startIndex, numPositions)
                          .Select(i => positions[i].VcfFields[VcfCommon.FilterIndex])
                          .ToArray();

            var gqValues = new string[numSamples];

            for (var i = 0; i < numSamples; i++)
            {
                gqValues[i] = GetStringWithMinValueOrDot(
                    new ArraySegment <string>(positionSet.GqInfo.Values[i], startIndex, numPositions).ToArray());
            }

            var psValues = new string[numSamples];

            for (var i = 0; i < numSamples; i++)
            {
                var psTagsThisSample =
                    new ArraySegment <string>(positionSet.PsInfo.Values[i], startIndex, numPositions);
                var isHomozygous = new ArraySegment <bool>(
                    positionSet.GtInfo.Values[i].Select(x => x.IsHomozygous).ToArray(), startIndex, numPositions);
                psValues[i] = GetPhaseSetForRecomposedVariant(psTagsThisSample, isHomozygous);
            }

            var homoReferenceSamplePloidy = new int?[numSamples];

            for (var i = 0; i < numSamples; i++)
            {
                if (Genotype.IsAllHomozygousReference(positionSet.GtInfo.Values[i], startIndex, numPositions))
                {
                    homoReferenceSamplePloidy[i] = positionSet.GtInfo.Values[i][startIndex].AlleleIndexes.Length;
                }
            }

            var sampleFilters = new List <bool> [numSamples];

            for (var i = 0; i < numSamples; i++)
            {
                sampleFilters[i] = new List <bool>();
            }

            return(new VariantInfo(qual, filters, gqValues, psValues, homoReferenceSamplePloidy, sampleFilters));
        }