コード例 #1
0
ファイル: frmMotifScorerBase.cs プロジェクト: EmineTopcu/PeSA
        private void DisplayMotif()
        {
            if (Motif == null)
            {
                return;
            }

            Settings settings    = Settings.Load("default.settings");
            int      heightImage = 200;
            int      widthImage  = 800;

            if (settings != null)
            {
                heightImage = settings.MotifHeight;
                widthImage  = settings.MotifWidth;
            }
            if (Motif.PositiveColumns != null)
            {
                mdPositive.Image = Motif.GetPositiveMotif(widthImage, heightImage);
            }
            else if (Motif.Frequencies != null)
            {
                mdPositive.Image = Motif.GetFrequencyMotif(widthImage, heightImage);
            }
            else
            {
                mdPositive.Image = null;
            }
            if (Motif.NegativeColumns != null)
            {
                mdNegative.Image = Motif.GetNegativeMotif(widthImage, heightImage);
            }
            else
            {
                mdNegative.Visible = false;
                mdNegative.Image   = null;
            }
            if (Motif.PositiveColumns != null)
            {
                mdChart.Image = Motif.GetBarChart(pMotif.Width - 6);
            }
            else
            {
                mdChart.Visible = false;
            }

            ePositiveThreshold.Text = Motif.PositiveThreshold.ToString();
            toolTip1.SetToolTip(eScorerPosThreshold, string.Format("Range: [{0:N2}, {1:N2}]", Motif.PositiveThreshold, Motif.MaxPosWeight));
            eNegativeThreshold.Text = Motif.NegativeThreshold.ToString();
            toolTip1.SetToolTip(eScorerNegThreshold, string.Format("Range: [{0:N2}, {1:N2}]", 0, Motif.NegativeThreshold));
            eWildtype.Text        = Motif.WildTypePeptide;
            eTargetPosition.Text  = "";
            eTargetAminoAcid.Text = "";
        }
コード例 #2
0
        private void DrawMotifs()
        {
            ClearMotifs();
            Settings settings    = Settings.Load("default.settings");
            int      heightImage = 200;
            int      widthImage  = 800;

            if (settings != null)
            {
                heightImage = settings.MotifHeight;
                widthImage  = settings.MotifWidth;
            }

            int midpoint = peptidelength / 2;

            if (Int32.TryParse(eKeyPosition.Text, out keyPos) && keyPos <= peptidelength && keyPos > 0)
            {
                midpoint = keyPos - 1;
            }
            else
            {
                keyPos            = midpoint + 1;
                eKeyPosition.Text = keyPos.ToString();
            }

            if (!Char.TryParse(eAminoAcid.Text.Trim(), out keyAA))
            {
                keyAA           = ' ';
                eAminoAcid.Text = keyAA.ToString();
            }
            else if (Char.IsLower(keyAA))
            {
                keyAA = Char.ToUpper(keyAA);
            }

            if (keyAA != ' ')
            {
                List <string> mainList = Peptides.Where(s => s[keyPos - 1] == keyAA).ToList();

                List <string> shiftedList = Analyzer.ShiftPeptides(Peptides.Where(s => s[keyPos - 1] != keyAA).ToList(), keyAA, peptidelength, keyPos - 1, out List <string> replacements);
                MainMotif = new Motif(mainList, peptidelength);
                MainMotif.FreqThreshold = threshold;
                Bitmap bm = MainMotif.GetFrequencyMotif(widthImage, heightImage);
                mdMain.Image = bm;

                ShiftedMotif = new Motif(shiftedList, peptidelength);
                ShiftedMotif.FreqThreshold = threshold;
                bm = ShiftedMotif.GetFrequencyMotif(widthImage, heightImage);
                mdShifted.Image   = bm;
                mdShifted.Visible = true;
                eOutput.Text     += String.Join("\r\nInfo: ", replacements) + "\r\n";
                eOutput.Text     += "Motifs are created succesfully.\r\n";
            }
            else
            {
                MainMotif = new Motif(Peptides, peptidelength);
                MainMotif.FreqThreshold = threshold;
                Bitmap bm = MainMotif.GetFrequencyMotif(widthImage, heightImage);
                mdMain.Image      = bm;
                mdShifted.Visible = false;
                eOutput.Text     += "Motif is created succesfully.\r\n";
            }
        }
コード例 #3
0
        private bool DrawMotifs()
        {
            try
            {
                ClearMotifs();
                if (PA == null)
                {
                    return(true);
                }
                Settings settings    = Settings.Load("default.settings");
                int      heightImage = 200;
                int      widthImage  = 800;
                if (settings != null)
                {
                    heightImage = settings.MotifHeight;
                    widthImage  = settings.MotifWidth;
                }

                int midpoint = peptidelength / 2;
                if (Int32.TryParse(eKeyPosition.Text, out int keyPos) && keyPos <= peptidelength && keyPos > 0)
                {
                    midpoint = keyPos - 1;
                }
                else
                {
                    keyPos            = midpoint + 1;
                    eKeyPosition.Text = keyPos.ToString();
                }
                PA.KeyPosition = keyPos;

                if (!Char.TryParse(eAminoAcid.Text.Trim(), out char keyAA))
                {
                    keyAA           = ' ';
                    eAminoAcid.Text = keyAA.ToString();
                }
                else if (Char.IsLower(keyAA))
                {
                    keyAA = Char.ToUpper(keyAA);
                }

                PA.KeyAA = keyAA;
                if (keyAA != ' ')
                {
                    List <string> mainList = PA.ModifiedPeptides.Where(s => s[keyPos - 1] == keyAA).ToList();

                    List <string> shiftedList = Analyzer.ShiftPeptides(PA.ModifiedPeptides.Where(s => s[keyPos - 1] != keyAA).ToList(), keyAA, peptidelength, keyPos - 1, out List <string> replacements);
                    MotifMain = new Motif(mainList, peptidelength);
                    MotifMain.FreqThreshold = PA.FrequencyThreshold;
                    Bitmap bm = MotifMain.GetFrequencyMotif(widthImage, heightImage);
                    mdMain.Image = bm;

                    MotifShifted = new Motif(shiftedList, peptidelength);
                    MotifShifted.FreqThreshold = PA.FrequencyThreshold;
                    bm = MotifShifted.GetFrequencyMotif(widthImage, heightImage);
                    mdShifted.Image   = bm;
                    mdShifted.Visible = true;
                }
                else
                {
                    MotifMain = new Motif(PA.ModifiedPeptides, peptidelength);
                    MotifMain.FreqThreshold = PA.FrequencyThreshold;
                    Bitmap bm = MotifMain.GetFrequencyMotif(widthImage, heightImage);
                    mdMain.Image      = bm;
                    mdShifted.Visible = false;
                }
                return(true);
            }
            catch { return(false); }
        }