public void WriteCountsFile()
        {
            VQROptions options = new VQROptions()
            {
                VcfPath                  = Path.Combine(TestPaths.LocalTestDataDirectory, "TestSignatureSorter.vcf"),
                OutputDirectory          = TestPaths.LocalScratchDirectory,
                LociCount                = -1,
                DoBasicChecks            = true,
                DoAmpliconPositionChecks = false
            };


            var expectedPath = Path.Combine(TestPaths.LocalTestDataDirectory, "Expected.counts");
            SignatureSorterResultFiles results = SignatureSorter.StrainVcf(options);
            string outFile = results.BasicCountsFilePath;

            Assert.True(File.Exists(outFile));

            var observedLines = File.ReadAllLines(outFile);
            var expectedLines = File.ReadAllLines(expectedPath);

            Assert.Equal(expectedLines.Length, observedLines.Length);

            for (int i = 0; i < expectedLines.Length; i++)
            {
                Assert.Equal(expectedLines[i], observedLines[i]);
            }

            File.Delete(outFile);
        }
示例#2
0
        public void TestOnADiploidVcf()
        {
            var vcfPath      = Path.Combine(TestPaths.LocalTestDataDirectory, "TestWithDiploidCalls.vcf");
            var countsPath   = Path.Combine(TestPaths.LocalTestDataDirectory, "Dirty.counts");
            var outDir       = Path.Combine(TestPaths.LocalScratchDirectory, "RecalibrateDiploidVcf");
            var outFile      = Path.Combine(outDir, "TestWithDiploidCalls.vcf.recal");
            var expectedFile = Path.Combine(TestPaths.LocalTestDataDirectory, "ExpectedDiploidCalls.vcf.recal");

            if (File.Exists(outFile))
            {
                File.Delete(outFile);
            }

            Logger.OpenLog(outDir, "RecalibrateDiploidCallsLog.txt", true);

            VQROptions options = new VQROptions
            {
                CommandLineArguments = new string[] { "-vcf", "TestWithDiploidCalls.vcf" },
                // FilterQScore = 30, <- set below
                ZFactor   = 0,
                MaxQScore = 66,
                // BaseQNoise = 30, <- set below
                VcfPath         = vcfPath,
                OutputDirectory = outDir,
            };

            options.BamFilterParams.MinimumBaseCallQuality          = 30; //-1
            options.VariantCallingParams.MinimumVariantQScoreFilter = 30;
            options.VariantCallingParams.PloidyModel = PloidyModel.DiploidByThresholding;
            options.VcfWritingParams.AllowMultipleVcfLinesPerLoci    = false;
            options.VariantCallingParams.AmpliconBiasFilterThreshold = null;

            SignatureSorterResultFiles resultFiles = new SignatureSorterResultFiles(countsPath, "foo.txt", "foo.txt");

            QualityRecalibration.Recalibrate(resultFiles, options);


            Logger.CloseLog();

            Assert.True(File.Exists(outFile));

            TestUtilities.TestHelper.CompareFiles(outFile, expectedFile);

            //redirect log incase any other thread is logging here.
            var SafeLogDir = TestPaths.LocalScratchDirectory;

            Logger.OpenLog(SafeLogDir, "DefaultLog.txt", true);
            Logger.CloseLog();

            //delete our log
            File.Delete(outFile);
        }
示例#3
0
        public void WriteEdgeCountsFile()
        {
            /*
             * chr10   7577500.C   G  //on edge (within 2 bases of chr10 amplicon end)
             * chr10   7577501.C   G  //on edge (within 2 bases of chr10 amplicon end)
             * chr17   7577537.C   G   100 PASS DP = 10  //on edge (within 2 bases of chr17 amplicon start)
             * chr17   7577538.C   G   100 PASS DP = 11  //on edge (within 2 bases of chr17 amplicon start)
             * chr17   7577540.G   A   100 PASS DP = 13   //NOT on edge
             * chr17   7577541.T   A   100 PASS DP = 100  //on edge (within 2 bases of edge of hat distribution)
             * chr17   7577542.G   T   100 PASS DP = 101   //on edge (within 2 bases of edge of hat distribution)
             * chr17   7577543.T   C   100 PASS DP = 100  //on edge (within 2 bases of edge of hat distribution)
             * chr17   7577544.T   C   100 PASS DP = 56   //on edge (within 2 bases of edge of hat distribution)
             * chr17   7577549.C.   100 PASS DP = 10  //NOT on edge
             * chr17   7577550.C.   100 PASS DP = 10  //NOT on edge
             * chr17   7577552.C   A   100 PASS DP = 15 //NOT on edge
             * chr17   7577553.T   C   100 PASS DP = 16 //on edge (within 2 bases of edge of hat distribution)
             * chr17   7577554.C.   100 PASS DP = 3700  //on edge (within 2 bases of edge of hat distribution), BUT its a referece call so we dont count it
             * chr17   7577555.C.   100 PASS DP = 0    //NOT on edge (DP=0)
             * chr17   7577556.C   A   100 PASS DP = 0  //NOT on edge (DP=0)
             * chr17   7577557.C   A   100 PASS DP = 0 //NOT on edge (DP=0)
             * chr17   7577558.C   A   100 PASS DP = 0   //NOT on edge (DP=0)
             * chr20   7577554.C   G   100 PASS DP = 3700 //on edge (within 2 bases of edge of hat distribution)
             * chr20   7577555.C.   100 PASS DP = 0    //NOT on edge (DP=0)
             */


            VQROptions options = new VQROptions()
            {
                VcfPath                  = Path.Combine(TestPaths.LocalTestDataDirectory, "FindEdges.vcf"),
                OutputDirectory          = Path.Combine(TestPaths.LocalScratchDirectory, "WriteEdgeCountsFile"),
                LociCount                = -1,
                DoBasicChecks            = false,
                DoAmpliconPositionChecks = true,
                ExtentofEdgeRegion       = 2
            };


            var expectedCountsFile = Path.Combine(TestPaths.LocalTestDataDirectory, "Expected.edgecounts");
            var expectedIssuesFile = Path.Combine(TestPaths.LocalTestDataDirectory, "Expected.edgevariants");

            TestUtilities.TestHelper.RecreateDirectory(options.OutputDirectory);

            SignatureSorterResultFiles results = SignatureSorter.StrainVcf(options);

            TestUtilities.TestHelper.CompareFiles(results.AmpliconEdgeCountsFilePath, expectedCountsFile);
            TestUtilities.TestHelper.CompareFiles(results.AmpliconEdgeSuspectListFilePath, expectedIssuesFile);

            TestUtilities.TestHelper.RecreateDirectory(options.OutputDirectory);
        }
示例#4
0
        public void OpenLogTest()
        {
            var outDir  = Path.Combine(TestPaths.LocalScratchDirectory, "VQRoutDir");
            var options = new VQROptions();

            options.OutputDirectory = outDir;
            options.LogFileName     = "LogText.txt";

            Logger.OpenLog(options.OutputDirectory, options.LogFileName, true);
            Logger.CloseLog();
            Assert.True(Directory.Exists(outDir));
            Assert.True(File.Exists(Path.Combine(options.OutputDirectory, options.LogFileName)));

            //cleanup and redirect logging
            var SafeLogDir = TestPaths.LocalScratchDirectory;

            Logger.OpenLog(SafeLogDir, "DefaultLog.txt", true);
            Logger.CloseLog();
            Directory.Delete(outDir, true);
        }
示例#5
0
        public void RecalibrateCleanVcf()
        {
            var vcfPath      = Path.Combine(TestPaths.LocalTestDataDirectory, "Test.vcf");
            var countsPath   = Path.Combine(TestPaths.LocalTestDataDirectory, "Clean.counts");
            var outDir       = Path.Combine(TestPaths.LocalScratchDirectory, "RecalibrateDirtyVcf");
            var outFile      = Path.Combine(outDir, "Test.vcf.recal");
            var expectedFile = Path.Combine(TestPaths.LocalTestDataDirectory, "ExpectedTest.vcf.recal");

            if (File.Exists(outFile))
            {
                File.Delete(outFile);
            }

            Logger.OpenLog(TestPaths.LocalScratchDirectory, "RecalibrateCleanVcfLog.txt", true);
            VQROptions options = new VQROptions
            {
                CommandLineArguments = null,
                //          FilterQScore = -1,
                ZFactor   = 0,
                MaxQScore = 66,
                //          BaseQNoise = 30,
                OutputDirectory = outDir
            };

            options.VariantCallingParams.MinimumVariantQScoreFilter = -1;
            options.BamFilterParams.MinimumBaseCallQuality          = 30;
            SignatureSorterResultFiles resultFiles = new SignatureSorterResultFiles(countsPath, "foo.txt", "foo.txt");

            QualityRecalibration.Recalibrate(resultFiles, options);

            Logger.CloseLog();

            //no recalibration should occur for a clean file.
            Assert.True(!File.Exists(outFile));

            //redirect log incase any other thread is logging here.
            var SafeLogDir = TestPaths.LocalScratchDirectory;

            Logger.OpenLog(SafeLogDir, "DefaultLog.txt", true);
            Logger.CloseLog();
        }
示例#6
0
        public void WriteEdgeCountsFileGivenLociCounts()
        {
            VQROptions options = new VQROptions()
            {
                VcfPath                  = Path.Combine(TestPaths.LocalTestDataDirectory, "FindEdges.vcf"),
                OutputDirectory          = Path.Combine(TestPaths.LocalScratchDirectory, "WriteEdgeCountsFileGivenLociCounts"),
                LociCount                = 1000,
                DoBasicChecks            = false,
                DoAmpliconPositionChecks = true,
                ExtentofEdgeRegion       = 2
            };


            var expectedPath = Path.Combine(TestPaths.LocalTestDataDirectory, "ExpectedGivenLociNum.edgecounts");

            TestUtilities.TestHelper.RecreateDirectory(options.OutputDirectory);


            SignatureSorterResultFiles results = SignatureSorter.StrainVcf(options);
            string outFile = results.AmpliconEdgeCountsFilePath;

            TestUtilities.TestHelper.CompareFiles(results.AmpliconEdgeCountsFilePath, expectedPath);
            TestUtilities.TestHelper.RecreateDirectory(options.OutputDirectory);
        }