Esempio n. 1
0
 private void UpdateKnownPriors()
 {
     if (!string.IsNullOrEmpty(_options.PriorsPath))
     {
         using (var reader = new AlleleReader(_options.PriorsPath))
         {
             _knownVariants = reader.GetVariantsByChromosome(true, true, new List <AlleleCategory> {
                 AlleleCategory.Insertion, AlleleCategory.Mnv
             }, doSkipCandidate: SkipPrior);
             if (_options.TrimMnvPriors)
             {
                 foreach (var knownVariantList in _knownVariants.Values)
                 {
                     foreach (var knownVariant in knownVariantList)
                     {
                         if (knownVariant.Type == AlleleCategory.Mnv)
                         {
                             knownVariant.ReferenceAllele = knownVariant.ReferenceAllele.Substring(1);
                             knownVariant.AlternateAllele = knownVariant.AlternateAllele.Substring(1);
                             knownVariant.ReferencePosition++;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
        public void GetVariantsByChromosome()
        {
            var vcfReader =
                new AlleleReader(Path.Combine(TestPaths.LocalTestDataDirectory, "VcfReader_Extensions.vcf"));

            //Simple case
            var output = vcfReader.GetVariantsByChromosome(true, true,
                                                           new List <AlleleCategory> {
                AlleleCategory.Insertion, AlleleCategory.Mnv
            });

            Assert.Equal(1, output.Count);
            Assert.True(output.ContainsKey("chr1"));
            var candidateAlleles = new List <CandidateAllele>();

            output.TryGetValue("chr1", out candidateAlleles);
            Assert.Equal(2, candidateAlleles.Count);
            Assert.Equal(AlleleCategory.Mnv, candidateAlleles[0].Type);
            Assert.Equal(AlleleCategory.Insertion, candidateAlleles[1].Type);

            //Custom rule
            var filteredVcfReader =
                new AlleleReader(Path.Combine(TestPaths.LocalTestDataDirectory, "VcfReader_Extensions.vcf"));
            var filteredOutput = filteredVcfReader.GetVariantsByChromosome(true, true,
                                                                           new List <AlleleCategory> {
                AlleleCategory.Insertion, AlleleCategory.Mnv
            }, candidate => candidate.ReferenceAllele.Length > 3);

            Assert.Equal(1, filteredOutput.Count);
            Assert.True(filteredOutput.ContainsKey("chr1"));
            var filteredCandidateAlleles = new List <CandidateAllele>();

            filteredOutput.TryGetValue("chr1", out filteredCandidateAlleles);
            Assert.Equal(1, filteredCandidateAlleles.Count);
            Assert.False(filteredCandidateAlleles.Any(c => c.ReferenceAllele.Length > 3));
        }