private static string ProcessDataReadFromFile(IDataWithAnnotationRows mdata, Parameters param)
        {
            Parameter <string> fp       = param.GetParam <string>("Input file");
            string             filename = fp.Value;

            string[] colNames;
            try {
                colNames = TabSep.GetColumnNames(filename, '\t');
            } catch (Exception) {
                return("Could not open file " + filename + ". It maybe open in another program.");
            }
            int nameIndex = GetNameIndex(colNames);

            if (nameIndex < 0)
            {
                return("Error: the file has to contain a column called 'Name'.");
            }
            if (colNames.Length < 2)
            {
                return("Error: the file does not contain a numerical column.");
            }
            string[] nameCol             = TabSep.GetColumn(colNames[nameIndex], filename, '\t');
            Dictionary <string, int> map = ArrayUtils.InverseMap(nameCol);

            for (int i = 0; i < colNames.Length; i++)
            {
                if (i == nameIndex)
                {
                    continue;
                }
                string   groupName = colNames[i];
                string[] groupCol  = TabSep.GetColumn(groupName, filename, '\t');
                double[] newCol    = new double[mdata.ColumnCount];
                for (int j = 0; j < newCol.Length; j++)
                {
                    string colName = mdata.ColumnNames[j];
                    if (!map.ContainsKey(colName))
                    {
                        newCol[j] = double.NaN;
                        continue;
                    }
                    int    ind   = map[colName];
                    string group = groupCol[ind] ?? "";
                    group = group.Trim();
                    if (string.IsNullOrEmpty(group))
                    {
                        newCol[j] = double.NaN;
                    }
                    else
                    {
                        if (!Parser.TryDouble(group, out newCol[j]))
                        {
                            newCol[j] = double.NaN;
                        }
                    }
                }
                mdata.AddNumericRow(groupName, groupName, newCol);
            }
            return(null);
        }
        private static string ProcessDataReadFromFile(IDataWithAnnotationRows mdata, Parameters param)
        {
            Parameter <string> fp       = param.GetParam <string>("Input file");
            string             filename = fp.Value;

            string[] colNames;
            try
            {
                colNames = TabSep.GetColumnNames(filename, '\t');
            }
            catch (Exception)
            {
                return("Could not open file " + filename + ". It maybe open in another program.");
            }
            int nameIndex = GetNameIndex(colNames);

            if (nameIndex < 0)
            {
                return("Error: the file has to contain a column called 'Name'.");
            }
            if (colNames.Length < 2)
            {
                return("Error: the file does not contain a grouping column.");
            }
            string[] nameCol = TabSep.GetColumn(colNames[nameIndex], filename, '\t');
            for (int i = 0; i < nameCol.Length; i++)
            {
                MessageBox.Show(nameCol[i].ToString());
            }
            return(null);
        }
        private static string ProcessDataReadFromFileList(IMatrixData mdata, Parameters param)
        {
            Parameter <string> fp       = param.GetParam <string>("Input file");
            string             filename = fp.Value;

            string[] colNames;
            try
            {
                colNames = TabSep.GetColumnNames(filename, '\t');
            }
            catch (Exception)
            {
                return("Could not open file " + filename + ". It maybe open in another program.");
            }
            int nameIndex = GetNameIndex(colNames);

            string[] nameCol = TabSep.GetColumn(colNames[nameIndex], filename, '\t');
            MessageBox.Show(nameCol.Length.ToString());
            MessageBox.Show(mdata.ColumnCount.ToString());
            for (int i = 0; i < mdata.ColumnCount; i++)
            {
                MessageBox.Show(nameCol.Length.ToString());
                MessageBox.Show(mdata.ColumnCount.ToString());

                /*    if (nameCol.Length != mdata.ColumnCount)
                *       {
                *           return "ERROR";
                *       }
                *       else { mdata.ColumnNames[i] = nameCol[i]; } */
            }

            return(null);
        }
        private static string ProcessDataReadFromFile(IMatrixData mdata, Parameters param)
        {
            Parameter <string> fp       = param.GetParam <string>("Input file");
            string             filename = fp.Value;

            string[] colNames  = TabSep.GetColumnNames(filename, '\t');
            int      nameIndex = GetNameIndex(colNames);

            if (nameIndex < 0)
            {
                return("Error: the file has to contain a column called 'Name'.");
            }
            if (colNames.Length < 2)
            {
                return("Error: the file does not contain a grouping column.");
            }
            string[] nameCol             = TabSep.GetColumn(colNames[nameIndex], filename, '\t');
            Dictionary <string, int> map = ArrayUtils.InverseMap(nameCol);

            for (int i = 0; i < colNames.Length; i++)
            {
                if (i == nameIndex)
                {
                    continue;
                }
                string     groupName = colNames[i];
                string[]   groupCol  = TabSep.GetColumn(groupName, filename, '\t');
                string[][] newCol    = new string[mdata.ColumnCount][];
                for (int j = 0; j < newCol.Length; j++)
                {
                    string colName = mdata.ColumnNames[j];
                    if (!map.ContainsKey(colName))
                    {
                        newCol[j] = new string[0];
                        continue;
                    }
                    int    ind   = map[colName];
                    string group = groupCol[ind] ?? "";
                    group = group.Trim();
                    if (string.IsNullOrEmpty(group))
                    {
                        newCol[j] = new string[0];
                    }
                    else
                    {
                        string[] w = group.Split(';');
                        Array.Sort(w);
                        for (int k = 0; k < w.Length; k++)
                        {
                            w[k] = w[k].Trim();
                        }
                        newCol[j] = w;
                    }
                }
                mdata.AddCategoryRow(groupName, groupName, newCol);
            }
            return(null);
        }
 public static void ParseKinaseSubstrate(string filename, out string[] seqWins, out string[] subAccs,
                                         out string[] kinases, out string[] kinAccs, out string[] species)
 {
     seqWins = TabSep.GetColumn("SITE_+/-7_AA", filename, 3, '\t');
     subAccs = TabSep.GetColumn("SUB_ACC_ID", filename, 3, '\t');
     kinases = TabSep.GetColumn("KINASE", filename, 3, '\t');
     kinAccs = TabSep.GetColumn("KIN_ACC_ID", filename, 3, '\t');
     species = TabSep.GetColumn("KIN_ORGANISM", filename, 3, '\t');
 }
 public static void ParseKnownMods(string filename, out string[] seqWins, out string[] accs, out string[] pubmedLtp,
                                   out string[] pubmedMs2, out string[] cstMs2, out string[] species)
 {
     seqWins   = TabSep.GetColumn("SITE_+/-7_AA", filename, 3, '\t');
     accs      = TabSep.GetColumn("ACC_ID", filename, 3, '\t');
     pubmedLtp = TabSep.GetColumn("LT_LIT", filename, 3, '\t');
     pubmedMs2 = TabSep.GetColumn("MS_LIT", filename, 3, '\t');
     cstMs2    = TabSep.GetColumn("MS_CST", filename, 3, '\t');
     species   = TabSep.GetColumn("ORGANISM", filename, 3, '\t');
 }
        public static string[] GetAllKinaseSubstrateOrganisms()
        {
            string filename = GetKinaseSubstrateFile();

            if (filename == null)
            {
                return(null);
            }
            string[] species = TabSep.GetColumn("KIN_ORGANISM", filename, 3, '\t');
            return(ArrayUtils.UniqueValues(species));
        }
 public static void ParseRegulatorySites(string filename, out string[] seqWins, out string[] accs,
                                         out string[] function, out string[] process, out string[] protInteract, out string[] otherInteract,
                                         out string[] notes, out string[] species)
 {
     seqWins       = TabSep.GetColumn("SITE_+/-7_AA", filename, 3, '\t');
     accs          = TabSep.GetColumn("ACC_ID", filename, 3, '\t');
     function      = TabSep.GetColumn("ON_FUNCTION", filename, 3, '\t');
     process       = TabSep.GetColumn("ON_PROCESS", filename, 3, '\t');
     protInteract  = TabSep.GetColumn("ON_PROT_INTERACT", filename, 3, '\t');
     otherInteract = TabSep.GetColumn("ON_OTHER_INTERACT", filename, 3, '\t');
     notes         = TabSep.GetColumn("NOTES", filename, 3, '\t');
     species       = TabSep.GetColumn("ORGANISM", filename, 3, '\t');
 }
Exemple #9
0
        private static string ProcessDataReadFromFileList(IMatrixData mdata, Parameters param)
        {
            Parameter <string> fp       = param.GetParam <string>("Input file");
            string             filename = fp.Value;

            string[] colNames;
            try{
                colNames = TabSep.GetColumnNames(filename, '\t');
            } catch (Exception) {
                return("Could not open file " + filename + ". It maybe open in another program.");
            }
            int nameIndex = GetNameIndex(colNames);

            string[] nameCol = TabSep.GetColumn(colNames[nameIndex], filename, '\t');
            return(null);
        }
        public void LoadData(IMatrixData matrixData, Parameters parameters, ref IMatrixData[] supplTables,
                             ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            int             ind            = parameters.GetParam <int>("Organism").Value;
            string          filename       = GetOrganismFiles()[ind];
            List <string>   stringColnames = new List <string>(TabSep.GetColumnNames(filename, '\t'));
            List <string[]> stringCols     = new List <string[]>();

            foreach (string t in stringColnames)
            {
                string[] col = TabSep.GetColumn(t, filename, '\t');
                stringCols.Add(col);
            }
            matrixData.Name        = "Gene list";
            matrixData.ColumnNames = new List <string>();
            matrixData.Values.Init(stringCols[0].Length, 0);
            matrixData.SetAnnotationColumns(stringColnames, stringCols,
                                            new List <string>(), new List <string[][]>(), new List <string>(), new List <double[]>(), new List <string>(),
                                            new List <double[][]>());
            matrixData.Origin = "Gene list";
        }