public void BasicIntervalTesting()
        {
            var bamFilePath = Path.Combine(UnitTestPaths.TestDataDirectory, "var123var35.bam");
            var vcfFilePath = Path.Combine(UnitTestPaths.TestDataDirectory, "var123var35.vcf");

            var functionalTestRunner = new SomaticVariantCallerFunctionalTestSetup();

            functionalTestRunner.GenomeDirectory = Path.Combine(UnitTestPaths.TestGenomesDirectory, "chr17chr19");

            var expectedAlleles = new List <BaseCalledAllele>
            {
                new CalledVariant(AlleleCategory.Snv)
                {
                    Coordinate = 3118942,
                    Reference  = "A",
                    Alternate  = "T",
                    Chromosome = "chr19"
                },
                new CalledVariant(AlleleCategory.Snv)
                {
                    Coordinate = 7572985,
                    Reference  = "T",
                    Alternate  = "C",
                    Chromosome = "chr17"
                }
            };

            // thread by chr
            functionalTestRunner.Execute(bamFilePath, vcfFilePath, null, expectedAlleles, threadByChr: true);
        }
        public void SomaticVariantCaller_SimpleSnv()
        {
            var functionalTestRunner = new SomaticVariantCallerFunctionalTestSetup();

            functionalTestRunner.GenomeDirectory = Path.Combine(UnitTestPaths.TestGenomesDirectory, "chr17chr19");

            var expectedAlleles = new List <BaseCalledAllele>
            {
                new CalledVariant(AlleleCategory.Snv)
                {
                    Coordinate = 3118942,
                    Reference  = "A",
                    Alternate  = "T",
                    Chromosome = "chr19"
                }
            };

            var vcfFilePath = Path.ChangeExtension(_bam_SIM_DID_35_S1, "vcf");

            // without reference calls
            File.Delete(vcfFilePath);
            functionalTestRunner.Execute(_bam_SIM_DID_35_S1, vcfFilePath, null, expectedAlleles);

            // with reference calls
            File.Delete(vcfFilePath);
            functionalTestRunner.Execute(_bam_SIM_DID_35_S1, vcfFilePath, null, expectedAlleles, null, true, true, 102);

            // with reference calls and intervals
            File.Delete(vcfFilePath);
            functionalTestRunner.Execute(_bam_SIM_DID_35_S1, vcfFilePath, _interval_SIM_DID_35_S1, expectedAlleles, null, true, true, 11);
        }
        public void BasicSNVIntervalTesting()
        {
            var bamFilePath          = Path.Combine(UnitTestPaths.TestDataDirectory, "var123var35.bam");
            var vcfFilePath          = Path.Combine(UnitTestPaths.TestDataDirectory, "var123var35.vcf");
            var intervalFilePath     = Path.Combine(UnitTestPaths.TestDataDirectory, "chr17only.picard");
            var functionalTestRunner = new SomaticVariantCallerFunctionalTestSetup();

            functionalTestRunner.GenomeDirectory = Path.Combine(UnitTestPaths.TestGenomesDirectory, "chr17chr19");

            var expectedAlleles = new List <BaseCalledAllele>
            {
                new CalledVariant(AlleleCategory.Snv)
                {
                    Coordinate = 3118942,
                    Reference  = "A",
                    Alternate  = "T",
                    Chromosome = "chr19"
                },
                new CalledVariant(AlleleCategory.Snv)
                {
                    Coordinate = 7572985,
                    Reference  = "T",
                    Alternate  = "C",
                    Chromosome = "chr17"
                }
            };

            // Spot an expected allele inside an interval.
            functionalTestRunner.Execute(bamFilePath, vcfFilePath, intervalFilePath, expectedAlleles.Where(a => a.Chromosome == "chr17").ToList());

            // Ignore indels spotted outside or overlapping the interval.
            functionalTestRunner.Execute(bamFilePath, vcfFilePath, intervalFilePath, expectedAlleles.Where(a => a.Chromosome == "chr17").ToList());
        }
        public void BasicMnvTesting()
        {
            var functionalTestRunner = new SomaticVariantCallerFunctionalTestSetup();

            functionalTestRunner.GenomeDirectory = Path.Combine(UnitTestPaths.TestGenomesDirectory, "chr17chr19");

            // Mock ChrReference for the MockGenome.
            List <ChrReference> mockChrRef = new List <ChrReference>()
            {
                new ChrReference()
                {
                    Name     = "chr1",
                    Sequence = "TTGTCAGTGCGCTTTTCCCAACACCACCTGCTCCGACCACCACCAGTTTGTACTCAGTCATTTCACACCAGCAAGAACCTGTTGGAAACCAGTAATCAGGGTTAATTGGCGGCG"
                }
            };

            var expectedAlleles = new List <BaseCalledAllele>
            {
                new CalledVariant(AlleleCategory.Mnv)
                {
                    Coordinate = 27,
                    Reference  = "CCTGCTCCG",
                    Alternate  = "TTTGCTCCA",
                    Chromosome = "chr1"
                },
                new CalledVariant(AlleleCategory.Mnv)
                {
                    Coordinate = 27,
                    Reference  = "CC",
                    Alternate  = "TT",
                    Chromosome = "chr1"
                },
                new CalledVariant(AlleleCategory.Snv)
                {
                    Coordinate = 35,
                    Reference  = "G",
                    Alternate  = "A",
                    Chromosome = "chr1"
                }
            };

            // Testing small_S1.bam with a MockGenome.
            functionalTestRunner.Execute(_bamSmallS1, Path.ChangeExtension(_bamSmallS1, "vcf"), null, expectedAlleles, mockChrRef, doCheckReferences: true, doLog: true);
        }
        public void InsertionAtEdgeOfDistribution()
        {
            // This test was brought forward to test Deletion at the edge from the previous tests. The test was listed as failing when stitching was included.
            // Notes from Old SVC: Make sure we can accurately insertions at the edge of the coverage distribution, and not accidentally mark them as SB
            // This test case was in response to a bug, where originally we called SB here when we should not.
            // chr7    116376907       .       ATTT    A       100.00  SB      DP=750;
            var bamFilePath          = Path.Combine(UnitTestPaths.TestDataDirectory, "edgeIns_S2.bam");
            var functionalTestRunner = new SomaticVariantCallerFunctionalTestSetup();

            functionalTestRunner.GenomeDirectory = Path.Combine(UnitTestPaths.TestGenomesDirectory, "chr17chr19");

            var appOptions = new ApplicationOptions
            {
                BAMPaths           = new[] { bamFilePath },
                IntervalPaths      = null,
                GenomePaths        = new[] { Path.Combine(UnitTestPaths.TestGenomesDirectory, "chr17chr19") },
                OutputgVCFFiles    = true,
                OutputBiasFiles    = true,
                DebugMode          = true,
                CallMNVs           = true,
                UseMNVReallocation = false,
                MaxSizeMNV         = 100,
                FilterOutVariantsPresentOnlyOneStrand = false,
                AppliedNoiseLevel                  = -1,
                MinimumBaseCallQuality             = 20,
                MaximumVariantQScore               = 100,
                FilteredVariantQScore              = 30,
                MinimumVariantQScore               = 20,
                MaxGapBetweenMNV                   = 10,
                MinimumCoverage                    = 10,
                MinimumMapQuality                  = 1,
                MinimumFrequency                   = 0.01f,
                StrandBiasAcceptanceCriteria       = 0.5f,
                StrandBiasScoreMaximumToWriteToVCF = -100,
                StrandBiasScoreMinimumToWriteToVCF = 0,
                OnlyUseProperPairs                 = false,
                NoiseModelHalfWindow               = 1,
                DoBamQC              = BamQCOptions.VarCallOnly,
                NoiseModel           = NoiseModel.Flat,
                GTModel              = GenotypeModel.Symmetrical,
                StrandBiasModel      = StrandBiasModel.Extended,
                RequireXCTagToStitch = true,
                StitchReads          = false
            };

            // Time to build the fake sequences for testing.
            var mockChrRef = new List <ChrReference>()
            {
                new ChrReference()
                {
                    // position 63
                    Name     = "chr7",
                    Sequence = "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN" +
                               "GTTGGTCTTCTATTTTATGCGAATTCTTCTAAGATTCCCAGGTTATTTATCATAAGAATTACATTTACATGGCAAATTTAGTTCTGTTCCTAGAAATATCTCCATGACAACCAAAAGGAACTCCTAATTTCTGGCACACATTACTTCAGGGGT"
                }
            };

            var expectedAlleles = new List <BaseCalledAllele>
            {
                new CalledVariant(AlleleCategory.Insertion)
                {
                    Coordinate = 110,
                    Reference  = "T",
                    Alternate  = "TGGG",
                    Chromosome = "chr7"
                }
            };

            functionalTestRunner.Execute(bamFilePath, Path.ChangeExtension(bamFilePath, "genome.vcf"), null, expectedAlleles, mockChrRef, applicationOptions: appOptions);
        }