IEnumerator FindPath(Vector2 start, Vector2 target)
    {
        PathWay[] pathPoints    = new PathWay[0];
        bool      pathSuccess   = false;
        Waypoint  startingPoint = handler.PointFromWorldPosition(start);
        Waypoint  targetPoint   = handler.PointFromWorldPosition(target);

        Heap <Waypoint>    openSet   = new Heap <Waypoint> (handler.wayPointSize); //to be evaluated
        HashSet <Waypoint> closedSet = new HashSet <Waypoint> ();                  //already evaluated

        openSet.Add(startingPoint);

        while (openSet.Count > 0)
        {
            Waypoint currentPoint = openSet.RemoveFirst();
            closedSet.Add(currentPoint);
            //gizmoPath.Add (currentPoint);
            if (currentPoint == targetPoint)
            {
                pathSuccess = true;
                break;
            }
            foreach (Waypoint neighbour in currentPoint.getNeighbours())
            {
                if (closedSet.Contains(neighbour))
                {
                    continue;
                }
                int newMovementCostToNeighbour = currentPoint.gCost + GetDistance(currentPoint, neighbour);
                if (newMovementCostToNeighbour < neighbour.gCost || !openSet.Contains(neighbour))
                {
                    neighbour.gCost  = newMovementCostToNeighbour;
                    neighbour.hCost  = GetDistance(neighbour, targetPoint);
                    neighbour.parent = currentPoint;

                    if (!openSet.Contains(neighbour))
                    {
                        openSet.Add(neighbour);
                    }
                    else
                    {
                        openSet.UpdateItem(neighbour);
                    }
                }
            }
        }
        yield return(null);

        if (pathSuccess)
        {
            pathPoints = RetracePath(startingPoint, targetPoint);
        }
        requestManager.FinishedProcessingPath(pathPoints, pathSuccess);
    }
Exemple #2
0
        private void FindNextMove(PathWay rightWay, MoveType lastMove, int gotoPosition)
        {
            var current      = this.Player.Walk[rightWay.Position];
            var nextRightWay = new List <PathWay>();

            while (true)
            {
                if (current.East && lastMove != MoveType.West)
                {
                    rightWay.Path.Add(MoveType.East);
                    nextRightWay.Add(new PathWay(rightWay.Position + 1, rightWay.Path));
                }

                if (current.West && lastMove != MoveType.East)
                {
                    rightWay.Path.Add(MoveType.West);
                    nextRightWay.Add(new PathWay(rightWay.Position - 1, rightWay.Path));
                }

                if (current.North && lastMove != MoveType.South)
                {
                    rightWay.Path.Add(MoveType.North);
                    nextRightWay.Add(new PathWay(rightWay.Position - this.Width, rightWay.Path));
                }

                if (current.South && lastMove != MoveType.North)
                {
                    rightWay.Path.Add(MoveType.South);
                    nextRightWay.Add(new PathWay(rightWay.Position + this.Width, rightWay.Path));
                }

                nextRightWay.ForEach(f =>
                {
                    if (f.Position == gotoPosition)
                    {
                        this.FinalWay.Add(f);
                    }

                    this.FindNextMove(f, f.Path.Last(), gotoPosition);
                });
                break;
            }
        }
Exemple #3
0
    public void LaunchLevel(string sceneName)
    {
        if (!done)
        {
            Sequence  sequence = DOTween.Sequence();
            PathWay   thisPath = myPaths[sceneName];
            Vector3[] path     = new Vector3[thisPath.wayPoints.Length];
            for (int i = 0; i < path.Length; i++)
            {
                path[i] = thisPath.wayPoints[i].position;
            }

            sequence.Append(playerIcon.transform.DOPath(path, 0.5f * path.Length));
            sequence.Play();
            done = true;
            StartCoroutine(Load(sceneName, sequence.Duration() + 1));
            foreach (var item in GetComponentsInChildren <Button>())
            {
                item.interactable = false;
            }
        }
    }
    private void InterActQuery2(string[] Proteins, string pType)
    {
        if (pType == "IPI")
            this.rbIPI.Checked = true;
        else if (pType == "UNIPROT")
            this.rbUniprot.Checked = true;
        else
            this.rbGeneName.Checked = true;

        string ProteinList = "";
        for (int i = 0; i < Proteins.Length; i++)
        {
            if (ProteinList == "")
                ProteinList = string.Format("'{0}'", Proteins[i]);
            else
                ProteinList += string.Format(",'{0}'", Proteins[i]);
        }

        Hashtable IntactsList = new Hashtable();

        string strSQL = string.Format("select distinct INTACT_ID,interactorA_id,interactorB_id from INTACT_T where INTERACTORA_ID in ({0}) or INTERACTORB_ID in ({0}) order by interactorA_ID", ProteinList);
        if (pType == "GeneName")
        {
            strSQL = string.Format("select distinct INTACT_ID,ALIAS_INT_A,ALIAS_INT_B from INTACT_T where ALIAS_INT_A in ({0}) or ALIAS_INT_B in ({0}) order by ALIAS_INT_A", ProteinList);
        }
        DataSet Intactresult = DBInterface.QuerySQL2(strSQL);
        if (Intactresult != null)
        {
            for (int i = 0; i < Intactresult.Tables[0].Rows.Count; i++)
            {
                string IntactID = Intactresult.Tables[0].Rows[i].ItemArray[0].ToString();
                string IntactorA = Intactresult.Tables[0].Rows[i].ItemArray[1].ToString();
                string IntactorB = Intactresult.Tables[0].Rows[i].ItemArray[2].ToString();
                if (!IntactsList.ContainsKey(string.Format ("{0}_{1}",IntactorA ,IntactorB)))
                    IntactsList.Add (string.Format ("{0}_{1}",IntactorA ,IntactorB),IntactID);

                //TableRow trIntact = new TableRow();
                //TableCell tcFlag1 = new TableCell();
                //tcFlag1.Text = string.Format("<a href='http://www.ebi.ac.uk/intact/interaction/{0}' target='_blank'>{0}</a>",IntactID);
                //trIntact.Cells.Add(tcFlag1);
                //TableCell tcInteractorA1 = new TableCell();
                //tcInteractorA1.Text = IntactorA;
                //trIntact.Cells.Add(tcInteractorA1);
                //TableCell tcInteractorB1 = new TableCell();
                //tcInteractorB1.Text = IntactorB;
                //trIntact.Cells.Add(tcInteractorB1);

                //tblInteract.Rows.Add(trIntact);
            }
        }
        TableRow trHeader = new TableRow();
        TableCell tcFlag = new TableCell();
        tcFlag.Text = "<a href='http://www.ebi.ac.uk/intact/'><img src=\"_image\\intact-logo.gif\" title=\"EBI IntAct\"></a>";
        trHeader.Cells.Add(tcFlag);

        for (int i = 0; i < Proteins.Length; i++)
        {
            TableCell tcP = new TableCell();
            tcP.Text = string.Format("<div class=\"verticaltext\" height=\"100px\" width=\"20px\">{0}</div> ", Proteins[i]);
            tcP.Height = new Unit(100);
            //tcP.VerticalAlign = VerticalAlign.Top ;
            trHeader.Cells.Add(tcP);
        }
        trHeader.BackColor = System.Drawing.Color.FromArgb(234, 237, 238);

        tblInteract.Rows.Add(trHeader);
        trHeader.Height = new Unit(100);

        for (int i = 0; i < Proteins.Length; i++)
        {
            TableRow trProteins = new TableRow();
            TableCell tcProtein = new TableCell();
            tcProtein.Text = Proteins[i];
            tcProtein.BackColor = System.Drawing.Color.FromArgb(234, 237, 238);
            trProteins.Cells.Add(tcProtein);
            bool bWithAct = false;

            for (int j = 0; j < Proteins.Length; j++)
            {
                TableCell tcIntAct = new TableCell();
                tcIntAct.Width = new Unit("3px");
                if (IntactsList.ContainsKey(string.Format("{0}_{1}", Proteins[i], Proteins[j])))
                {
                    tcIntAct.Text = string.Format("<a href='http://www.ebi.ac.uk/intact/interaction/{0}' target='_blank'><img src=\"_image\\check.gif\" title=\"{1}-vs-{2}\" width=\"5px\"></a>", IntactsList[string.Format("{0}_{1}", Proteins[i], Proteins[j])], Proteins[i], Proteins[j]);
                    bWithAct = true;
                    tcIntAct.BackColor = System.Drawing.Color.FromArgb(0, 0, 245);
                }
                else
                {
                    tcIntAct.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
                }

                tcIntAct.HorizontalAlign = HorizontalAlign.Center;

                trProteins.Cells.Add(tcIntAct);
            }
            if (bWithAct )
            tblInteract.Rows.Add(trProteins);
        }

        if (pType != "IPI")
        {
            Hashtable Pathways = new Hashtable();

            if (pType == "GeneName")
            {
                ProteinList = "";
                for (int i = 0; i < Proteins.Length; i++)
                {
                    if (ProteinList == "")
                        ProteinList = string.Format("'{0}'", getUniprotByGene(Proteins[i]));
                    else
                        ProteinList += string.Format(",'{0}'", getUniprotByGene(Proteins[i]));
                }
            }

             string strRecSQL = string.Format ("select distinct REACT_ID,PATHWAY,URL,uniprot from unipro2pathway_t where uniprot in ({0})", ProteinList );
             DataSet result = DBInterface.QuerySQL2(strRecSQL);
             if (result != null)
             {
                 for (int j = 0; j < result.Tables[0].Rows.Count; j++)
                 {
                     PathWay pw = new PathWay();
                     pw.React_ID = result.Tables[0].Rows[j].ItemArray[0].ToString();
                     pw.PathWayName = result.Tables[0].Rows[j].ItemArray[1].ToString();
                     pw.PahtwayURL = result.Tables[0].Rows[j].ItemArray[2].ToString();
                     string uniprotid = result.Tables[0].Rows[j].ItemArray[3].ToString();
                     if (Pathways.Contains(pw))
                     {
                         Pathways[pw] += "|" + uniprotid + ";" + uniprotid;
                     }
                     else
                         Pathways.Add(pw, uniprotid  + ";" + uniprotid);
                 }
             }
            //// show the pathway information
            //for (int i = 0; i < Proteins.Length; i++)
            //{
            //    string uniprotid = Proteins[i];
            //    if (pType == "GeneName")
            //        uniprotid = getUniprotByGene(Proteins[i]);
            //    string strRecSQL = string.Format("select REACT_ID,PATHWAY,URL from unipro2pathway_t where uniprot='{0}'", uniprotid);
            //    DataSet result = DBInterface.QuerySQL2(strRecSQL);
            //
            //    {
            //        for (int j = 0; j < result.Tables[0].Rows.Count; j++)
            //        {
            //            PathWay pw = new PathWay();
            //            pw.React_ID = result.Tables[0].Rows[j].ItemArray[0].ToString();
            //            pw.PathWayName = result.Tables[0].Rows[j].ItemArray[1].ToString();
            //            pw.PahtwayURL = result.Tables[0].Rows[j].ItemArray[2].ToString();

            //            if (Pathways.Contains(pw))
            //            {
            //                Pathways[pw] += "|" + Proteins[i] + ";" + uniprotid;
            //            }
            //            else
            //                Pathways.Add(pw, Proteins[i] + ";" + uniprotid);
            //        }
            //    }
            //}
            TableRow trPathHeader = new TableRow();
            TableCell tcPathHeader = new TableCell();
            tcPathHeader.Text = "<a href='http://www.reactome.org/'><img src=\"_image\\R-purple-fly.png\" title=\"Reactome\" width=\"64px\" height=\"64px\"></a>";

            trPathHeader.Cells.Add(tcPathHeader);
            TableCell tcProteinsInPath = new TableCell();
            tcProteinsInPath.Text = "Proteins in the pathway";
            trPathHeader.Cells.Add(tcProteinsInPath);
            tbPathways.Rows.Add(trPathHeader);
            foreach (PathWay pw in Pathways.Keys)
            {
                TableRow trPath = new TableRow();
                TableCell tcPathWay = new TableCell();
                tcPathWay.Text = string.Format("<a href=\"{0}\" target='_blank'>{1}</a>", pw.PahtwayURL, pw.PathWayName);
                trPath.Cells.Add(tcPathWay);
                TableCell tcProteins = new TableCell();
                string[] Prots = Pathways[pw].ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < Prots.Length; i++)
                {
                    string protname = Prots[i].Substring(0, Prots[i].IndexOf(";"));
                    string uniprotname = Prots[i].Substring(Prots[i].IndexOf(";") + 1);
                    tcProteins.Text += string.Format("<a href=\"http://www.reactome.org/cgi-bin/link?SOURCE=UniProt&ID={0}\" target='_blank'>{1}</a> ", uniprotname, protname);
                }
                trPath.Cells.Add(tcProteins);
                tbPathways.Rows.Add(trPath);
            }
        }
    }
    private void InterActQuery(string[] Proteins,string pType)
    {
        if (pType == "IPI")
            this.rbIPI.Checked = true;
        else if (pType == "UNIPROT")
            this.rbUniprot.Checked = true;
        else
            this.rbGeneName.Checked = true;

        TableRow trHeader = new TableRow();
        TableCell tcFlag = new TableCell();
        tcFlag.Text = "Proteins";
        trHeader.Cells.Add(tcFlag);

        for (int i = 0; i < Proteins.Length; i++)
        {
            TableCell tcP = new TableCell();
            tcP.Text = string.Format("<div class=\"verticaltext\" height=\"100px\" width=\"100px\">{0}</div> ", Proteins[i]);
            tcP.Height = new Unit(100);
            //tcP.VerticalAlign = VerticalAlign.Top ;
            trHeader.Cells.Add(tcP);
        }
        trHeader.BackColor = System.Drawing.Color.FromArgb(234,237,238);

        tblInteract.Rows.Add(trHeader);

        trHeader.Height = new Unit(100);

        for (int i = 0; i < Proteins.Length; i++)
        {
            TableRow trProteins = new TableRow();
            TableCell tcProtein = new TableCell();
            tcProtein.Text = Proteins[i];
            tcProtein.BackColor = System.Drawing.Color.FromArgb(234, 237, 238);
            trProteins.Cells.Add(tcProtein);

            for (int j = 0; j < Proteins.Length; j++)
            {
                string IntactID = GetIntActID(Proteins[i], Proteins[j],pType);

                TableCell tcIntAct = new TableCell();
                if (IntactID != null)
                {
                    tcIntAct.Text = string.Format("<a href='http://www.ebi.ac.uk/intact/interaction/{0}' target='_blank'><img src=\"_image\\check.gif\" title=\"{1}-vs-{2}\"></a>",IntactID,Proteins [i],Proteins[j] );
                }
                else
                {

                }
                tcIntAct.HorizontalAlign = HorizontalAlign.Center;
                trProteins.Cells.Add(tcIntAct);
            }
            tblInteract.Rows.Add(trProteins);
        }

        if (pType != "IPI")
        {
            Hashtable Pathways = new Hashtable();
            // show the pathway information
            for (int i = 0; i < Proteins.Length; i++)
            {
                string uniprotid = Proteins[i];
                if (pType == "GeneName")
                    uniprotid = getUniprotByGene(Proteins [i]);
                string strRecSQL = string.Format("select REACT_ID,PATHWAY,URL from unipro2pathway_t where uniprot='{0}'", uniprotid);
                 DataSet result = DBInterface.QuerySQL2(strRecSQL);
                 if (result != null)
                 {
                     for (int j=0;j<result.Tables[0].Rows.Count;j++)
                     {
                         PathWay pw = new PathWay();
                         pw.React_ID = result.Tables[0].Rows[j].ItemArray[0].ToString ();
                         pw.PathWayName = result.Tables[0].Rows[j].ItemArray[1].ToString ();
                         pw.PahtwayURL = result.Tables[0].Rows[j].ItemArray[2].ToString ();

                         if (Pathways.Contains(pw))
                         {
                             Pathways[pw] += "|" + Proteins[i]+";"+uniprotid  ;
                         }
                         else
                             Pathways.Add(pw, Proteins[i] + ";" + uniprotid);
                     }
                 }
            }
            TableRow trPathHeader = new TableRow();
            TableCell tcPathHeader = new TableCell();
            tcPathHeader.Text = "Pathway";
            trPathHeader.Cells.Add(tcPathHeader);
            TableCell tcProteinsInPath = new TableCell();
            tcProteinsInPath.Text = "Proteins in the pathway";
            trPathHeader.Cells.Add(tcProteinsInPath);
            tbPathways.Rows.Add(trPathHeader);
            foreach (PathWay pw in Pathways.Keys )
            {
                TableRow trPath = new TableRow();
                TableCell tcPathWay = new TableCell();
                tcPathWay.Text = string.Format("<a href=\"{0}\" target='_blank'>{1}</a>", pw.PahtwayURL, pw.PathWayName);
                trPath.Cells.Add(tcPathWay);
                TableCell tcProteins = new TableCell();
                string[] Prots = Pathways[pw].ToString ().Split (new string[]{"|"},StringSplitOptions.RemoveEmptyEntries );
                for (int i=0;i<Prots.Length ;i++)
                {
                    string protname = Prots[i].Substring(0, Prots[i].IndexOf(";"));
                    string uniprotname = Prots[i].Substring(Prots[i].IndexOf(";") + 1);
                    tcProteins.Text += string.Format("<a href=\"http://www.reactome.org/cgi-bin/link?SOURCE=UniProt&ID={0}\" target='_blank'>{1}</a> ", uniprotname ,protname );
                }
                trPath.Cells.Add(tcProteins);
                tbPathways.Rows.Add(trPath);
            }
        }
    }
    private void InterActQuery(string[] Proteins, string pType)
    {
        if (pType == "IPI")
        {
            this.rbIPI.Checked = true;
        }
        else if (pType == "UNIPROT")
        {
            this.rbUniprot.Checked = true;
        }
        else
        {
            this.rbGeneName.Checked = true;
        }

        TableRow  trHeader = new TableRow();
        TableCell tcFlag   = new TableCell();

        tcFlag.Text = "Proteins";
        trHeader.Cells.Add(tcFlag);

        for (int i = 0; i < Proteins.Length; i++)
        {
            TableCell tcP = new TableCell();
            tcP.Text   = string.Format("<div class=\"verticaltext\" height=\"100px\" width=\"100px\">{0}</div> ", Proteins[i]);
            tcP.Height = new Unit(100);
            //tcP.VerticalAlign = VerticalAlign.Top ;
            trHeader.Cells.Add(tcP);
        }
        trHeader.BackColor = System.Drawing.Color.FromArgb(234, 237, 238);

        tblInteract.Rows.Add(trHeader);

        trHeader.Height = new Unit(100);

        for (int i = 0; i < Proteins.Length; i++)
        {
            TableRow  trProteins = new TableRow();
            TableCell tcProtein  = new TableCell();
            tcProtein.Text      = Proteins[i];
            tcProtein.BackColor = System.Drawing.Color.FromArgb(234, 237, 238);
            trProteins.Cells.Add(tcProtein);

            for (int j = 0; j < Proteins.Length; j++)
            {
                string IntactID = GetIntActID(Proteins[i], Proteins[j], pType);

                TableCell tcIntAct = new TableCell();
                if (IntactID != null)
                {
                    tcIntAct.Text = string.Format("<a href='http://www.ebi.ac.uk/intact/interaction/{0}' target='_blank'><img src=\"_image\\check.gif\" title=\"{1}-vs-{2}\"></a>", IntactID, Proteins [i], Proteins[j]);
                }
                else
                {
                }
                tcIntAct.HorizontalAlign = HorizontalAlign.Center;
                trProteins.Cells.Add(tcIntAct);
            }
            tblInteract.Rows.Add(trProteins);
        }


        if (pType != "IPI")
        {
            Hashtable Pathways = new Hashtable();
            // show the pathway information
            for (int i = 0; i < Proteins.Length; i++)
            {
                string uniprotid = Proteins[i];
                if (pType == "GeneName")
                {
                    uniprotid = getUniprotByGene(Proteins [i]);
                }
                string  strRecSQL = string.Format("select REACT_ID,PATHWAY,URL from unipro2pathway_t where uniprot='{0}'", uniprotid);
                DataSet result    = DBInterface.QuerySQL2(strRecSQL);
                if (result != null)
                {
                    for (int j = 0; j < result.Tables[0].Rows.Count; j++)
                    {
                        PathWay pw = new PathWay();
                        pw.React_ID    = result.Tables[0].Rows[j].ItemArray[0].ToString();
                        pw.PathWayName = result.Tables[0].Rows[j].ItemArray[1].ToString();
                        pw.PahtwayURL  = result.Tables[0].Rows[j].ItemArray[2].ToString();

                        if (Pathways.Contains(pw))
                        {
                            Pathways[pw] += "|" + Proteins[i] + ";" + uniprotid;
                        }
                        else
                        {
                            Pathways.Add(pw, Proteins[i] + ";" + uniprotid);
                        }
                    }
                }
            }
            TableRow  trPathHeader = new TableRow();
            TableCell tcPathHeader = new TableCell();
            tcPathHeader.Text = "Pathway";
            trPathHeader.Cells.Add(tcPathHeader);
            TableCell tcProteinsInPath = new TableCell();
            tcProteinsInPath.Text = "Proteins in the pathway";
            trPathHeader.Cells.Add(tcProteinsInPath);
            tbPathways.Rows.Add(trPathHeader);
            foreach (PathWay pw in Pathways.Keys)
            {
                TableRow  trPath    = new TableRow();
                TableCell tcPathWay = new TableCell();
                tcPathWay.Text = string.Format("<a href=\"{0}\" target='_blank'>{1}</a>", pw.PahtwayURL, pw.PathWayName);
                trPath.Cells.Add(tcPathWay);
                TableCell tcProteins = new TableCell();
                string[]  Prots      = Pathways[pw].ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < Prots.Length; i++)
                {
                    string protname    = Prots[i].Substring(0, Prots[i].IndexOf(";"));
                    string uniprotname = Prots[i].Substring(Prots[i].IndexOf(";") + 1);
                    tcProteins.Text += string.Format("<a href=\"http://www.reactome.org/cgi-bin/link?SOURCE=UniProt&ID={0}\" target='_blank'>{1}</a> ", uniprotname, protname);
                }
                trPath.Cells.Add(tcProteins);
                tbPathways.Rows.Add(trPath);
            }
        }
    }
    private void InterActQuery2(string[] Proteins, string pType)
    {
        if (pType == "IPI")
        {
            this.rbIPI.Checked = true;
        }
        else if (pType == "UNIPROT")
        {
            this.rbUniprot.Checked = true;
        }
        else
        {
            this.rbGeneName.Checked = true;
        }

        string ProteinList = "";

        for (int i = 0; i < Proteins.Length; i++)
        {
            if (ProteinList == "")
            {
                ProteinList = string.Format("'{0}'", Proteins[i]);
            }
            else
            {
                ProteinList += string.Format(",'{0}'", Proteins[i]);
            }
        }

        Hashtable IntactsList = new Hashtable();

        string strSQL = string.Format("select distinct INTACT_ID,interactorA_id,interactorB_id from INTACT_T where INTERACTORA_ID in ({0}) or INTERACTORB_ID in ({0}) order by interactorA_ID", ProteinList);

        if (pType == "GeneName")
        {
            strSQL = string.Format("select distinct INTACT_ID,ALIAS_INT_A,ALIAS_INT_B from INTACT_T where ALIAS_INT_A in ({0}) or ALIAS_INT_B in ({0}) order by ALIAS_INT_A", ProteinList);
        }
        DataSet Intactresult = DBInterface.QuerySQL2(strSQL);

        if (Intactresult != null)
        {
            for (int i = 0; i < Intactresult.Tables[0].Rows.Count; i++)
            {
                string IntactID  = Intactresult.Tables[0].Rows[i].ItemArray[0].ToString();
                string IntactorA = Intactresult.Tables[0].Rows[i].ItemArray[1].ToString();
                string IntactorB = Intactresult.Tables[0].Rows[i].ItemArray[2].ToString();
                if (!IntactsList.ContainsKey(string.Format("{0}_{1}", IntactorA, IntactorB)))
                {
                    IntactsList.Add(string.Format("{0}_{1}", IntactorA, IntactorB), IntactID);
                }

                //TableRow trIntact = new TableRow();
                //TableCell tcFlag1 = new TableCell();
                //tcFlag1.Text = string.Format("<a href='http://www.ebi.ac.uk/intact/interaction/{0}' target='_blank'>{0}</a>",IntactID);
                //trIntact.Cells.Add(tcFlag1);
                //TableCell tcInteractorA1 = new TableCell();
                //tcInteractorA1.Text = IntactorA;
                //trIntact.Cells.Add(tcInteractorA1);
                //TableCell tcInteractorB1 = new TableCell();
                //tcInteractorB1.Text = IntactorB;
                //trIntact.Cells.Add(tcInteractorB1);


                //tblInteract.Rows.Add(trIntact);
            }
        }
        TableRow  trHeader = new TableRow();
        TableCell tcFlag   = new TableCell();

        tcFlag.Text = "<a href='http://www.ebi.ac.uk/intact/'><img src=\"_image\\intact-logo.gif\" title=\"EBI IntAct\"></a>";
        trHeader.Cells.Add(tcFlag);

        for (int i = 0; i < Proteins.Length; i++)
        {
            TableCell tcP = new TableCell();
            tcP.Text   = string.Format("<div class=\"verticaltext\" height=\"100px\" width=\"20px\">{0}</div> ", Proteins[i]);
            tcP.Height = new Unit(100);
            //tcP.VerticalAlign = VerticalAlign.Top ;
            trHeader.Cells.Add(tcP);
        }
        trHeader.BackColor = System.Drawing.Color.FromArgb(234, 237, 238);

        tblInteract.Rows.Add(trHeader);
        trHeader.Height = new Unit(100);

        for (int i = 0; i < Proteins.Length; i++)
        {
            TableRow  trProteins = new TableRow();
            TableCell tcProtein  = new TableCell();
            tcProtein.Text      = Proteins[i];
            tcProtein.BackColor = System.Drawing.Color.FromArgb(234, 237, 238);
            trProteins.Cells.Add(tcProtein);
            bool bWithAct = false;

            for (int j = 0; j < Proteins.Length; j++)
            {
                TableCell tcIntAct = new TableCell();
                tcIntAct.Width = new Unit("3px");
                if (IntactsList.ContainsKey(string.Format("{0}_{1}", Proteins[i], Proteins[j])))
                {
                    tcIntAct.Text      = string.Format("<a href='http://www.ebi.ac.uk/intact/interaction/{0}' target='_blank'><img src=\"_image\\check.gif\" title=\"{1}-vs-{2}\" width=\"5px\"></a>", IntactsList[string.Format("{0}_{1}", Proteins[i], Proteins[j])], Proteins[i], Proteins[j]);
                    bWithAct           = true;
                    tcIntAct.BackColor = System.Drawing.Color.FromArgb(0, 0, 245);
                }
                else
                {
                    tcIntAct.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
                }

                tcIntAct.HorizontalAlign = HorizontalAlign.Center;

                trProteins.Cells.Add(tcIntAct);
            }
            if (bWithAct)
            {
                tblInteract.Rows.Add(trProteins);
            }
        }

        if (pType != "IPI")
        {
            Hashtable Pathways = new Hashtable();

            if (pType == "GeneName")
            {
                ProteinList = "";
                for (int i = 0; i < Proteins.Length; i++)
                {
                    if (ProteinList == "")
                    {
                        ProteinList = string.Format("'{0}'", getUniprotByGene(Proteins[i]));
                    }
                    else
                    {
                        ProteinList += string.Format(",'{0}'", getUniprotByGene(Proteins[i]));
                    }
                }
            }

            string  strRecSQL = string.Format("select distinct REACT_ID,PATHWAY,URL,uniprot from unipro2pathway_t where uniprot in ({0})", ProteinList);
            DataSet result    = DBInterface.QuerySQL2(strRecSQL);
            if (result != null)
            {
                for (int j = 0; j < result.Tables[0].Rows.Count; j++)
                {
                    PathWay pw = new PathWay();
                    pw.React_ID    = result.Tables[0].Rows[j].ItemArray[0].ToString();
                    pw.PathWayName = result.Tables[0].Rows[j].ItemArray[1].ToString();
                    pw.PahtwayURL  = result.Tables[0].Rows[j].ItemArray[2].ToString();
                    string uniprotid = result.Tables[0].Rows[j].ItemArray[3].ToString();
                    if (Pathways.Contains(pw))
                    {
                        Pathways[pw] += "|" + uniprotid + ";" + uniprotid;
                    }
                    else
                    {
                        Pathways.Add(pw, uniprotid + ";" + uniprotid);
                    }
                }
            }
            //// show the pathway information
            //for (int i = 0; i < Proteins.Length; i++)
            //{
            //    string uniprotid = Proteins[i];
            //    if (pType == "GeneName")
            //        uniprotid = getUniprotByGene(Proteins[i]);
            //    string strRecSQL = string.Format("select REACT_ID,PATHWAY,URL from unipro2pathway_t where uniprot='{0}'", uniprotid);
            //    DataSet result = DBInterface.QuerySQL2(strRecSQL);
            //
            //    {
            //        for (int j = 0; j < result.Tables[0].Rows.Count; j++)
            //        {
            //            PathWay pw = new PathWay();
            //            pw.React_ID = result.Tables[0].Rows[j].ItemArray[0].ToString();
            //            pw.PathWayName = result.Tables[0].Rows[j].ItemArray[1].ToString();
            //            pw.PahtwayURL = result.Tables[0].Rows[j].ItemArray[2].ToString();

            //            if (Pathways.Contains(pw))
            //            {
            //                Pathways[pw] += "|" + Proteins[i] + ";" + uniprotid;
            //            }
            //            else
            //                Pathways.Add(pw, Proteins[i] + ";" + uniprotid);
            //        }
            //    }
            //}
            TableRow  trPathHeader = new TableRow();
            TableCell tcPathHeader = new TableCell();
            tcPathHeader.Text = "<a href='http://www.reactome.org/'><img src=\"_image\\R-purple-fly.png\" title=\"Reactome\" width=\"64px\" height=\"64px\"></a>";

            trPathHeader.Cells.Add(tcPathHeader);
            TableCell tcProteinsInPath = new TableCell();
            tcProteinsInPath.Text = "Proteins in the pathway";
            trPathHeader.Cells.Add(tcProteinsInPath);
            tbPathways.Rows.Add(trPathHeader);
            foreach (PathWay pw in Pathways.Keys)
            {
                TableRow  trPath    = new TableRow();
                TableCell tcPathWay = new TableCell();
                tcPathWay.Text = string.Format("<a href=\"{0}\" target='_blank'>{1}</a>", pw.PahtwayURL, pw.PathWayName);
                trPath.Cells.Add(tcPathWay);
                TableCell tcProteins = new TableCell();
                string[]  Prots      = Pathways[pw].ToString().Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < Prots.Length; i++)
                {
                    string protname    = Prots[i].Substring(0, Prots[i].IndexOf(";"));
                    string uniprotname = Prots[i].Substring(Prots[i].IndexOf(";") + 1);
                    tcProteins.Text += string.Format("<a href=\"http://www.reactome.org/cgi-bin/link?SOURCE=UniProt&ID={0}\" target='_blank'>{1}</a> ", uniprotname, protname);
                }
                trPath.Cells.Add(tcProteins);
                tbPathways.Rows.Add(trPath);
            }
        }
    }
Exemple #8
0
 public bool UpdatePathWay(PathWay pathWay)
 {
     _db.PathWays.Update(pathWay);
     return(Save());
 }
Exemple #9
0
 public bool DeletePathWay(PathWay pathWay)
 {
     _db.PathWays.Remove(pathWay);
     return(Save());
 }
Exemple #10
0
 public bool CreatePathWay(PathWay pathWay)
 {
     _db.PathWays.Add(pathWay);
     return(Save());
 }