Exemple #1
0
        public static void OGlycoTest_GetKPerWithDuplicate()
        {
            List <int> input = new List <int> {
                3, 5, 2, 7
            };

            int[] ids = new int[3] {
                2, 2, 3
            };
            var perWithDuplicate = GlycoPeptides.GetPermutations(input, ids);
            var allPermutation   = Glycan.GetPermutations(input, ids.Length);

            Assert.That(perWithDuplicate.Count() == allPermutation.Count() / 2);
        }
Exemple #2
0
        //The function here is to calculate permutation localization which could be used to compare with Graph-Localization.
        public static List <int[]> GetPermutations(List <int> allModPos, int[] glycanBoxId)
        {
            var length  = glycanBoxId.Length;
            var indexes = Enumerable.Range(0, length).ToArray();

            int[] orderGlycan = new int[length];

            List <int[]> permutateModPositions = new List <int[]>();

            var combinations = Glycan.GetKCombs(allModPos, length);

            foreach (var com in combinations)
            {
                var permutation = Glycan.GetPermutations(com, length);

                HashSet <string> keys = new HashSet <string>();

                foreach (var per in permutation)
                {
                    Array.Sort(indexes);

                    var orderedPer = per.ToArray();
                    Array.Sort(orderedPer, indexes);

                    for (int i = 0; i < length; i++)
                    {
                        orderGlycan[i] = glycanBoxId[indexes[i]];
                    }
                    var key = string.Join(",", orderGlycan.Select(p => p.ToString()));
                    if (!keys.Contains(key))
                    {
                        keys.Add(key);
                        permutateModPositions.Add(per.ToArray());
                    }
                }
            }

            return(permutateModPositions);
        }
Exemple #3
0
        public static void OGlycoTest_GetK()
        {
            List <int> input = new List <int> {
                1, 2, 3, 4, 5
            };

            //Combination test
            var kcombs = Glycan.GetKCombs(input, 3);

            Assert.AreEqual(kcombs.Count(), 10);

            var allcombs = Glycan.GetKCombs(input, 5);

            Assert.AreEqual(allcombs.Count(), 1);

            //Combination test with repetition
            var kcombs_rep = Glycan.GetKCombsWithRept(input, 3);

            Assert.AreEqual(kcombs_rep.Count(), 35);

            var allcombs_rep = Glycan.GetKCombsWithRept(input, 5);

            Assert.AreEqual(allcombs_rep.Count(), 126);

            //Permutation test
            var kperm = Glycan.GetPermutations(input, 3);

            Assert.AreEqual(kperm.Count(), 60);

            var allperm = Glycan.GetPermutations(input, 5).ToList();

            Assert.AreEqual(allperm.Count(), 120);

            //Permutation test with repetition
            var kperm_rep = Glycan.GetPermutationsWithRept(input, 3);

            Assert.AreEqual(kperm_rep.Count(), 125);
        }