Пример #1
0
        public void ShowsHelpText(string template)
        {
            // Arrange
            string msg;
            string expected =
                "\r\n\r\nUsage: MSPC CLI [options]\r\n\r\nOptions:" +
                "\r\n  -? | -h | --help                      Show help information" +
                "\r\n  -v | --version                        Show version information" +
                "\r\n  -i | --input <value>                  Input samples to be processed in Browser Extensible Data (BED) Format." +
                "\r\n  -f | --folder-input <value>           Sets a path to a folder that all its containing files in BED format are considered as inputs." +
                "\r\n  -r | --replicate <value>              Sets the replicate type of samples. Possible values are: { Bio, Biological, Tec, Technical }" +
                "\r\n  -w | --tauW <value>                   Sets weak threshold. All peaks with p-values higher than this value are considered as weak peaks." +
                "\r\n  -s | --tauS <value>                   Sets stringency threshold. All peaks with p-values lower than this value are considered as stringent peaks." +
                "\r\n  -g | --gamma <value>                  Sets combined stringency threshold. The peaks with their combined p-values satisfying this threshold will be confirmed." +
                "\r\n  -a | --alpha <value>                  Sets false discovery rate of Benjamini–Hochberg step-up procedure." +
                "\r\n  -c <value>                            Sets minimum number of overlapping peaks before combining p-values." +
                "\r\n  -m | --multipleIntersections <value>  When multiple peaks from a sample overlap with a given peak, this argument defines which of the peaks to be considered: the one with lowest p-value, or the one with highest p-value? Possible values are: { Lowest, Highest }" +
                "\r\n  -d | --degreeOfParallelism <value>    Set the degree of parallelism." +
                "\r\n  -p | --parser <value>                 Sets the path to the parser configuration file in JSON." +
                "\r\n  -o | --output <value>                 Sets a path where analysis results should be persisted." +
                "\r\n  --excludeHeader                       If provided, MSPC will not add a header line to its output." +
                "\r\n" +
                "\n\rDocumentation:\thttps://genometric.github.io/MSPC/" +
                "\n\rSource Code:\thttps://github.com/Genometric/MSPC" +
                "\n\rPublications:\thttps://genometric.github.io/MSPC/publications" +
                "\n\r\r\n";

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run(template: template);

            // Assert
            Assert.Contains(expected, msg);
            Assert.True(Environment.ExitCode == 0);
        }
Пример #2
0
        public void ReportRuntime()
        {
            // Arrange
            string msg;

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run();

            // Assert
            Assert.Contains("Elapsed time: ", msg);
        }
Пример #3
0
        public void ErrorIfLessThanTwoSamplesAreGiven()
        {
            // Arrange
            string msg;

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run(false, "-i rep1.bed -r bio -w 1E-2 -s 1E-8");

            // Assert
            Assert.Contains("at least two samples are required; 1 is given.", msg);
        }
Пример #4
0
        public void WarningDisplayedForInvalidC(string c, string expected)
        {
            // Arrange
            string msg;

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run(template: $"-i sample_1 -i sample_2 -r bio -w 1E-2 -s 1E-8 -c {c}");

            // Assert
            Assert.Contains($"Invalid `C={c}`, it is set to `C={expected}`.", msg);
        }
Пример #5
0
        public void ErrorIfASpecifiedFileIsMissing()
        {
            // Arrange
            string msg;

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run(false, "-i rep1.bed -i rep2.bed -r bio -w 1E-2 -s 1E-8");

            // Assert
            Assert.Contains("the following files are missing: rep1.bed; rep2.bed", msg);
        }
Пример #6
0
        public void DontReportSuccessfullyFinishedIfExitedAfterAnError()
        {
            // Arrange
            List <string> messages;

            // Act
            using (var tmpMspc = new TmpMspc())
                messages = tmpMspc.FailRun();

            // Assert
            Assert.DoesNotContain(messages, x => x.Contains("All processes successfully finished"));
        }
Пример #7
0
        public void ErrorIfARequiredArgumentIsMissing()
        {
            // Arrange
            string msg;

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run(false, "-i rep1.bed -i rep2.bed -w 1E-2 -s 1E-8");

            // Assert
            Assert.Contains("the following required arguments are missing: -r|--replicate.", msg);
        }
Пример #8
0
        public void SuccessfulAnalysis()
        {
            // Arrange
            string msg;

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run();

            // Assert
            Assert.Contains("All processes successfully finished", msg);
        }
Пример #9
0
        public void AssertInformingMaxPValue()
        {
            // Arrange
            string msg;

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run();

            // Assert
            Assert.Contains("1.000E-003", msg);
            Assert.Contains("1.000E-002", msg);
        }
Пример #10
0
        public void CaptureExporterExceptions()
        {
            // Arrange
            string message;

            // Act
            using (var tmpMspc = new TmpMspc())
                message = tmpMspc.Run(new MExporter());

            // Assert
            Assert.Contains("The method or operation is not implemented.", message);
            Assert.DoesNotContain("All processes successfully finished", message);
        }
Пример #11
0
        public void HintHowToUseHelpWhenAnExceptionOccurs()
        {
            // Arrange
            string msg;
            string expected = "You may run mspc with either of [-? | -h | --help] tags for help.";

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run(template: "");

            // Assert
            Assert.Contains(expected, msg);
        }
Пример #12
0
        public void ShowVersion(string template)
        {
            // Arrange
            string msg;
            string expected = "\r\nVersion ";

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run(template: template);

            // Assert
            Assert.Contains(expected, msg);
        }
Пример #13
0
        public void ReuseExistingLogger()
        {
            // Arrange
            List <string> messages;

            // Act
            using (var tmpMspc = new TmpMspc())
                messages = tmpMspc.FailRun();

            // Assert
            Assert.Contains(messages, x => x.Contains("the following files are missing: rep1; rep2"));
            Assert.Contains(messages, x => x.Contains("the following required arguments are missing: (-i|--input or -f|--folder-input)."));
        }
Пример #14
0
        public void AssertInformingPeaksCount()
        {
            // Arrange
            string msg;

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run();

            // Assert
            Assert.Contains("  2\t", msg);
            Assert.Contains("  3\t", msg);
        }
Пример #15
0
        public void RaiseExceptionWritingToIllegalPath()
        {
            // Arrange
            string msg;
            var    illegalPath = "C:\\*<>*\\//";

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run(sessionPath: illegalPath);

            // Assert
            Assert.True(
                msg.Contains("Illegal characters in path.") ||
                msg.Contains("The filename, directory name, or volume label syntax is incorrect"));
        }
Пример #16
0
        public void WriteOutputPathExceptionToLoggerIfAvailable()
        {
            // Arrange
            List <string> messages;

            // Act
            using (var tmpMspc = new TmpMspc())
                messages = tmpMspc.FailRun(template2: "-i rep1 -i rep2 -o C:\\*<>*\\// -r bio -s 1e-8 -w 1e-4");

            // Assert
            Assert.Contains(messages, x => x.Contains("the following files are missing: rep1; rep2"));
            Assert.Contains(
                messages,
                x => x.Contains("Illegal characters in path.") ||
                x.Contains("The filename, directory name, or volume label syntax is incorrect"));
        }
Пример #17
0
        public void ExportPathIsReportedInConsole()
        {
            // Arrange
            string msg;

            // Act
            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run();

            // Assert
            var rx = new Regex(".*Export Directory: (.*)\r\n.*");
            var loggedOutputPath = rx.Match(msg).Groups[1].Value.Trim();

            var isAValidPath = TryGetFullPath(loggedOutputPath, out _);

            Assert.True(isAValidPath);
        }
Пример #18
0
        public void ReadDataAccordingToParserConfig()
        {
            // Arrange
            ParserConfig cols = new ParserConfig()
            {
                Chr                    = 0,
                Left                   = 3,
                Right                  = 4,
                Name                   = 1,
                Strand                 = 2,
                Summit                 = 6,
                Value                  = 5,
                DefaultValue           = 1.23E-45,
                PValueFormat           = PValueFormats.minus1_Log10_pValue,
                DropPeakIfInvalidValue = false,
            };
            var path = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "MSPCTests_" + new Random().NextDouble().ToString();

            using (StreamWriter w = new StreamWriter(path))
                w.WriteLine(JsonConvert.SerializeObject(cols));

            string rep1Path = Path.GetTempPath() + Guid.NewGuid().ToString() + ".bed";
            string rep2Path = Path.GetTempPath() + Guid.NewGuid().ToString() + ".bed";

            FileStream stream = File.Create(rep1Path);

            using (StreamWriter writter = new StreamWriter(stream))
                writter.WriteLine("chr1\tMSPC_PEAK\t.\t10\t20\t16\t15");

            stream = File.Create(rep2Path);
            using (StreamWriter writter = new StreamWriter(stream))
                writter.WriteLine("chr1\tMSPC_PEAK\t.\t15\t25\tEEE\t20");

            // Act
            string msg;

            using (var tmpMspc = new TmpMspc())
                msg = tmpMspc.Run(createSample: false, template: string.Format("-i {0} -i {1} -p {2} -r bio -w 1e-2 -s 1e-4", rep1Path, rep2Path, path));

            // Assert
            Assert.Contains("1.000E-016", msg);
            Assert.Contains("1.230E-045", msg);
        }
Пример #19
0
        public void ThrowExceptionForInvalidCultureValue()
        {
            // Arrange
            var parserFilename =
                Environment.CurrentDirectory + Path.DirectorySeparatorChar +
                Guid.NewGuid().ToString() + ".json";

            // Create an json file with a `culture` field containing
            // invalid culture name.
            using (StreamWriter w = new StreamWriter(parserFilename))
                w.WriteLine("{\"Culture\":\"xyz\"}");

            // Act
            string msg;

            using (var tmpMSPC = new TmpMspc())
                msg = tmpMSPC.Run(parserFilename: parserFilename);

            // Assert
            Assert.Contains("Error setting value to 'Culture'", msg);
        }