Beispiel #1
0
        public void GetPositionsAndRefAltAlleles_AsExpected()
        {
            var genotypeBlock    = new GenotypeBlock(new[] { "1|2", "1/1", "0|1", "0/1" }.Select(Genotype.GetGenotype).ToArray());
            var genotypeToSample =
                new Dictionary <GenotypeBlock, List <int> > {
                { genotypeBlock, new List <int> {
                      0
                  } }
            };
            var indexOfUnsupportedVars = Enumerable.Repeat(new HashSet <int>(), genotypeBlock.Genotypes.Length).ToArray();
            var starts = new[] { 356, 358, 360, 361 };
            var functionBlockRanges = new List <int> {
                358, 360, 362, 364
            };
            var          alleles     = new[] { new[] { "G", "C", "T" }, new[] { "A", "T" }, new[] { "C", "G" }, new[] { "G", "T" } };
            const string refSequence = "GAATCG";
            var          alleleBlockToSampleHaplotype       = AlleleBlock.GetAlleleBlockToSampleHaplotype(genotypeToSample, indexOfUnsupportedVars, starts, functionBlockRanges, out var alleleBlockGraph);
            var          mergedAlleleBlockToSampleHaplotype =
                AlleleBlockMerger.Merge(alleleBlockToSampleHaplotype, alleleBlockGraph).ToArray();
            var alleleSet    = new AlleleSet(ChromosomeUtilities.Chr1, starts, alleles);
            var alleleBlocks = mergedAlleleBlockToSampleHaplotype.Select(x => x.Key).ToArray();
            var sequence     = new NSequence();

            var result1 = VariantGenerator.GetPositionsAndRefAltAlleles(alleleBlocks[0], alleleSet, refSequence, starts[0], null, sequence, _vidCreator);
            var result2 = VariantGenerator.GetPositionsAndRefAltAlleles(alleleBlocks[1], alleleSet, refSequence, starts[0], null, sequence, _vidCreator);

            var expectedVarPosIndexes1 = new List <int> {
                0, 1
            };
            var expectedVarPosIndexes2 = new List <int> {
                0, 1, 2
            };

            Assert.Equal((356, 360, "GAATC", "CATTC"), (result1.Start, result1.End, result1.Ref, result1.Alt));
            for (var i = 0; i < expectedVarPosIndexes1.Count; i++)
            {
                Assert.Equal(expectedVarPosIndexes1[i], result1.VarPosIndexesInAlleleBlock[i]);
            }

            Assert.Equal((356, 360, "GAATC", "TATTG"), (result2.Start, result2.End, result2.Ref, result2.Alt));
            for (var i = 0; i < expectedVarPosIndexes2.Count; i++)
            {
                Assert.Equal(expectedVarPosIndexes2[i], result2.VarPosIndexesInAlleleBlock[i]);
            }
        }
        public void Length_ReturnTrueLength_WhenGapsArePresent()
        {
            const int expectedResults = 720;

            var        sequence       = new NSequence();
            var        codingRegion   = new CodingRegion(10051, 12770, 51, 800, 720);
            const byte startExonPhase = 1;

            var regions = new ITranscriptRegion[]
            {
                new TranscriptRegion(TranscriptRegionType.Exon, 1, 10001, 10299, 1, 299),
                new TranscriptRegion(TranscriptRegionType.Intron, 1, 10300, 12300, 229, 331),
                new TranscriptRegion(TranscriptRegionType.Exon, 2, 12301, 12970, 331, 1000)
            };

            var codingSequence  = new CodingSequence(sequence, codingRegion, regions, false, startExonPhase);
            var observedResults = codingSequence.Length;

            Assert.Equal(expectedResults, observedResults);
            Assert.NotEqual(expectedResults, codingRegion.End - codingRegion.Start + 1);
        }