コード例 #1
0
ファイル: GORecord.cs プロジェクト: xxq21/Web-Services
 public static GORecord[] FromDataTable(DataTable dt)
 {
     GORecord[] array = new GORecord[dt.Rows.Count];
     for (int i = 0; i < array.Length; i++)
     {
         array[i] = GORecord.FromDataRow(dt.Rows[i]);
     }
     return(array);
 }
コード例 #2
0
        public GORecord[] GetGORecordsFromECNumber(string ecNumber)
        {
            DataTable tableGO   = GetGOFromECNumber(ecNumber);
            ArrayList listTerms = new ArrayList();

            foreach (DataRow rowGO in tableGO.Rows)
            {
                listTerms.Add(GORecord.FromDataRow(rowGO));
            }
            return((GORecord[])listTerms.ToArray(typeof(GORecord)));
        }
コード例 #3
0
ファイル: GORecord.cs プロジェクト: xxq21/Web-Services
//		public void AddMetaRecord(string key, string val)
//		{
//			_meta.Add(new string[]{key, val});
//		}
//
//		public string[][] GetMetaRecords()
//		{
//			return (string[][])_meta.ToArray(typeof(string[]));
//		}
//
//		public void AddMetaRecords(string[][] records)
//		{
//			foreach(string[] pair in records)
//				AddMetaRecord(pair[0], pair[1]);
//		}

        public static GORecord FromDataRow(DataRow dr)
        {
            GORecord rec = new GORecord();

            if (dr.Table.Columns.Contains("GOID"))
            {
                rec._id = (string)dr["GOID"];
                if (rec._id.StartsWith("GO:"))
                {
                    rec._id = rec._id.Substring("GO:".Length);
                }
            }
            if (dr.Table.Columns.Contains("GOName"))
            {
                rec._name = (string)dr["GOName"];
            }

            //put the rest of the DataRow information into the meta dictionary
//			int colID = dr.Table.Columns["GOID"].Ordinal;
//			int colName = dr.Table.Columns["GOName"].Ordinal;
//			for(int i=0; i<dr.Table.Columns.Count; i++)
//			{
//				if( i == colID || i == colName) continue;
//				string key = dr.Table.Columns[i].ColumnName;
//				string val = dr[i].ToString();
//				rec.AddMetaRecord(key, val);
//			}

            if (dr.Table.Columns.Contains("SwissProID"))
            {
                rec._notes = "linked through Protein: " + (string)dr["protein_name"];
            }

            if (dr.Table.Columns.Contains("ECNumber"))
            {
                string ec = (string)dr["ECNumber"];
                rec._notes    = "linked through EC: " + ec;
                rec._ecNumber = ec;
            }
            if (dr.Table.Columns.Contains("process_ID") && !dr.IsNull("process_ID"))
            {
                rec._processID = (Guid)dr["process_ID"];
            }
            if (dr.Table.Columns.Contains("process_name") && !dr.IsNull("process_name"))
            {
                rec._processName = (string)dr["process_name"];
            }
            if (dr.Table.Columns.Contains("TermLevel") && !dr.IsNull("TermLevel"))
            {
                rec._treeLevel = (int)dr["TermLevel"];
            }
            return(rec);
        }
コード例 #4
0
ファイル: GORecord.cs プロジェクト: xxq21/Web-Services
        public override bool Equals(object obj)
        {
            if (obj.GetType() != typeof(GORecord))
            {
                return(base.Equals(obj));
            }
            GORecord rec = obj as GORecord;

            return
                (this.ID == rec.ID &&
                 this.ECNumber == rec.ECNumber &&
                 this.Name == rec.Name &&
                 this.Notes == rec.Notes &&
                 this.ProcessID == rec.ProcessID &&
                 this.ProcessName == rec.ProcessName);
        }
コード例 #5
0
        public GORecord[] GetGORecordsFromProcessID_EC(Guid processID)
        {
            //find the GO Terms through EC Numbers
            //			PathwaysLib.ServerObjects.ServerProcess sp = PathwaysLib.ServerObjects.ServerProcess.Load(processID);
            //			Guid gProcessID = sp.GenericProcessID;
            DataTable dtGO_EC = GetGOFromProcessID_ECNumber(processID);

            ArrayList goRecords = new ArrayList();

            foreach (DataRow dr in dtGO_EC.Rows)
            {
                GORecord rec = GORecord.FromDataRow(dr);
                rec.TreeLevel = GetMaxMaxTreeLevelOfGOTerm(rec.ID);
                goRecords.Add(rec);
            }
            return((GORecord[])goRecords.ToArray(typeof(GORecord)));
        }
コード例 #6
0
        public GORecord[] TransposeGOTermUpToLevel(GORecord record, int treeLevel)
        {
            if (GetMinTreeLevelOfGOTerm_UnderCatalyticActivity(record.ID) <= treeLevel)
            {
                return new GORecord[] { record }
            }
            ;

            //a queue to aid in BFS
            Queue goTerms = new Queue(new GORecord[] { record });

            ArrayList listLevelXAnnotations = new ArrayList();

            //keep track of all categories so we don't go up a path multiple times
            ArrayList listTouchedCategories = new ArrayList();

            while (goTerms.Count > 0)
            {
                GORecord rec = (GORecord)goTerms.Dequeue();

                //if this is at the correct level or above, add it to the annotation list
                int minLevel = GetMaxMaxTreeLevelOfGOTerm(rec.ID);
                if (minLevel <= treeLevel)
                {
                    rec.TreeLevel = minLevel;
                    listLevelXAnnotations.Add(rec);
                }
                else
                {
                    //find it's parents who are under Catalytic Activity and add those to the Queue
                    SqlConnection con = new SqlConnection(CONNECTION_STRING);
                    try
                    {
                        con.Open();

                        string command =
                            "select ParentName = terms.[Name], tt.* from " +
                            "	(select * from Pubmed.dbo.GOTermsTree where ChildID=@childID and OnPathUnderCatalyticActivity=1) tt "+
                            "	inner join "+
                            "	Pubmed.dbo.GOTerms terms "+
                            "	on tt.ParentID = terms.[ID] ";

                        SqlCommand com = new SqlCommand(command, con);
                        com.Parameters.Add("@childID", rec.ID);
                        SqlDataReader dr = com.ExecuteReader();
                        while (dr.Read())
                        {
                            //add a modified version of this same record to the queue
                            string   GOID      = (string)dr["ParentID"];
                            string   GOName    = (string)dr["ParentName"];
                            int      nextLevel = (int)dr["TermLevel"];
                            GORecord newRec    = new GORecord();
                            newRec.ECNumber    = rec.ECNumber;
                            newRec.Notes       = rec.Notes;
                            newRec.ProcessID   = rec.ProcessID;
                            newRec.ProcessName = rec.ProcessName;
                            newRec.TreeLevel   = nextLevel;
                            newRec.ID          = GOID;
                            newRec.Name        = GOName;

                            //only add this category if we haven't been up this path
                            if (!listTouchedCategories.Contains(newRec.ID))
                            {
                                goTerms.Enqueue(newRec);
                                listTouchedCategories.Add(newRec.ID);
                            }
                        }
                        dr.Close();
                    }
                    catch (Exception se) { throw se; }
                    finally{ con.Close(); }
                }
            }

            return((GORecord[])listLevelXAnnotations.ToArray(typeof(GORecord)));
        }