Example #1
0
 public void LogFolder()
 {
     var options = new ScyllaApplicationOptions();
     options.OutputDirectory = @"C:\Out";
     options.SetIODirectories("Scylla");
     Assert.Equal(@"C:\Out\ScyllaLogs", options.LogFolder);
 }
Example #2
0
        public void LogFolder()
        {
            var options = new ScyllaApplicationOptions();

            options.OutputDirectory = "VariantPhasingTestOut";
            options.SetIODirectories("Scylla");
            Assert.Equal(Path.Combine("VariantPhasingTestOut", "ScyllaLogs"), options.LogFolder);
        }
        public void VcfPath()
        {
            var options = new ScyllaApplicationOptions()
            {
                VcfPath = "testPath"
            };
            var factory = new Factory(options);

            Assert.Equal("testPath", factory.VcfPath);
        }
Example #4
0
        public void OpenLogTest()
        {
            var outDir  = Path.Combine(TestPaths.LocalScratchDirectory, "ScyllaTestsOutDir");
            var options = new ScyllaApplicationOptions();

            options.OutputDirectory = outDir;

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

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

            Logger.OpenLog(SafeLogDir, "DefaultLog.txt", true);
            Logger.CloseLog();
            Directory.Delete(outDir, true);
        }
Example #5
0
        public void OpenLogTest()
        {
            var outDir = Path.Combine(TestPaths.LocalScratchDirectory, "ScyllaProgramTestsOutDir");

            TestUtilities.TestHelper.RecreateDirectory(outDir);
            var options = new ScyllaApplicationOptions();

            options.OutputDirectory = outDir;

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

            //cleanup and redirect logging
            var SafeLogDir = Path.Combine(outDir, "logs");

            Logger.OpenLog(SafeLogDir, "DefaultLog.txt", true);
            Logger.CloseLog();
        }
Example #6
0
        public void TestInvalidArguments()
        {
            ScyllaApplicationOptions phasingOptions = new ScyllaApplicationOptions();

            Assert.Equal((int)ExitCodeType.MissingCommandLineOption, Program.Main(new string[] { }));
            Assert.Equal((int)ExitCodeType.MissingCommandLineOption, Program.Main(new string[] { "" }));
            Assert.Equal((int)ExitCodeType.MissingCommandLineOption, Program.Main(new string[] { "\t" }));
            Assert.Equal((int)ExitCodeType.MissingCommandLineOption, Program.Main(new string[] { " " }));
            Assert.Equal((int)ExitCodeType.UnknownCommandLineOption, Program.Main(new string[] { "-h", "-blah" }));
            Assert.Equal((int)ExitCodeType.UnknownCommandLineOption, Program.Main(new string[] { "-help", "-blah" }));

            var inBam   = Path.Combine(TestPaths.LocalTestDataDirectory, "chr21_11085587_S1.bam");
            var inVcf   = Path.Combine(TestPaths.LocalTestDataDirectory, "chr21_11085587_S1.genome.vcf");
            var outPath = Path.Combine(TestPaths.LocalScratchDirectory, "chr21_11085587_S1.phased.genome.vcf");


            string[] extraSetting = new string[] { "-out", outPath, "-bam", inBam, "-vcf", inVcf, "-extrathing", "blah" };

            Assert.Equal((int)ExitCodeType.UnknownCommandLineOption, Program.Main(extraSetting));
        }
 public ScyllaOptionsParser()
 {
     Options = new ScyllaApplicationOptions();
 }
Example #8
0
        private void ExecuteNeighborhoodThreadingTest(int numberOfThreads, int expectedNumberOfThreads)
        {
            var bamFilePath = Path.Combine(TestPaths.LocalTestDataDirectory, "MNV-25-var216_S216.bam");
            var vcfFilePath = Path.Combine(TestPaths.LocalTestDataDirectory, "MNV-25-var216_S216.vcf");
            var outFolder   = Path.Combine(TestPaths.LocalScratchDirectory, "Out");

            var options = new ScyllaApplicationOptions
            {
                BamPath         = bamFilePath,
                VcfPath         = vcfFilePath,
                OutputDirectory = outFolder
            };

            options.SetIODirectories("Scylla");

            var logFile = Path.Combine(options.LogFolder, options.LogFileNameBase);

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


            var factory = new MockFactoryWithDefaults(options);

            factory.MockVcfWriter = new Mock <IVcfFileWriter <CalledAllele> >();
            factory.MockVcfWriter.Setup(s => s.Write(It.IsAny <IEnumerable <CalledAllele> >(), It.IsAny <IRegionMapper>())).Callback(() =>
            {
                Thread.Sleep(500);
            });



            var neighborhoods = GetNeighborhoods(expectedNumberOfThreads);

            factory.MockNeighborhoodBuilder = new Mock <INeighborhoodBuilder>();
            factory.MockNeighborhoodBuilder.Setup(s => s.GetBatchOfNeighborhoods(0))
            .Returns(neighborhoods);

            factory.MockVeadSource = MockVeadSource();

            factory.MockVariantSource = new Mock <IVcfVariantSource>();
            factory.MockVariantSource.Setup(s => s.GetVariants()).Returns(new List <VcfVariant>()
            {
                new VcfVariant()
                {
                    ReferenceName     = "chr1",
                    ReferencePosition = 123,
                    VariantAlleles    = new[] { "A" },
                    GenotypeTagOrder  = new[] { "GT", "GQ", "AD", "VF", "NL", "SB", "NC" },
                    InfoTagOrder      = new[] { "DP" },
                    Genotypes         = new List <Dictionary <string, string> >()
                    {
                        new Dictionary <string, string>()
                        {
                            { "GT", "0/1" },
                            { "GQ", "100" },
                            { "AD", "6830,156" },
                            { "VF", "0.05" },
                            { "NL", "20" },
                            { "SB", "-20" },
                            { "NC", "0.01" }
                        }
                    },
                    InfoFields = new Dictionary <string, string>()
                    {
                        { "DP", "1000" }
                    },
                    ReferenceAllele = "C"
                },
                new VcfVariant()
                {
                    ReferenceName     = "chr2",
                    ReferencePosition = 123,
                    VariantAlleles    = new[] { "A" },
                    GenotypeTagOrder  = new[] { "GT", "GQ", "AD", "VF", "NL", "SB", "NC" },
                    InfoTagOrder      = new[] { "DP" },
                    Genotypes         = new List <Dictionary <string, string> >()
                    {
                        new Dictionary <string, string>()
                        {
                            { "GT", "0/1" },
                            { "GQ", "100" },
                            { "AD", "6830,156" },
                            { "VF", "0.05" },
                            { "NL", "20" },
                            { "SB", "-20" },
                            { "NC", "0.01" }
                        }
                    },
                    InfoFields = new Dictionary <string, string>()
                    {
                        { "DP", "1000" }
                    },
                    ReferenceAllele = "T"
                }
            });

            Logger.OpenLog(options.LogFolder, options.LogFileNameBase, true);
            var processor = new VariantPhaser(factory);

            processor.Execute(numberOfThreads);

            Logger.CloseLog();

            var threadsSpawnedBeforeFirstCompleted = 0;

            using (var reader = new StreamReader(new FileStream(logFile, FileMode.Open)))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    if (line.Contains("Completed processing"))
                    {
                        break;
                    }

                    if (line.Contains("Processing Neighborhood"))
                    {
                        threadsSpawnedBeforeFirstCompleted++;
                    }
                }
            }

            Assert.Equal(expectedNumberOfThreads, threadsSpawnedBeforeFirstCompleted);
        }
Example #9
0
 public MockFactoryWithDefaults(ScyllaApplicationOptions options) : base(options)
 {
 }
Example #10
0
        private void ExecuteNeighborhoodThreadingTest(int numberOfThreads, int expectedNumberOfThreads)
        {
            var bamFilePath = Path.Combine(TestPaths.LocalTestDataDirectory, "MNV-25-var216_S216.bam");
            var vcfFilePath = Path.Combine(TestPaths.LocalTestDataDirectory, "MNV-25-var216_S216.vcf");
            var outFolder   = Path.Combine(TestPaths.LocalScratchDirectory, "Out");

            var options = new ScyllaApplicationOptions
            {
                BamPath         = bamFilePath,
                VcfPath         = vcfFilePath,
                OutputDirectory = outFolder
            };

            options.SetIODirectories("Scylla");

            var logFile = Path.Combine(options.LogFolder, options.LogFileNameBase);

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


            var factory = new MockFactoryWithDefaults(options);

            factory.MockVcfWriter = new Mock <IVcfFileWriter <CalledAllele> >();
            factory.MockVcfWriter.Setup(s => s.Write(It.IsAny <IEnumerable <CalledAllele> >(), It.IsAny <IRegionMapper>())).Callback(() =>
            {
                Thread.Sleep(500);
            });



            var neighborhoods = GetNeighborhoods(expectedNumberOfThreads);

            factory.MockNeighborhoodBuilder = new Mock <INeighborhoodBuilder>();
            var numRaw = 0;

            factory.MockNeighborhoodBuilder.Setup(s => s.GetBatchOfCallableNeighborhoods(0, out numRaw))
            .Returns(neighborhoods);

            factory.MockVeadSource = MockVeadSource();

            factory.MockVariantSource = new Mock <IAlleleSource>();
            factory.MockVariantSource.Setup(s => s.GetVariants()).Returns(new List <CalledAllele>()
            {
                new CalledAllele()
                {
                    Chromosome        = "chr1",
                    ReferencePosition = 123,
                    AlternateAllele   = "A",
                    ReferenceAllele   = "C",
                    Genotype          = Pisces.Domain.Types.Genotype.HeterozygousAltRef,
                    TotalCoverage     = 10000
                },
                new CalledAllele()
                {
                    Chromosome        = "chr2",
                    ReferencePosition = 123,
                    AlternateAllele   = "A",
                    ReferenceAllele   = "T",
                    Genotype          = Pisces.Domain.Types.Genotype.HeterozygousAltRef,
                    TotalCoverage     = 10000
                }
            });

            Logger.OpenLog(options.LogFolder, options.LogFileNameBase, true);
            var processor = new VariantPhaser(factory);

            processor.Execute(numberOfThreads);

            Logger.CloseLog();

            var threadsSpawnedBeforeFirstCompleted = 0;

            using (var reader = new StreamReader(new FileStream(logFile, FileMode.Open)))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    if (line.Contains("Completed processing"))
                    {
                        break;
                    }

                    if (line.Contains("Processing Neighborhood"))
                    {
                        threadsSpawnedBeforeFirstCompleted++;
                    }
                }
            }

            Assert.Equal(expectedNumberOfThreads, threadsSpawnedBeforeFirstCompleted);
        }