Exemplo n.º 1
0
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
                                ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            int[] catColInds = param.GetParam <int[]>("Categorical rows for renaming").Value;
            ParameterWithSubParams <int> parmInd = param.GetParamWithSubParams <int>("Rename type");
            int renameType = parmInd.Value;

            string[] newNames = new string[mdata.ColumnCount];
            Dictionary <string, int> repeatNames = new Dictionary <string, int>();
            bool change = false;

            for (int i = 0; i < mdata.ColumnCount; i++)
            {
                string newName = "";
                foreach (int catColInd in catColInds)
                {
                    if (mdata.GetCategoryRowEntryAt(catColInd, i)[0] != "NA")
                    {
                        change = true;
                    }
                    newName = newName + " " + mdata.GetCategoryRowEntryAt(catColInd, i)[0];
                }
                if (change)
                {
                    change      = false;
                    newNames[i] = newName;
                }
                else
                {
                    newNames[i] = mdata.ColumnNames[i];
                }
            }
            if (renameType == 0)
            {
                IsobaricLabeling(parmInd, mdata, newNames);
            }
            else if (renameType == 1)
            {
                for (int i = 0; i < mdata.ColumnCount; i++)
                {
                    if (newNames[i] != mdata.ColumnNames[i])
                    {
                        mdata.ColumnNames[i] = mdata.ColumnNames[i] + " " + newNames[i];
                    }
                }
            }
            else
            {
                CheckRepeat(newNames);
                for (int i = 0; i < mdata.ColumnCount; i++)
                {
                    mdata.ColumnNames[i] = newNames[i];
                }
            }
        }
Exemplo n.º 2
0
        public void IsobaricLabeling(ParameterWithSubParams <int> parmInd, IMatrixData mdata,
                                     string[] newNames)
        {
            int  expInd     = parmInd.GetSubParameters().GetParam <int>("Experiment row").Value;
            int  channelInd = parmInd.GetSubParameters().GetParam <int>("Channel row").Value;
            bool detect     = false;

            for (int i = 0; i < mdata.ColumnCount; i++)
            {
                string[] expCols  = mdata.GetCategoryRowEntryAt(expInd, i)[0].Split(' ');
                string[] mainCols = mdata.ColumnNames[i].Split(' ');
                if (mainCols.Length > expCols.Length)
                {
                    string[] checkExpName = new string[expCols.Length];
                    Array.Copy(mainCols, (mainCols.Length - expCols.Length), checkExpName, 0, expCols.Length);
                    if ((String.Join(" ", expCols) == String.Join(" ", checkExpName)) &&
                        (mainCols[mainCols.Length - expCols.Length - 1] == mdata.GetCategoryRowEntryAt(channelInd, i)[0]))
                    {
                        string mainString = "";
                        for (int j = 0; j < (mainCols.Length - expCols.Length - 1); j++)
                        {
                            mainString = mainString + " " + mainCols[j];
                        }
                        detect      = true;
                        newNames[i] = mainString.Trim() + " " + newNames[i];
                    }
                }
            }
            if (detect)
            {
                CheckRepeat(newNames);
                for (int i = 0; i < mdata.ColumnCount; i++)
                {
                    mdata.ColumnNames[i] = newNames[i];
                }
            }
            else
            {
                for (int i = 0; i < mdata.ColumnCount; i++)
                {
                    if (newNames[i] != mdata.ColumnNames[i])
                    {
                        mdata.ColumnNames[i] = mdata.ColumnNames[i] + " " + newNames[i];
                    }
                }
            }
        }
Exemplo n.º 3
0
        public string GetRowName(int ind, int nameColumnIndex, bool cutNames)
        {
            if (ind < 0)
            {
                return("");
            }
            if (nameColumnIndex < 0)
            {
                return("");
            }
            if (ind >= mdata.ColumnNames.Count)
            {
                return(mdata.NumericColumnNames[ind - mdata.ColumnNames.Count]);
            }
            if (nameColumnIndex == 0)
            {
                return(mdata.ColumnNames[ind]);
            }
            int indw = nameColumnIndex - 1;

            if (indw < mdata.CategoryRowCount)
            {
                if (ind >= 0 && ind < mdata.ColumnCount)
                {
                    string[] w = mdata.GetCategoryRowEntryAt(indw, ind);
                    if (cutNames)
                    {
                        return(w.Length > 0 ? w[0] : "");
                    }
                    return(StringUtils.Concat(";", w));
                }
            }
            int indi = indw - mdata.CategoryRowCount;

            if (indi < mdata.NumericRowCount && indi >= 0)
            {
                double[] q = mdata.NumericRows[indi];
                if (ind >= 0 && ind < q.Length)
                {
                    return("" + q[ind]);
                }
            }
            return("");
        }
        public static int[] GetIndicesOfCol(IMatrixData data, string categoryName, HashSet <string> values)
        {
            int        index  = GetIndexOfCol(data, categoryName);
            List <int> result = new List <int>();

            for (int i = 0; i < data.ColumnCount; i++)
            {
                string[] s = data.GetCategoryRowEntryAt(index, i);
                foreach (string s1 in s)
                {
                    if (values.Contains(s1))
                    {
                        result.Add(i);
                        break;
                    }
                }
            }
            return(result.ToArray());
        }
 public static int[] GetIndicesOfCol(IMatrixData data, string categoryName, HashSet<string> values)
 {
     int index = GetIndexOfCol(data, categoryName);
     List<int> result = new List<int>();
     for (int i = 0; i < data.ColumnCount; i++){
         string[] s = data.GetCategoryRowEntryAt(index, i);
         foreach (string s1 in s){
             if (values.Contains(s1)){
                 result.Add(i);
                 break;
             }
         }
     }
     return result.ToArray();
 }