private void QueryPeptides(string ProteinID)
    {
        string PepIDURL = "<a href='PeptideInfo.aspx?QType=Peptide+ID&QValue={0}'>{1}</a>";
        string strSQL = string.Format("select a.peptide_sequence, a.peptide_sequence,b.prevaa,b.nextaa,a.Molecular_weight,b.location,a.Enzyme_Specificity from peptide_tbl a, pp_relation_tbl b where a.peptide_sequence = b.peptide_sequence and b.location<> -1 and b.protein_id='{0}' order by b.location", DBInterface.SQLValidString(ProteinID));
        DataSet result = DBInterface.QuerySQL2(strSQL);
        if (result != null)
        {

            for (int j = 0; j < result.Tables[0].Rows.Count; j++)
            {
                TableRow trCaption = new TableRow();
                TableCell tcPepID = new TableCell();
                string PeptideID = result.Tables[0].Rows[j].ItemArray[0].ToString();
                tcPepID.Text = string.Format(PepIDURL, PeptideID, PeptideID);
                tcPepID.HorizontalAlign = HorizontalAlign.Left;
                trCaption.Cells.Add(tcPepID);
                TableCell tcPreAA = new TableCell();
                tcPreAA.Text = result.Tables[0].Rows[j].ItemArray[2].ToString();
                tcPreAA.HorizontalAlign = HorizontalAlign.Center;
                trCaption.Cells.Add(tcPreAA);
                //TableCell tcSequence = new TableCell();
                //tcSequence.Text = result.Tables[0].Rows[j].ItemArray[1].ToString();
                //tcSequence.HorizontalAlign = HorizontalAlign.Left;
                //trCaption.Cells.Add(tcSequence);
                TableCell tcNextAA = new TableCell();
                tcNextAA.Text = result.Tables[0].Rows[j].ItemArray[3].ToString();
                tcNextAA.HorizontalAlign = HorizontalAlign.Center;
                trCaption.Cells.Add(tcNextAA);
                TableCell tcMW = new TableCell();
                tcMW.Text = result.Tables[0].Rows[j].ItemArray[4].ToString();
                tcMW.HorizontalAlign = HorizontalAlign.Right;
                trCaption.Cells.Add(tcMW);
                TableCell tcFully = new TableCell();
                tcFully.Text = result.Tables[0].Rows[j].ItemArray[5].ToString();
                tcFully.HorizontalAlign = HorizontalAlign.Right;
                trCaption.Cells.Add(tcFully);
                TableCell tcEnzyme = new TableCell();
                tcEnzyme.Text = result.Tables[0].Rows[j].ItemArray[6].ToString();
                tcEnzyme.HorizontalAlign = HorizontalAlign.Right;
                trCaption.Cells.Add(tcEnzyme);
                tbPeptides.Rows.Add(trCaption);
            }

            lbDistinct_Peptides.Text = result.Tables[0].Rows.Count.ToString();
            imgPeptides.ImageUrl = String.Format("ProSeqImage.aspx?PID={0}&L={1}&NO={2:F0}", ProteinID, lbSequence_Length.Text, result.Tables[0].Rows.Count);
            lbPeptideNumber.Text = string.Format("Totals: {0:F0}", result.Tables[0].Rows.Count);
            try
            {
                PeptidesImageInfo PIF = new PeptidesImageInfo(ProteinID, int.Parse(lbSequence_Length.Text), result.Tables[0].Rows.Count);
                int totalHeight = 0;
                ArrayList RectArray = PIF.ComputeTheValues(ref totalHeight);
                int j = 0;
                for (j = 0; j < result.Tables[0].Rows.Count; j++)
                {
                    PeptidesImageInfo.PepRectInfo rect = (PeptidesImageInfo.PepRectInfo)RectArray[j];
                    RectangleHotSpot recthot = new RectangleHotSpot();
                    recthot.Left = rect.left;
                    recthot.Right = rect.right;
                    recthot.Top = rect.top;
                    recthot.Bottom = rect.bottom;
                    recthot.NavigateUrl = string.Format("PeptideInfo.aspx?QType=Peptide+ID&QValue={0}", rect.PepID);
                    recthot.AlternateText = string.Format("{0}-{1}, {2}", rect.Location, rect.Location + rect.Length, rect.Sequence);
                    imgPeptides.HotSpots.Add(recthot);
                }
            }
            catch (Exception ex)
            {

            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["PID"] == null)
        {
            // don't display anything
        }
        else
        {
            string ProteinID = Request.QueryString["PID"];
            int Totals = 500;
            string strTotals = Request.QueryString ["L"];
            string PeptideNumb = Request.QueryString["NO"];
            int iPeptideNumb = 0;
            try
            {
                if (strTotals != "")
                    Totals = int.Parse(strTotals);
                if (PeptideNumb != "")
                    iPeptideNumb = int.Parse(PeptideNumb);

            }
            catch
            { }

            if (Totals>= 2000 && Totals< 5000)
            {
                BIGSEG = 500;
                SMALLSEG = 50;
            }
            else if (Totals > 5000 && Totals <20000)
            {
                BIGSEG = 1000;
                SMALLSEG = 100;
            }
            else if (Totals >= 20000)
            {
                BIGSEG = 5000;
                SMALLSEG = 500;
            }
            else
            {
                BIGSEG = 100;
                SMALLSEG = 10;
            }

            //try
            //{
            //    if (PeptideNumb != null)
            //        Height += int.Parse(PeptideNumb) * PEPROWHEIGHT ;
            //}
            //catch (Exception ex)
            //{

            //}
            Font font = new Font("courier",10,FontStyle.Regular );

            PeptidesImageInfo PIF = new PeptidesImageInfo(ProteinID, Totals, iPeptideNumb);
            int totalHeight = 0;
            ArrayList RectArray = PIF.ComputeTheValues(ref totalHeight);
            Height = totalHeight;
            Bitmap image = new Bitmap(WIDTH , Height );

            Graphics g = Graphics.FromImage(image);
            g.FillRectangle(Brushes.White, 0, 0, WIDTH, Height);
            float unit;
            DrawAxis(g,Totals, BIGSEG, SMALLSEG,out unit);
            DrawPeptide(g,RectArray);
            image.Save(Response.OutputStream , System.Drawing.Imaging.ImageFormat.Gif );
            g.Dispose();
            image.Dispose();
        }
    }