public void TrimTaillingRefAlleles_RefIsTrimmed() { var blocks = new[] { new List <int> { 1, 2, 1, 0, 1, 0, 0 }, new List <int> { 0, 2, 1, 0, 1, 1, 0 } }; var expected = new[] { new List <int> { 1, 2, 1, 0, 1, 0 }, new List <int> { 0, 2, 1, 0, 1, 1 } }; AlleleIndexBlock.TrimTrailingRefAlleles(blocks); Assert.Equal(expected, blocks); }
public void GetPloidyFromGenotypes_DotIsIgnored() { string genotypes = ".;1|2;0/2"; var ploidy = AlleleIndexBlock.GetMaxPloidy(genotypes); Assert.Equal(2, ploidy); }
private static VariantInfo GetVariantInfo(PositionSet positionSet, AlleleIndexBlock alleleIndexBlock) { string filter = "PASS"; var positions = positionSet.SimplePositions; var startIndex = alleleIndexBlock.PositionIndex; var numPositions = alleleIndexBlock.AlleleIndexes.Count; var numSamples = positionSet.NumSamples; string[] quals = new string[numPositions]; for (int i = startIndex; i < startIndex + numPositions; i++) { quals[i - startIndex] = positions[i].VcfFields[VcfCommon.QualIndex]; string thisFilter = positions[i].VcfFields[VcfCommon.FilterIndex]; if (filter == "PASS" && thisFilter != "PASS" && thisFilter != ".") { filter = FailedFilterTag; } } string qual = GetStringWithMinValueOrDot(quals); string[] gqValues = new string[numSamples]; for (int i = 0; i < numSamples; i++) { gqValues[i] = GetStringWithMinValueOrDot(new ArraySegment <string>(positionSet.GqInfo[i], startIndex, numPositions).ToArray()); } string[] psValues = new string[numSamples]; for (int i = 0; i < numSamples; i++) { // PS tags are the same in the decomposed variants psValues[i] = positionSet.PsInfo[i][startIndex]; } return(new VariantInfo(qual, filter, gqValues, psValues)); }
public void GetPositionsAndRefAltAlleles_AsExpected() { var genotypes = new[] { "1|2", "1/1", "0|1", "0/1" }; var genotypeToSample = new Dictionary <(string, int), List <int> > { { (string.Join(";", genotypes), 0), new List <int> { 0 } } }; var indexOfUnsupportedVars = Enumerable.Repeat(new HashSet <string>(), 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" } }; var refSequence = "GAATCG"; var alleleIndexBlocksToSample = AlleleIndexBlock.GetAlleleIndexBlockToSampleIndex(genotypeToSample, indexOfUnsupportedVars, starts, functionBlockRanges).ToArray(); var alleleSet = new AlleleSet(null, starts, alleles); var alleleIndexBlocks = alleleIndexBlocksToSample.Select(x => x.Key).ToArray(); var decomposedPositionIndex = new HashSet <(int, int)>(); var result1 = VariantGenerator.GetPositionsAndRefAltAlleles(alleleIndexBlocks[0], alleleSet, refSequence, starts[0], decomposedPositionIndex); var result2 = VariantGenerator.GetPositionsAndRefAltAlleles(alleleIndexBlocks[1], alleleSet, refSequence, starts[0], decomposedPositionIndex); Assert.Equal((356, 360, "GAATC", "CATTC"), result1); Assert.Equal((356, 360, "GAATC", "TATTG"), result2); }
internal static (int Start, int End, string Ref, string Alt) GetPositionsAndRefAltAlleles(AlleleIndexBlock alleleIndexBlock, AlleleSet alleleSet, string totalRefSequence, int regionStart, HashSet <(int, int)> decomposedPosVarIndex)