コード例 #1
0
        public void MutatorTest1()
        {
            Organism organism = new Organism();

            organism.Chromosomes.Add(new Chromosome(1, "10"));

            MutationCounter mutator = new MutationCounter();

            mutator.Mutate(organism);
            mutator.Mutate(organism);
            mutator.Mutate(organism);
            mutator.Mutate(organism);

            Assert.AreEqual(4, mutator.MutationCount);
            Assert.AreEqual("10", organism.Chromosomes[0].ToString());
        }
コード例 #2
0
        public void GetMutationCategory()
        {
            var v = new VcfVariant();

            v.ReferenceAllele = "A";
            v.VariantAlleles  = new string[] { "C" };
            Assert.Equal(MutationCategory.AtoC, MutationCounter.GetMutationCategory(v));

            v.ReferenceAllele = "G";
            v.VariantAlleles  = new string[] { "T" };
            Assert.Equal(MutationCategory.GtoT, MutationCounter.GetMutationCategory(v));

            v.ReferenceAllele = "A";
            v.VariantAlleles  = new string[] { "c" };
            Assert.Equal(MutationCategory.AtoC, MutationCounter.GetMutationCategory(v));

            v.ReferenceAllele = "g";
            v.VariantAlleles  = new string[] { "t" };
            Assert.Equal(MutationCategory.GtoT, MutationCounter.GetMutationCategory(v));


            v.ReferenceAllele = "G";
            v.VariantAlleles  = new string[] { "t" };
            Assert.Equal(MutationCategory.GtoT, MutationCounter.GetMutationCategory(v));

            v.ReferenceAllele = "G";
            v.VariantAlleles  = new string[] { "TT" };
            Assert.Equal(MutationCategory.Insertion, MutationCounter.GetMutationCategory(v));

            v.ReferenceAllele = "GGG";
            v.VariantAlleles  = new string[] { "T" };
            Assert.Equal(MutationCategory.Deletion, MutationCounter.GetMutationCategory(v));

            v.ReferenceAllele = "GG";
            v.VariantAlleles  = new string[] { "TZ" };
            Assert.Equal(MutationCategory.Other, MutationCounter.GetMutationCategory(v));

            v.ReferenceAllele = "G";
            v.VariantAlleles  = new string[] { "G" };
            Assert.Equal(MutationCategory.Reference, MutationCounter.GetMutationCategory(v));

            v.ReferenceAllele = "G";
            v.VariantAlleles  = new string[] { "." };
            Assert.Equal(MutationCategory.Reference, MutationCounter.GetMutationCategory(v));
        }
コード例 #3
0
        public void GetMutationCategory_VariantInput()
        {
            var v = MakeDummyAllele("A", "C");

            Assert.Equal(MutationCategory.AtoC, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("G", "T");
            Assert.Equal(MutationCategory.GtoT, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("A", "c");
            Assert.Equal(MutationCategory.AtoC, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("G", "t");
            Assert.Equal(MutationCategory.GtoT, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("G", "t");
            Assert.Equal(MutationCategory.GtoT, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("G", "TT");
            Assert.Equal(MutationCategory.Insertion, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("GGG", "T");
            Assert.Equal(MutationCategory.Deletion, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("GG", "TZ");
            Assert.Equal(MutationCategory.Other, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("G", "G");
            Assert.Equal(MutationCategory.Reference, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("G", "g");
            Assert.Equal(MutationCategory.Reference, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("g", "G");
            Assert.Equal(MutationCategory.Reference, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("g", "g");
            Assert.Equal(MutationCategory.Reference, MutationCounter.GetMutationCategory(v));

            v = MakeDummyAllele("G", ".");
            Assert.Equal(MutationCategory.Reference, MutationCategoryUtil.GetMutationCategory(v));
        }
コード例 #4
0
        public void MutatorTest4()
        {
            Organism organism = new Organism();

            organism.Chromosomes.Add(new Chromosome(1, "10"));

            int    runCount            = 100000;
            double mutationProbability = 0;

            MutationCounter mutator         = new MutationCounter();
            IRandom         rand            = new Rand();
            Mutator         mutationManager = new Mutator(rand, mutationProbability);

            mutationManager.AddMutator(mutator);
            for (int i = 0; i <= runCount - 1; i++)
            {
                mutationManager.Mutate(organism);
            }

            Assert.AreEqual(0, mutator.MutationCount);
            Assert.AreEqual("10", organism.Chromosomes[0].ToString());
        }
コード例 #5
0
        public void MutatorTest4()
        {
            Organism organism = new Organism();
            organism.Chromosomes.Add(new Chromosome(1, "10"));

            int runCount = 100000;
            double mutationProbability = 0;

            MutationCounter mutator = new MutationCounter();
            IRandom rand = new Rand();
            Mutator mutationManager = new Mutator(rand, mutationProbability);
            mutationManager.AddMutator(mutator);
            for (int i = 0; i <= runCount - 1; i++) {
                mutationManager.Mutate(organism);
            }

            Assert.AreEqual(0, mutator.MutationCount);
            Assert.AreEqual("10", organism.Chromosomes[0].ToString());
        }
コード例 #6
0
        public void MutatorTest1()
        {
            Organism organism = new Organism();
            organism.Chromosomes.Add(new Chromosome(1, "10"));

            MutationCounter mutator = new MutationCounter();
            mutator.Mutate(organism);
            mutator.Mutate(organism);
            mutator.Mutate(organism);
            mutator.Mutate(organism);

            Assert.AreEqual(4, mutator.MutationCount);
            Assert.AreEqual("10", organism.Chromosomes[0].ToString());
        }