public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ref IDocumentData[] documents, ProcessInfo processInfo) { if (param.GetParam <int>("Filter mode").Value == 2) { supplTables = new[] { PerseusPluginUtils.CreateSupplTab(mdata) }; } int nrows = param.GetParam <int>("Number of rows").Value; nrows = Math.Min(nrows, mdata.RowCount); Random2 rand = new Random2(7); int[] rows = ArrayUtils.SubArray(rand.NextPermutation(mdata.RowCount), nrows); PerseusPluginUtils.FilterRowsNew(mdata, param, rows); }
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ref IDocumentData[] documents, ProcessInfo processInfo) { if (param.GetParam <int>("Filter mode").Value == 2) { supplTables = new[] { PerseusPluginUtils.CreateSupplTab(mdata) }; } int colInd = param.GetParam <int>("Column").Value; string searchString = param.GetParam <string>("Search string").Value; bool remove = param.GetParam <int>("Mode").Value == 0; bool matchCase = param.GetParam <bool>("Match case").Value; bool matchWholeWord = param.GetParam <bool>("Match whole word").Value; if (!matchWholeWord && string.IsNullOrEmpty(searchString)) { processInfo.ErrString = "Please provide a search string, or set 'Match whole word' to match empty entries."; return; } string[] vals = mdata.StringColumns[colInd]; List <int> valids = new List <int>(); List <int> notvalids = new List <int>(); for (int i = 0; i < vals.Length; i++) { bool matches = Matches(vals[i], searchString, matchCase, matchWholeWord); if (matches && !remove) { valids.Add(i); } else if (!matches && remove) { valids.Add(i); } else { notvalids.Add(i); } } if (param.GetParam <int>("Filter mode").Value == 2) { supplTables = new[] { PerseusPluginUtils.CreateSupplTabSplit(mdata, notvalids.ToArray()) }; } PerseusPluginUtils.FilterRowsNew(mdata, param, valids.ToArray()); }