//The function here is to build GlycanBoxes used for LocalizationGraph. //In LocalizationGraph matrix, for each AdjNode, it represent a ChildOGlycanBox here at certain glycosite. public static IEnumerable <GlycanBox> BuildChildOGlycanBoxes(int maxNum, int[] glycanIds, bool targetDecoy = true) { yield return(new GlycanBox(new int[0], targetDecoy)); HashSet <string> seen = new HashSet <string>(); for (int i = 1; i <= maxNum; i++) { foreach (var idCombine in Glycan.GetKCombs(Enumerable.Range(0, maxNum), i)) { List <int> ids = new List <int>(); foreach (var id in idCombine) { ids.Add(glycanIds[id]); } if (!seen.Contains(string.Join(",", ids.Select(p => p.ToString())))) { seen.Add(string.Join(",", ids.Select(p => p.ToString()))); GlycanBox glycanBox = new GlycanBox(ids.ToArray(), targetDecoy); yield return(glycanBox); } } } }
public static IEnumerable <GlycanBox> BuildOGlycanBoxes(int maxNum, bool buildDecoy) { for (int i = 1; i <= maxNum; i++) { foreach (var idCombine in Glycan.GetKCombsWithRept(Enumerable.Range(0, GlobalOGlycans.Length), i)) { GlycanBox glycanBox = new GlycanBox(idCombine.ToArray()); glycanBox.TargetDecoy = true; glycanBox.ChildGlycanBoxes = BuildChildOGlycanBoxes(glycanBox.NumberOfMods, glycanBox.ModIds, glycanBox.TargetDecoy).ToArray(); yield return(glycanBox); if (buildDecoy) { GlycanBox glycanBox_decoy = new GlycanBox(idCombine.ToArray()); glycanBox_decoy.TargetDecoy = false; glycanBox_decoy.ChildGlycanBoxes = BuildChildOGlycanBoxes(glycanBox_decoy.NumberOfMods, glycanBox_decoy.ModIds, glycanBox_decoy.TargetDecoy).ToArray(); yield return(glycanBox_decoy); } } } }