Ejemplo n.º 1
0
        public void BiasingParametersLoadParametersFromNull()
        {
            // ReSharper disable UnusedVariable
            var parameters = BiasingParameters.LoadParametersFromJson(null);

            // ReSharper restore UnusedVariable
            Assert.Fail("LoadParametersFromJson(null) should throw an ArgumentNullException.");
        }
Ejemplo n.º 2
0
        public void BiasingParametersJsonFileBinCountNotCutoffSize()
        {
            const string inputFile = "resources\\biasing_sample_BIN_COUNT_not_CUTOFF_array_size.json";
            // ReSharper disable UnusedVariable
            var parameters = BiasingParameters.LoadParametersFromJson(inputFile);

            // ReSharper restore UnusedVariable
            Assert.Fail("BiasingParametersJsonFileBinCountNotCutoffSize() should throw a System.ArgumentException.");
        }
Ejemplo n.º 3
0
        public void BiasingParametersJsonFileIreCountNotRareEventInfoSize()
        {
            const string inputFile = "resources\\biasing_sample_IRE_COUNT_not_RARE_EVENT_INFO_array_size.json";
            // ReSharper disable UnusedVariable
            var parameters = BiasingParameters.LoadParametersFromJson(inputFile);

            // ReSharper restore UnusedVariable
            Assert.Fail("BiasingParametersJsonFileIreCountNotRareEventInfoSize() should throw a System.ArgumentException.");
        }
Ejemplo n.º 4
0
        public void BiasingParametersJsonFileReactionCountLessThanReactionArraySize()
        {
            const string inputFile = "resources\\biasing_sample_REACTION_COUNT_less_than_REACTION_array_size.json";
            // ReSharper disable UnusedVariable
            var parameters = BiasingParameters.LoadParametersFromJson(inputFile);

            // ReSharper restore UnusedVariable
            Assert.Fail("BiasingParametersJsonFileReactionCountLessThanReactionArraySize() should throw a System.ArgumentException.");
        }
Ejemplo n.º 5
0
        public void BiasingParametersJsonFileMissingIreCountParameter()
        {
            const string inputFile = "resources\\biasing_sample_IRE_COUNT_missing.json";
            // ReSharper disable UnusedVariable
            var parameters = BiasingParameters.LoadParametersFromJson(inputFile);

            // ReSharper restore UnusedVariable
            Assert.Fail("BiasingParametersJsonFileMissingIreCountParameter() should throw a System.ArgumentException.");
        }
Ejemplo n.º 6
0
        public void BiasingParametersLoadParametersFromInvalidJson()
        {
            const string jsonFilename = "resources\\invalid.json";
            // ReSharper disable UnusedVariable
            var parameters = BiasingParameters.LoadParametersFromJson(jsonFilename);

            // ReSharper restore UnusedVariable
            Assert.Fail("LoadParametersFromInvalidJson({0}) should throw an ArgumentException.", jsonFilename);
        }
Ejemplo n.º 7
0
        public void BiasingParametersLoadParametersFromMissingFile()
        {
            string tempFileName = Path.GetTempFileName();

            File.Delete(tempFileName);
            // ReSharper disable UnusedVariable
            var parameters = BiasingParameters.LoadParametersFromJson(tempFileName);

            // ReSharper restore UnusedVariable
            Assert.Fail("LoadParametersFromMissingFile(tempFileName) should throw an IO.FileNotFoundException.");
        }
Ejemplo n.º 8
0
        public void BiasingParametersLoadParametersFromJson()
        {
            const string filename   = "resources\\biasing_sample.json";
            var          parameters = BiasingParameters.LoadParametersFromJson(filename);

            // Verify rare event spec
            Assert.AreEqual("site_1", parameters.RareEvent.ExpressionLocale);
            Assert.AreEqual("reExpression", parameters.RareEvent.ExpressionName);
            Assert.AreEqual(2, parameters.RareEvent.IntermediateRareEventCount);
            Assert.AreEqual(24, parameters.RareEvent.Thresholds[0]);
            Assert.AreEqual(32, parameters.RareEvent.Thresholds[1]);

            // Verify locale[s]
            Assert.AreEqual(1, parameters.Locales.Count);
            var localeInfo = parameters.Locales[0];

            Assert.AreEqual("site_1", localeInfo.Name);
            Assert.AreEqual(8, localeInfo.ReactionCount);
            Assert.AreEqual(8, localeInfo.Reactions.Count);

            // Verify first reaction
            var reactionInfo = localeInfo.Reactions[0];

            Assert.AreEqual("R1", reactionInfo.Name);
            Assert.AreEqual(2, reactionInfo.RareEvents.Count);
            var rareEventInfo = reactionInfo.RareEvents[0];

            Assert.AreEqual(2, rareEventInfo.BinCount);
            Assert.AreEqual(2, rareEventInfo.Gammas.Length);
            Assert.AreEqual(1, rareEventInfo.Thresholds.Length);
            Assert.AreEqual(1.06863, rareEventInfo.Gammas[0]);
            Assert.AreEqual(1.56882, rareEventInfo.Gammas[1]);
            Assert.AreEqual(0.00031386, rareEventInfo.Thresholds[0]);

            // Verify last reaction
            reactionInfo = localeInfo.Reactions[localeInfo.ReactionCount - 1];
            Assert.AreEqual("R8", reactionInfo.Name);
            Assert.AreEqual(2, reactionInfo.RareEvents.Count);
            rareEventInfo = reactionInfo.RareEvents[1];
            Assert.AreEqual(7, rareEventInfo.BinCount);
            Assert.AreEqual(7, rareEventInfo.Gammas.Length);
            Assert.AreEqual(6, rareEventInfo.Thresholds.Length);
            Assert.AreEqual(2.37130, rareEventInfo.Gammas[0]);
            Assert.AreEqual(2.191004, rareEventInfo.Gammas[6]);
            Assert.AreEqual(0.3935499, rareEventInfo.Thresholds[5]);
        }
Ejemplo n.º 9
0
        public void BiasingParametersWriteParametersToJson()
        {
            const string inputFile  = "resources\\biasing_sample.json";
            var          parameters = BiasingParameters.LoadParametersFromJson(inputFile);
            string       outputFile = Path.GetTempFileName();
            bool         areSame    = false;

            try
            {
                Console.WriteLine("Writing biasing parameters to '{0}'...", outputFile);
                parameters.WriteParametersToJsonFile(outputFile);
                FileAssert.AreEqual(inputFile, outputFile);
                areSame = true;
            }
            finally
            {
                if (areSame)
                {
                    File.Delete(outputFile);
                }
            }
        }