/// <summary> /// Maps the distribution of an R-group to all possible substitute combinations. /// </summary> /// <remarks> /// This is best illustrated by an example. /// Say R2 occurs twice in the root, and has condition >0. So a valid /// output configuration can have either one or two substitutes. /// The distributions will have been calculated to be the following /// solutions: /// <para>[0,1], [1,0], [1,1]</para> /// To start with [1,1], assume two possible substitutes have been /// defined for R2, namely *C=O and *C-N. Then the distribution [1,1] /// should lead to four mappings: /// <para>[*C=O,*C=O], [*C-N,*C-N], [*C=O,*C-N], [*C-N,*C=O].</para> /// These mappings are generated in this function, as well as the other valid mappings /// for [0,1] and [1,0]: /// <para>[*C=O,null], [*C-N,null], [null,*C=O], [null,*C-N]. </para> /// So the example would have this function produce eight mappings (result list size==8). /// </remarks> /// <param name="rgpList"></param> /// <param name="listOffset"></param> /// <param name="distribution"></param> /// <param name="mapping"></param> /// <param name="result"></param> private void MapSubstitutes(RGroupList rgpList, int listOffset, int[] distribution, RGroup[] mapping, List <List <RGroup> > result) { if (listOffset == distribution.Length) { List <RGroup> mapped = new List <RGroup>(); foreach (var rgrp in mapping) { mapped.Add(rgrp); } result.Add(mapped); } else { if (distribution[listOffset] == 0) { mapping[listOffset] = null; MapSubstitutes(rgpList, listOffset + 1, distribution, mapping, result); } else { foreach (var rgrp in rgpList.RGroups) { mapping[listOffset] = rgrp; MapSubstitutes(rgpList, listOffset + 1, distribution, mapping, result); } } } }
public void TestOccurrenceNull() { RGroupList rgrLst = new RGroupList(1); rgrLst.Occurrence = null; Assert.AreEqual(rgrLst.Occurrence, RGroupList.DefaultOccurence); }
public void TestOccurrenceCorrect() { RGroupList rgrLst = new RGroupList(1); rgrLst.Occurrence = "1, 3-7, 9, >11"; Assert.AreEqual(rgrLst.Occurrence, "1,3-7,9,>11"); }
public void TestOccurrenceNotSmallerThanZero() { RGroupList rgrLst = new RGroupList(1); rgrLst.Occurrence = "<0"; }
public void TestOccurrenceNoNegativeNumber() { RGroupList rgrLst = new RGroupList(1); rgrLst.Occurrence = "-10"; }
public void TestOccurrenceNumericValues() { RGroupList rgrLst = new RGroupList(1); rgrLst.Occurrence = "a,3,10"; }