Ejemplo n.º 1
0
        public static PeptideAnalysisFrame ShowPeptideAnalysis(PeptideAnalysis peptideAnalysis)
        {
            if (peptideAnalysis == null)
            {
                return(null);
            }
            var form = Program.FindOpenEntityForm <PeptideAnalysisFrame>(peptideAnalysis);

            if (form != null)
            {
                form.Activate();
                return(form);
            }
            using (peptideAnalysis.IncChromatogramRefCount())
            {
                TopographForm.Instance.LoadPeptideAnalysis(peptideAnalysis.Id);
                if (!peptideAnalysis.ChromatogramsWereLoaded)
                {
                    return(null);
                }
                form = new PeptideAnalysisFrame(peptideAnalysis);
                form.Show(TopographForm.Instance.DocumentPanel, DockState.Document);
                return(form);
            }
        }
Ejemplo n.º 2
0
        public static PeptideFileAnalysisFrame ShowFileAnalysisForm <T>(PeptideFileAnalysis peptideFileAnalysis) where T : PeptideFileAnalysisForm
        {
            var analysisForm = PeptideAnalysisFrame.ShowPeptideAnalysis(peptideFileAnalysis.PeptideAnalysis);

            if (null == analysisForm)
            {
                return(null);
            }
            return(ActivatePeptideDataForm <T>(analysisForm.PeptideAnalysisSummary, peptideFileAnalysis));
        }
Ejemplo n.º 3
0
 private void ShowPeptideAnalysis(Peptide peptide)
 {
     using (var session = Workspace.OpenSession())
     {
         var dbPeptide         = session.Load <DbPeptide>(peptide.Id);
         var dbPeptideAnalysis = (DbPeptideAnalysis)session
                                 .CreateCriteria(typeof(DbPeptideAnalysis))
                                 .Add(Restrictions.Eq("Peptide", dbPeptide))
                                 .UniqueResult();
         if (dbPeptideAnalysis == null)
         {
             var psmTimesByDataFileId = dbPeptide.PsmTimesByDataFileId(session);
             if (psmTimesByDataFileId.Count == 0)
             {
                 MessageBox.Show(
                     "This peptide cannot be analyzed because it has no search results.",
                     Program.AppName);
                 return;
             }
             if (MessageBox.Show("This peptide has not yet been analyzed.  Do you want to analyze it now?", Program.AppName, MessageBoxButtons.OKCancel) == DialogResult.Cancel)
             {
                 return;
             }
             session.BeginTransaction();
             session.Save(dbPeptideAnalysis = Peptide.CreateDbPeptideAnalysis(session, dbPeptide));
             foreach (var grouping in psmTimesByDataFileId)
             {
                 MsDataFile msDataFile;
                 if (!Workspace.MsDataFiles.TryGetValue(grouping.Key, out msDataFile))
                 {
                     continue;
                 }
                 session.Save(PeptideFileAnalysis.CreatePeptideFileAnalysis(
                                  session, msDataFile, dbPeptideAnalysis, psmTimesByDataFileId));
                 dbPeptideAnalysis.FileAnalysisCount++;
             }
             session.Update(dbPeptideAnalysis);
             session.Transaction.Commit();
         }
         var peptideAnalysis = TopographForm.Instance.LoadPeptideAnalysis(dbPeptideAnalysis.GetId());
         if (peptideAnalysis == null)
         {
             return;
         }
         PeptideAnalysisFrame.ShowPeptideAnalysis(peptideAnalysis);
     }
 }
Ejemplo n.º 4
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            var row = dataGridView1.Rows[e.RowIndex];

            if (e.ColumnIndex == colPeptide.Index)
            {
                var peptideSequence = row.Cells[e.ColumnIndex].Value as string;
                if (string.IsNullOrEmpty(peptideSequence))
                {
                    return;
                }
                using (var session = Workspace.OpenSession())
                {
                    var peptideAnalysisIds =
                        session.CreateQuery(
                            "SELECT pa.Id FROM DbPeptideAnalysis pa WHERE pa.Peptide.Sequence = :sequence")
                        .SetParameter("sequence", Peptide.TrimSequence(peptideSequence))
                        .List();
                    if (peptideAnalysisIds.Count >= 0)
                    {
                        PeptideAnalysisFrame.ShowPeptideAnalysis(
                            TurnoverForm.Instance.LoadPeptideAnalysis((long)peptideAnalysisIds[0]));
                    }
                }
                return;
            }
            if (e.ColumnIndex == colProteinKey.Index)
            {
                var halfLifeForm = new HalfLifeForm(Workspace)
                {
                    Peptide     = Peptide.TrimSequence(Convert.ToString(row.Cells[colPeptide.Index].Value) ?? ""),
                    ProteinName = Convert.ToString(row.Cells[colProteinName.Index].Value),
                    MinScore    = double.Parse(tbxMinScore.Text),
                };
                halfLifeForm.Show(DockPanel, DockState);
            }
        }
Ejemplo n.º 5
0
            private void PeptideClickHandler(object sender, EventArgs eventArgs)
            {
                var peptide = _halfLifeResultRow.Peptide;

                if (peptide == null)
                {
                    return;
                }
                DbPeptideAnalysis dbPeptideAnalysis;

                using (var session = _form.Workspace.OpenSession())
                {
                    dbPeptideAnalysis = (DbPeptideAnalysis)session.CreateCriteria(typeof(DbPeptideAnalysis))
                                        .Add(Restrictions.Eq("Peptide", session.Load <DbPeptide>(peptide.Id)))
                                        .UniqueResult();
                    if (dbPeptideAnalysis == null)
                    {
                        return;
                    }
                    PeptideAnalysis peptideAnalysis;
                    if (!_form.Workspace.PeptideAnalyses.TryGetValue(dbPeptideAnalysis.Id.GetValueOrDefault(), out peptideAnalysis))
                    {
                        return;
                    }
                    var form = Program.FindOpenEntityForm <PeptideAnalysisFrame>(peptideAnalysis);
                    if (form != null)
                    {
                        form.Activate();
                        return;
                    }
                    using (peptideAnalysis.IncChromatogramRefCount())
                    {
                        TopographForm.Instance.LoadPeptideAnalysis(dbPeptideAnalysis.Id.GetValueOrDefault());
                        form = new PeptideAnalysisFrame(peptideAnalysis);
                        form.Show(_form.DockPanel, _form.DockState);
                    }
                }
            }
Ejemplo n.º 6
0
 private void PeptideClickHandler(object sender, EventArgs eventArgs)
 {
     var peptide = _halfLifeResultRow.Peptide;
     if (peptide == null)
     {
         return;
     }
     DbPeptideAnalysis dbPeptideAnalysis;
     using (var session = _form.Workspace.OpenSession())
     {
         dbPeptideAnalysis = (DbPeptideAnalysis) session.CreateCriteria(typeof (DbPeptideAnalysis))
             .Add(Restrictions.Eq("Peptide", session.Load<DbPeptide>(peptide.Id)))
             .UniqueResult();
         if (dbPeptideAnalysis == null)
         {
             return;
         }
         PeptideAnalysis peptideAnalysis;
         if (!_form.Workspace.PeptideAnalyses.TryGetValue(dbPeptideAnalysis.Id.GetValueOrDefault(), out peptideAnalysis))
         {
             return;
         }
         var form = Program.FindOpenEntityForm<PeptideAnalysisFrame>(peptideAnalysis);
         if (form != null)
         {
             form.Activate();
             return;
         }
         using (peptideAnalysis.IncChromatogramRefCount())
         {
             TopographForm.Instance.LoadPeptideAnalysis(dbPeptideAnalysis.Id.GetValueOrDefault());
             form = new PeptideAnalysisFrame(peptideAnalysis);
             form.Show(_form.DockPanel, _form.DockState);
         }
     }
 }
Ejemplo n.º 7
0
 public static PeptideAnalysisFrame ShowPeptideAnalysis(PeptideAnalysis peptideAnalysis)
 {
     if (peptideAnalysis == null)
     {
         return null;
     }
     var form = Program.FindOpenEntityForm<PeptideAnalysisFrame>(peptideAnalysis);
     if (form != null)
     {
         form.Activate();
         return form;
     }
     using (peptideAnalysis.IncChromatogramRefCount())
     {
         TopographForm.Instance.LoadPeptideAnalysis(peptideAnalysis.Id);
         if (!peptideAnalysis.ChromatogramsWereLoaded)
         {
             return null;
         }
         form = new PeptideAnalysisFrame(peptideAnalysis);
         form.Show(TopographForm.Instance.DocumentPanel, DockState.Document);
         return form;
     }
 }